Tutorials > Web services > Define an inbound Web service
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
- 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.
- Right-click the MyCompany folder and select New > Other
- In the Select a wizard dialog box, select Web Services > WSDL and click Next.
- 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.
- In the Options dialog box, specify http://www.mycompany.com/ as Target namespace and myco as Prefix.
- Do not change the rest of the default values. Click Finish to create the WSDL file.
- To complete the Web service definition:
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.
- In the WSDL Editor, delete the default schema in the Types section by right-clicking the schema and selecting Delete.
- In the Services section, do the following:
- Expand the MyCompany-ProductServices service and select MyCompany-ProductServicesSOAP to view the port information.
- Rename the port from MyCompany-ProductServicesSOAP to ProductServices.
- Expand the port to reveal the soap:address information.
- 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.
- In the Bindings section, do the following:
- In the editor window, expand the ProductServices binding.
- Rename the NewOperation operation to GetProductInformation.
- Expand GetProductInformation.
- Select input in the editor and ensure the Name field is blank in the Properties window.
- Select output in the editor and ensure the Name field is blank in the Properties window.
- In the Port Types section, do the following:
- Rename the MyCompany-ProductServices port type to MyCompany-ProductServicesPortType.
- Expand MyCompany-ProductServicesPortType.
- Rename the NewOperation operation to GetProductInformation. This should link the operation found in the ProductServices binding with this operation.
- Expand GetProductInformation.
- In the editor, select input. Execute the following tasks in the Properties window:
- Ensure the Name field is blank.
- Click ... to the right of the Message field.
- 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.
- Select output in the editor window.
- Verify the Name field is blank.
- Click ... to the right of the Message field.
- 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.
- In the Bindings section, select ProductServices and change the port type to myco:MyCompany-ProductServicesPortType.
- In the Messages section, do the following:
- Remove the GetProductInformationRequest and GetProductInformationResponse messages by right-clicking on the messages and selecting Delete.
- Expand GetProductInformation and select the part.
- In the Properties window:
- In the Reference kind field, ensure that Element is selected.
- Click ... to the right of the Element field.
- Select Import Element from a file and click Browse.
- Select WebContent > xsd > MyCompany > ProductInformationServices.xsd and click OK.
- Select GetProductInformation from the list and click Finish.
- Expand ShowProductInformation and select the part.
- In the Properties window:
- In the Reference kind field, ensure that Element is selected.
- Click ... to the right of the Element field.
- Select Import Element from a file and click Browse.
- Select WebContent > xsd > MyCompany > ProductInformationServices.xsd and click OK.
- Select ShowProductInformation from the list and click Finish.
- Save the work and close the WSDL Editor.