Thursday, 26 January 2017

How to create a custom WSDL using XSD

Sometimes it is required to create a service interface(WSDL) from the schema(XSD) file.

This post shows you how to create interface- WSDL from the given XSD using Jdeveloper 12c.

Let's go step by step.

1) Suppose you have an Application and a project in the JDeveloper.

2) Right-click on the project and create a schema file


 3) Create the XSD structure like below


<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"
            targetNamespace="http://www.example.org" elementFormDefault="qualified">
  <xsd:element name="request">
    <xsd:annotation>
      <xsd:documentation>A sample element</xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="id" type="xsd:integer"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="response">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="name" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="fault">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="error" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

4) Let's create a WSDL document. Right-click on the project-> New -> WSDL Document


5) Arrange the schema and WSDL editor windows in a vertical split arrangement like as shown below. This can be achieved by dragging the test.xsd tab below


6) Let's create the WSDL document. Drag and Drop the request element from the XSD to the Port Types window. A popup will get open. Rename the Port Type Name as shown below


7) WSDL will look like


8) Here we can see, input and output refer to both request element. To correct this, select the output node from the Port Types window and drag and drop response element from the schema onto the output element


9) Add a fault node in the Port Types. To do so, first add the Message part, Drag and Drop the fault element from the schema on the Message window and rename Message name as EmpFault


10) Right-click on the output node, Insert After Output -> fault. 



11) Enter the name as EmpFault and select tns:EmpFault from the message dropdown


12) After the above steps, your WSDL document look like this


13) Now Drag and Drop EmpDemo node from Port Types window to Binding / Partner Links Type window and click OK

Your WSDL looks like this


14) Now drag and drop the EmpDempSOAP1Binding node to the Services Window. After this step WSDL document looks like this.


WSDL has been completed. Now validate the WSDL to see the WSDL we have created is valid or not. Right, Click on the test.wsdl and click Validate WSDL






You can use this WSDL to create the services.

5 comments:

  1. Thank you Ankur this post. But we can also create WSDL from XSD using WSDL builder very easily in 12c Jdeveloper. Regards Sanddy

    ReplyDelete
  2. Story of this blog is well written. The writer kept in consideration the grammar very well. Level of English also very well. Lot many new words has been used while writing content of this blog. cursus seo

    ReplyDelete