23 - Creating WSDL 2.0 and WSDL 1.1 with Java EE: Page 3 of 3

Once the new window is opened, select Web Services / Web service and click Next

      

You should see the Web Service screen. Here le’ts select the class we created so it is exposed as a web service, in our case the WSDemo.java class, so let’s reference it by the fully qualified class name: com.demo.goj.WSDemo.

     

On the configuration part of the screen, click on the Web Service Runtime: and select Axis2 and click OK

    

Now your setting in the Web Service screen should be like the following. Select “Publish the Web Service” and click Finish.

   

By clicking Finish, eclipse will create new elements in our workspace and start the web service in our tomcat instance and you could access the web service by accessing the WSDL file.

To access the WSDL 2.0 version of our web service you should open a web browser and enter the following address:

http://localhost:8080/WebServiceDemo/services/WSDemo?wsdl=wsdl2.0

You should see the WSDL 2.0 document generated for our web service and it should be something like this: 

   

<wsdl2:description xmlns:wsdl2 = "http://www.w3.org/ns/wsdl" xmlns:ns1 = "http://org.apache.axis2/xsd" xmlns:ns = "http://goj.demo.com" xmlns:wsaw = "http://www.w3.org/2006/05/addressing/wsdl" xmlns:wrpc = "http://www.w3.org/ns/wsdl/rpc" xmlns:wsoap = "http://www.w3.org/ns/wsdl/soap" xmlns:tns = "http://goj.demo.com" xmlns:wsdlx = "http://www.w3.org/ns/wsdl-extensions" xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:whttp = "http://www.w3.org/ns/wsdl/http" targetNamespace = "http://goj.demo.com">
    <wsdl2:documentation>Please Type your service description here</wsdl2:documentation>
    <wsdl2:types>
        <xs:schema attributeFormDefault = "qualified" elementFormDefault = "qualified" targetNamespace = "http://goj.demo.com">
            <xs:element name = "helloWorld">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs = "0" name = "name" nillable = "true" type = "xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name = "helloWorldResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs = "0" name = "return" nillable = "true" type = "xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl2:types>
    <wsdl2:interface name = "ServiceInterface">
        <wsdl2:operation name = "helloWorld" style = "http://www.w3.org/ns/wsdl/style/rpc" wrpc:signature = "name #in return #return " pattern = "http://www.w3.org/ns/wsdl/in-out">
            <wsdl2:input element = "ns:helloWorld" wsaw:Action = "urn:helloWorld"/>
            <wsdl2:output element = "ns:helloWorldResponse" wsaw:Action = "urn:helloWorldResponse"/>
        </wsdl2:operation>
    </wsdl2:interface>
    <wsdl2:binding name = "WSDemoSoap11Binding" interface = "tns:ServiceInterface" type = "http://www.w3.org/ns/wsdl/soap" wsoap:version = "1.1">
        <wsdl2:operation ref = "tns:helloWorld" wsoap:action = "urn:helloWorld">
            <wsdl2:input/>
            <wsdl2:output/>
        </wsdl2:operation>
    </wsdl2:binding>
    <wsdl2:binding name = "WSDemoHttpBinding" interface = "tns:ServiceInterface" whttp:methodDefault = "POST" type = "http://www.w3.org/ns/wsdl/http">
        <wsdl2:operation ref = "tns:helloWorld" whttp:location = "helloWorld">
            <wsdl2:input/>
            <wsdl2:output/>
        </wsdl2:operation>
    </wsdl2:binding>
    <wsdl2:binding name = "WSDemoSoap12Binding" interface = "tns:ServiceInterface" type = "http://www.w3.org/ns/wsdl/soap" wsoap:version = "1.2">
        <wsdl2:operation ref = "tns:helloWorld" wsoap:action = "urn:helloWorld">
            <wsdl2:input/>
            <wsdl2:output/>
        </wsdl2:operation>
    </wsdl2:binding>
    <wsdl2:service name = "WSDemo" interface = "tns:ServiceInterface">
        <wsdl2:endpoint name = "WSDemoHttpEndpoint" binding = "tns:WSDemoHttpBinding" address = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpEndpoint/"/>
        <wsdl2:endpoint name = "WSDemoHttpSoap12Endpoint" binding = "tns:WSDemoSoap12Binding" address = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpSoap12Endpoint/"/>
        <wsdl2:endpoint name = "WSDemoHttpSoap11Endpoint" binding = "tns:WSDemoSoap11Binding" address = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpSoap11Endpoint/"/>
    </wsdl2:service>
