Defining the Web Service Description Language (WSDL)

In this lesson, you learn how to expose an XML schema as a Web service. To expose the XML schemas you created in the previous two lessons, you must define the WSDL for the Web service. By defining the WSDL you are defining the functionality of the service, how to call the service, what parameters it expects, and what data structures it returns.

About this task

WSDL is an XML-based specification for describing networked services as a set of endpoints that operate on messages that contain either document-oriented or procedure-oriented information. In this lesson, you are defining the messages and endpoints for the Web service. The Web service you define in this lesson creates customer information and is represented by the SyncCustomer message. This Web service responds with an OAGIS ConfirmBOD that contains an acknowledgement that a customer was created.

Procedure

  1. Create the directory to contain the WSDL document.
    1. In the Enterprise Explorer view, navigate to WebServiceRouter/WebContent/wsdl
    2. Right-click the wsdl directory; select New > Folder.
    3. In the Folder name field, enter MyCompany: Click Finish.
  2. Create a WSDL file:
    1. Right-click the MyCompany directory; select New > Other.
    2. In the Select a wizard dialog, navigate to Web Services/WSDL; select WSDL. Click Next.
    3. In the New WSDL File dialog, select the MyCompany folder.
    4. In the File name field, enter MyCompany-CustomerServices.wsdl; click Next.
    5. In the Options dialog, for the Target namespace field, enter http://www.mycompany.com/.
    6. In the Prefix field, enter myco.
    7. Do not change the other default values. Click Finish to create the WSDL file. The WSDL editor opens.
  3. Delete the default schema before defining the WSDL file contents:
    1. Select Window > Show View > Outline to open the Outline view.
    2. In the WSDL editor, select the Outline tab.
    3. Expand the Types folder.
    4. Right-click the default http://www.mycompany.com/ schema; click Delete.
  4. Edit the port settings for the WSDL file:
    1. Click the Design tab.
    2. In the drop-down menu for the View: options select Advanced.
    3. In the outline, expand Services/MyCompany-CustomerServices/; select MyCompany-CustomerServicesSOAP
    4. Click the Properties tab.
    5. For the port name, rename the port CustomerServices.
    6. For the port address, change the address to http://localhost/webapp/wcs/services/CustomerServices. This URL is used to access the services defined by this WSDL document. The name of the binding in step 2b defines this URL which connects to the Web service.
  5. Edit the bindings settings for the WSDL file:
    1. In the outline, expand Bindings/MyCompany-CustomerServicesSOAP; select NewOperation. Click the Properties tab.
    2. Change the value of the Name field from NewOperation to SyncCustomer.
  6. Edit the Port Type settings for the WSDL file:
    1. In the outline, expand Port Type; select MyCompany-CustomerServices.
    2. Click the Properties tab.
    3. For the Port Type name, rename the Port Type MyCompany-CustomerServicesPortType
    4. Select input in the editor window. In the Name field, type SyncCustomer.
    5. For the message, select New...; enter SyncCustomer. Click OK.
    6. Select output in the editor window. In the Name field, type ConfirmBOD.
    7. For the message, select New...; enter ConfirmBOD. Click OK.
  7. Edit the Messages settings for the WSDL file:
    1. In the outline expand Messages; delete NewOperationResponse and NewOperationRequest by right-clicking and selecting Delete.
    2. Expand Messages/ConfirmBOD; select NewPart.
    3. Click the Properties tab.
    4. Rename the part ConfirmBOD
    5. Ensure that Element is selected in the Reference kind field.
    6. For the Type, select Browse... in the set element reference dialog select the Workspace radio button.
    7. Select ConfirmBOD - http://www.openapplications.org/oagis/9; ensure that the Declaration Location for this reference is /WebServicesRouter/WebContent/xsd/OAGIS/9.0/BODs/Developer/ConfirmBOD/xsd
      Screen capture of set element reference for ConfirmBOD
    8. Click OK.
    9. Expand Messages/SyncCustomer; select NewPart.
    10. Click the Properties tab.
    11. Rename the part SyncCustomer
    12. Ensure that Element is selected in the Reference kind field.
    13. For the Type, select Browse... in the set element reference dialog select the Current Resource radio button.
    14. Select SyncCustomer - http://www.mycompany/schema; ensure that the Declaration Location for this reference is /WebServicesRouter/WebContent/xsd/OAGIS/9.0/Overlays/MyCompany/BODs/SyncCustomer.xsd
      Screen capture of set element reference for SyncCustomer
    15. Click OK.
  8. Save your work and close the WSDL Editor.

    After the preceding steps are complete, the WSDL Editor shows a Web Service definition similar to the one found in the following screen capture. Note the arrows which indicate how the differ parts of the Web Service definition are associated.

    This screen capture shows the WSDL sections after completing this section of the tutorial