Tutorials > Web services > Define an inbound Web service

< Previous | Next >


Create the WSDL document for a Web service

This section contains the recommended steps for creating a WSDL document to expose the XML schema as a Web service.


Procedure

  1. Under the WebContent/wsdl folder of the WebServicesRouter project, create a folder to contain the WSDL document. Right-click the wsdl folder and select New > Folder. In the Folder name field, type MyCompany, Click Finish.

  2. Right-click the MyCompany folder and select New > Other

  3. In the Select a wizard dialog box, select Web Services > WSDL and click Next.

  4. In the New WSDL File dialog box, ensure that the MyCompany folder is highlighted. In the File name field, type MyCompany-ProductServices.wsdl and click Next.

  5. In the Options dialog box, specify http://www.mycompany.com/ as Target namespace and myco as Prefix.

  6. Do not change the rest of the default values. Click Finish to create the WSDL file.

  7. To complete the Web service definition:

    1. In the WSDL Editor, delete the default schema in the Types section by right-clicking the schema and selecting Delete.

    2. In the Services section, do the following:

      1. Expand the MyCompany-ProductServices service and select MyCompany-ProductServicesSOAP to view the port information.

      2. Rename the port from MyCompany-ProductServicesSOAP to ProductServices.

      3. Expand the port to reveal the soap:address information.

      4. Select soap:address in the editor. In the Properties window, change the value of the location property to http://localhost/webapp/wcs/services/ProductServices. 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.

    3. In the Bindings section, do the following:

      1. In the editor window, expand the ProductServices binding.

      2. Rename the NewOperation operation to GetProductInformation.

      3. Expand GetProductInformation.

      4. Select input in the editor and ensure the Name field is blank in the Properties window.

      5. Select output in the editor and ensure the Name field is blank in the Properties window.

    4. In the Port Types section, do the following:

      1. Rename the MyCompany-ProductServices port type to MyCompany-ProductServicesPortType.

      2. Expand MyCompany-ProductServicesPortType.

      3. Rename the NewOperation operation to GetProductInformation. This should link the operation found in the ProductServices binding with this operation.

      4. Expand GetProductInformation.

      5. In the editor, select input. Execute the following tasks in the Properties window:

        1. Ensure the Name field is blank.

        2. Click ... to the right of the Message field.

        3. In the Specify Message dialog that opens, ensure that Create a new message is selected. In the Name of message field, type GetProductInformation. Click Finish.

      6. Select output in the editor window.

        1. Verify the Name field is blank.

        2. Click ... to the right of the Message field.

        3. In the Specify Message dialog that opens, ensure that Create a new message is selected. In the Name of message field, type ShowProductInformation. Click Finish.

    5. In the Bindings section, select ProductServices and change the port type to myco:MyCompany-ProductServicesPortType.

    6. In the Messages section, do the following:

      1. Remove the GetProductInformationRequest and GetProductInformationResponse messages by right-clicking on the messages and selecting Delete.

      2. Expand GetProductInformation and select the part.

      3. In the Properties window:

        1. In the Reference kind field, ensure that Element is selected.

        2. Click ... to the right of the Element field.

        3. Select Import Element from a file and click Browse.

        4. Select WebContent > xsd > MyCompany > ProductInformationServices.xsd and click OK.

        5. Select GetProductInformation from the list and click Finish.

      4. Expand ShowProductInformation and select the part.

      5. In the Properties window:

        1. In the Reference kind field, ensure that Element is selected.

        2. Click ... to the right of the Element field.

        3. Select Import Element from a file and click Browse.

        4. Select WebContent > xsd > MyCompany > ProductInformationServices.xsd and click OK.

        5. Select ShowProductInformation from the list and click Finish.

    7. Save the work and close the WSDL Editor.
    After you have completed this section, the WSDL Editor should display a Web service definition similar to the one in the screen capture. The arrows indicate how the different parts of the Web service definition are associated.You can verify that the WSDL document is correct by comparing the source code of the WSDL document with the source code of MyCompany-ProductServices.wsdl in the sample zip file.

< Previous | Next >


+

Search Tips   |   Advanced Search