Create WSDL using Eclipse

In this tutorial, we will learn to create a simple WSDL using Eclipse. This WSDL portrays that it will take two binary numbers in request and provide their summation in response.

Technologies used –
a. Eclipse IDE for Java EE developer 4.5.0.20150621-1200 (Mars)
b. Preinstalled Maven with Eclipse Mars

Steps:

  1. Right click on the folder where you want to create WSDL and go to New > Other > Web Services > WSDL File

SOAPWSDLCreate

 

2. Click on Next and give a name to the WSDL. Then click Next. Change the target namespace value to your desired value. Leave other options as it is.

Target Namespace Choice

3. Click on Finish.

WSDL Design View

4. Change the address location of the Service (i.e. BinaryAdditionService) and operation name (i.e. NewOperation) to your choice.

tnsOperationName Change

 

5.  Double click on the rightmost arrow across input. A new tab should appear beside WSDL design screen.

RequestMessage Screen

6. If you want, change the request message (i.e. binaryAdd) name.

WSDL Request Message Name change

7. Change the request message parameter name (i.e. in) in binaryAddType. Right  click on request message parameter and add a parameter above or below the current parameter. Additionally, you can also change the type of the input parameter(s).

Add parameters

8.  After modifying and adding parameters, save the changes.

WSDL Modified operation parameters

9 . In the above case, we added the type of “a” as string, which is a predefined type in schema. If you want to add custom type, you should right click on the parameter and select “Set Type” and click on “New …”.

WSDL Complex Type

10. Once you click ok and double click on “binaryAddRequestType”, you should see the newly created type separated. Right clicking on it will give you tons of different options to proceed further.

WSDL-CustomTypeElement

11. If you want to add more operations, go back to the WSDL design view and right click on the operation and click on “Add Operation” and repeat the above steps.

WSDL add more operations

 

12. If the directions are followed properly, a sample WSDL as below will be created.

 

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.javanbeyond.com/BinaryAdditionService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BinaryAdditionService" targetNamespace="http://www.javanbeyond.com/BinaryAdditionService/">
    <wsdl:types>
        <xsd:schema targetNamespace="http://www.javanbeyond.com/BinaryAdditionService/">
            <xsd:element name="binaryAddRequest">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="a" type="xsd:string"></xsd:element>
                        <xsd:element name="b" type="xsd:string"></xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="binaryAddResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="out" type="xsd:string"></xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="binaryAddRequest">
        <wsdl:part element="tns:binaryAddRequest" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="binaryAddResponse">
        <wsdl:part element="tns:binaryAddResponse" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:portType name="BinaryAdditionService">
        <wsdl:operation name="binaryAdd">
            <wsdl:input message="tns:binaryAddRequest"></wsdl:input>
            <wsdl:output message="tns:binaryAddResponse"></wsdl:output>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="BinaryAdditionServiceSOAP" type="tns:BinaryAdditionService">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
        <wsdl:operation name="binaryAdd">
            <soap:operation soapAction="http://www.javanbeyond.com/BinaryAdditionService/binaryAdd"></soap:operation>
            <wsdl:input>
                <soap:body use="literal"></soap:body>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"></soap:body>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="BinaryAdditionService">
        <wsdl:port binding="tns:BinaryAdditionServiceSOAP" name="BinaryAdditionServiceSOAP">
            <soap:address location="http://www.javanbeyond.com/"></soap:address>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

 

Leave a Reply

Back to Top
%d bloggers like this: