Tutorials > Web services > Define an inbound Web service
Map the WSDL document to the WebSphere Commerce Web services framework
Enable the WebSphere Commerce Web services framework to handle the WSDL document involves two parts. The first part, described in this section, is to configure the WebSphere runtime environment to map the Web service request to the WebSphere Commerce Web services framework. The second part, described in Step 6, is to configure message mapping to process a Web service request.
Use the Web service tools to create and update existing deployment files to generate the mapping. The Web Service wizard creates the files required to create the mapping. The wizard also updates the Web services deployment descriptors to register the new WSDL document.
Ensure that Disable data binding and use SOAPElement has been selected as described in the setup steps in Configure WebSphere Commerce Developer for Web service development.
To create the files using the Web Service wizard:
Procedure
- In the Enterprise Explorer view, select WebServicesRouter > WebContent > wsdl > MyCompany > MyCompany-ProductServices.wsdl.
- Right click the WSDL file and select Web Services > Generate Java bean Skeleton.
- In the Web Service wizard, ensure that the Web service type is Skeleton Java bean Web Service. This should be the default value.
- Clear all the check boxes and click Next.
- In the Enter a URI to a WSDL, WSIL or HTML document field, ensure /WebServicesRouter/WebContent/wsdl/MyCompany/MyCompany-ProductServices.wsdl is specified and click Next.
- On the next page of the wizard, ensure that Service project is set to WebServicesRouter and EAR project to WC.
- Click Finish. You will see a warning about overwriting of files. Select Yes to All to avoid being prompted for each file.
If the WebSphere Commerce service test environment has not been started during this process, it will now be started.
- Optional: At the end of this process, some files are created by the tooling but are not required by the Web service. The following can be removed:
- The WebContent/wsdl/com directory.
- The WebContent/WEB-INF/wsdl/MyCompany-ProductServices.wsdl file.
- To map the service to the WebSphere Commerce Web services framework:
- In the Enterprise Explorer view, navigate to WebServicesRouter > WebContent > WEB-INF and open the MyCompany-ProductServices_mapping.xml file.
- Search for the following line within the file:
<service-endpoint-interface>com.mycompany.www.MyCompanyProductServicesPortType</service-endpoint-interface>
- Replace the service-endpoint-interface from com.mycompany.www.MyCompanyProductServicesPortType to com.ibm.commerce.webservices.OpenWebServicePortType. This will always be the service endpoint interface of any service that is handled by the WebSphere Commerce Web Services framework.
- Update the MyCompany-ProductServices_mapping.xml file and change the <java-method-name> value from getProductInformation to executeService. This will always be the method name of any service that is handled by the WebSphere Commerce Web Services framework.
The following shows the changes from step 3 and 4 in bold:
...
<service-endpoint-interface-mapping> <service-endpoint-interface> com.ibm.commerce.webservices.OpenWebServicePortType</service-endpoint-interface> <wsdl-port-type xmlns:seimwpt="http://www.mycompany.com/schema">seimwpt:MyCompany-ProductServicesPortType</wsdl-port-type> <wsdl-binding xmlns:seimwb="http://www.mycompany.com/schema">seimwb:ProductServices</wsdl-binding> <service-endpoint-method-mapping> <java-method-name> executeService</java-method-name> <wsdl-operation>GetProductInformation</wsdl-operation> ...
- Search for the following line within the file:
<java-port-name>ProductServices</java-port-name>
- Change the <java-port-name> value from ProductServices to com.ibm.commerce.webservices.OpenWebServicePortType.
- Save the changes to MyCompany-ProductServices_mapping.xml and close the editor.
- In the Enterprise Explorer view, double-click the WebContent/WEB-INF/webservices.xml file to open it in the Web Services Editor.
- In the Web Services panel, do the following:
- In the Web service descriptions section, select MyCompany-ProductServices.
- In the Web service description implementation details section, change the WSDL file field to point to the MyCompany-ProductServices.wsdl that you have created in wsdl/MyCompany/.
- In the Port Components panel, do the following:
- In the Web service description drop down list, select MyCompany-ProductServices.
- Update the Service endpoint interface with a value of com.ibm.commerce.webservices.OpenWebServicePortType to map the WSDL file to the WebSphere Commerce Web services framework.
- In the Port component implementation details section, under Service implementation bean, select OpenWebServiceBinding from the list and select the Servlet link radio button .
- Go to the Handlers tab.
- Select the Web service description and Port Component you just updated.
- Select the Add button to add a new handler. A window will open in which you can specify the class name of the handler.
- Find the class com.ibm.commerce.webservices.OpenWebServiceHandlerImpl and click OK.
- Under SOAP headers of the selected handler add the two following Namespace URIs. For each, set the Local part to "Security"
- http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
- http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-secext-1.0.xsd
- Under SOAP roles, click Add. This will create a role with the default value of "SOAP role". Change the value to " " (one space). Note: If the value is empty, the tooling will remove the SOAP role. Setting to a value of an empty space is the same as allowing a services that does not specify a SOAP actor to use this handler.
- Save the file and close the Web Services Editor.
There is an unneeded servlet created in the web.xml for the WebServicesRouter web module.
At the end of this process, the WSDL file should be mapped to the WebSphere Commerce Web services framework for request handling. The following new and changed files need to be updated when deploying the Web services to an existing or new WebSphere Commerce instance.
- Open the web.xml file.
- In the Servlets and JSPs panel, select the com_mycompany_www_ProductServicesImpl servlet.
- Click the Remove button to remove the servlet.
- WEB-INF/ibm-webservices-bnd.xmi (updated)
- WEB-INF/ibm-webservices-ext.xmi (updated)
- WEB-INF/MyCompany-ProductServices_mapping.xml (new)
- WEB-INF/webservices.xml (updated)
- wsdl/MyCompany/MyCompany-ProductServices.wsdl (new)
- xsd/MyCompany/ProductInformationService.xsd (new)