</wsdl2:description>

Since our WSDL was autogenerated by the Axis plugin, we can also check the WSDL 1.1 version of our web service, to access the WSDL 1.1 version of our web service you should open a web browser and enter the following address:  http://localhost:8080/WebServiceDemo/services/WSDemo?wsdl

You should see the WSDL 1.1 document generated for our web service and it should be something like this: 

<wsdl:definitions xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/" xmlns:ns1 = "http://org.apache.axis2/xsd" xmlns:ns = "http://goj.demo.com" xmlns:wsaw = "http://www.w3.org/2006/05/addressing/wsdl" xmlns:http = "http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:mime = "http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12 = "http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace = "http://goj.demo.com">
    <wsdl:documentation>Please Type your service description here</wsdl:documentation>
    <wsdl:types>
        <xs:schema attributeFormDefault = "qualified" elementFormDefault = "qualified" targetNamespace = "http://goj.demo.com">
            <xs:element name = "helloWorld">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs = "0" name = "name" nillable = "true" type = "xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name = "helloWorldResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs = "0" name = "return" nillable = "true" type = "xs:string"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name = "helloWorldRequest">
        <wsdl:part name = "parameters" element = "ns:helloWorld"/>
    </wsdl:message>
    <wsdl:message name = "helloWorldResponse">
        <wsdl:part name = "parameters" element = "ns:helloWorldResponse"/>
    </wsdl:message>
    <wsdl:portType name = "WSDemoPortType">
        <wsdl:operation name = "helloWorld">
            <wsdl:input message = "ns:helloWorldRequest" wsaw:Action = "urn:helloWorld"/>
            <wsdl:output message = "ns:helloWorldResponse" wsaw:Action = "urn:helloWorldResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name = "WSDemoSoap11Binding" type = "ns:WSDemoPortType">
        <soap:binding transport = "http://schemas.xmlsoap.org/soap/http" style = "document"/>
        <wsdl:operation name = "helloWorld">
            <soap:operation soapAction = "urn:helloWorld" style = "document"/>
            <wsdl:input>
                <soap:body use = "literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use = "literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name = "WSDemoSoap12Binding" type = "ns:WSDemoPortType">
        <soap12:binding transport = "http://schemas.xmlsoap.org/soap/http" style = "document"/>
        <wsdl:operation name = "helloWorld">
            <soap12:operation soapAction = "urn:helloWorld" style = "document"/>
            <wsdl:input>
                <soap12:body use = "literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use = "literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name = "WSDemoHttpBinding" type = "ns:WSDemoPortType">
        <http:binding verb = "POST"/>
        <wsdl:operation name = "helloWorld">
            <http:operation location = "helloWorld"/>
            <wsdl:input>
                <mime:content type = "application/xml" part = "parameters"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type = "application/xml" part = "parameters"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name = "WSDemo">
        <wsdl:port name = "WSDemoHttpSoap11Endpoint" binding = "ns:WSDemoSoap11Binding">
            <soap:address location = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpSoap11Endpoint/"/>
        </wsdl:port>
        <wsdl:port name = "WSDemoHttpSoap12Endpoint" binding = "ns:WSDemoSoap12Binding">
            <soap12:address location = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpSoap12Endpoint/"/>
        </wsdl:port>
        <wsdl:port name = "WSDemoHttpEndpoint" binding = "ns:WSDemoHttpBinding">
            <http:address location = "http://localhost:8080/WebServiceDemo/services/WSDemo.WSDemoHttpEndpoint/"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

 

Like us on Facebook