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
# As depicted in the figure below, EmpId type is taken as long while EmpName type is string.
# Once OK button is presses, the JDeveloper editor view would look like this
# 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.
# Next we change the name of the messages to EmployeeRequestMessage and EmployeeResponseMessage using the property inspector window.
# Now, we drag and drop the EmployeeDetail node onto the Bindings/Partner Link Types window. In the Create Binding window, we check the SOAP12.
# 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.
# 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.
# Now, we drag and drop the EmployeeDetail node onto the Bindings/Partner Link Types window. In the Create Binding window, we check the SOAP12.
# 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.
No comments:
Post a Comment