Tuesday, September 1, 2009

Creating a WSDL File From XSD File

In this post, lets learn how we can create services interface - WSDL from schema file using Oracle JDeveloper 11g. Here, we attempt to create a service which when provided with an Employee Id returns the Employee Name. Incase no matching records are found for an Id, it simply returns the string value - "Unknown".

# We start with opening the JDeveloper 11g

# Create an application - "MyWSDLApplication" using the Generic Application template.

# Name the project as "MyWSDLProject" and select "Web Services" as the project technologies.

# The Application Navigator view should look like this

# Lets create the schema file first. For this, right click on the project and from the context menu, select New. In the Gallery that opens, select General -> XML -> XML Schema

# Name the schema as Employee.xsd

# The schema editor window opens as shown in the figure below.

# We will be adding two elements - EmpId and EmpName here. Right click on the root schema element and from the context menu, select Insert inside schema -> element

# Once the two elements are specified, we provide them types by right click on the element and from context menu - select Set Type as shown below

# As depicted in the figure below, EmpId type is taken as long while EmpName type is string.

# With the schema defined, we move onto creating the WSDL document. Right click on the project and from context Menu, select New. In the gallery, choose Business Tier -> Web Services -> WSDL Document. Press OK button.
# Name WSDL document as EmployeeWSDL

# Once OK button is presses, the JDeveloper editor view would look like this

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

# Now, we begin creating the WSDL document. Drag and Drop the EmpId element (input for our case) onto the Port Type window. This opens the 'Create Port Type' window. Lets name it as EmployeeDetail.

# After our previous action, the WSDL editor should look like this

# We have a problem here as can be seen from the image. The output is shown as EmpId while we expect it to be EmpName.

# To correct this, we select the output node in the Port Types window. Drag and Drop EmpName element from the schema onto this node. With this, the WSDL document appears like

# Next we change the name of the messages to EmployeeRequestMessage and EmployeeResponseMessage using the property inspector window.
# With the changes in message name, we need to remap these to the operation messages as else these appear with errorneous icon like we have output icon below. To correct this, drag and drop the relevant messages onto the correct nodes. Example : EmployeeRequestMessage is dropped onto the input node of EmpIdOperation and EmployeeResponseMessage is dropped onto the output of EmpIdOperation

# Here, we make the operation name more meaningful using property Inspector - getEmployeeNameOperation.

# The complete WSDL view should appear like this

# Now, we drag and drop the EmployeeDetail node onto the Bindings/Partner Link Types window. In the Create Binding window, we check the SOAP12.

# This should result in the view as shown below :

# Next, drag and drop the root node from the Bindings window onto the Services window. This results in the view as shown below

# At this point, the structure window should look like this. This completes our WSDL document creation process.

# We can validate our WSDL document by doing right click on the EmployeeWSDL (in the Applications Navigator Window) and from context menu, choose Validate WSDL. Confirm the message in the Messages- Log window.

This completes our exercise to create WSDL document using the schema file. Next, we will create Web Service using this WSDL document.


  1. It is excellent. I came from a WPS ( websphere process server background ) and was looking for something like this as a beginner to understand how we can create WSDL in Oracle SOA suit.

  2. I am using Jdeveloper for the first time.It is really nice article.Thanks for uploading.

  3. Ya this article is very nice and usefull. can you upload the next article "create Web Service using this WSDL document".

  4. Hi This was very helpful for the beginners who comes to SOA and Web service development. Thanks a lot.

  5. Hi Thanks. It helps me a lot know how to create WSDL based on XSD. Waiting eagerly for next topic "create Web Service using this WSDL document".

  6. Hi, how can we create very very complex xsd in SOA like using import schemas, include schemas.

  7. Hi, how can we create very very complex xsd in SOA like using import schemas, include schemas.