Tutorial: Defining a User Registration Web Service >
Mapping a WSDL document to the WebSphere Commerce Web Services Framework
This section is related to mapping a WSDL document to the WebSphere Commerce Web Services Framework.
Enabling WebSphere Commerce to handle the Web Service Enabling the WebSphere Commerce Web Service framework to handle the WSDL defined previously involves two steps. The first step is configuring the WebSphere Commerce Web Services runtime to delegate the Web Service request to the WebSphere Commerce Web Services framework. The second step is configuring the WebSphere Commerce Web Services to process the request. This is done by using the message mapping facility to convert the XML request to a name-value-pair. The name-value-pair will be passed to the business logic and JSP to handle the response and configure the JSP that will be used to generate the web service response.
Mapping the WSDL to the WebSphere Commerce Web Services Framework The approach taken with WebSphere Web Services runtime is to map the WSDL to the WebSphere Commerce Web Services framework. The Web Services tooling can be used to create and update existing deployment files to generate this mapping. By using the wizard to generate a Java Bean Skeleton, you will have the required files to create the mapping and update the web services deployment descriptors to register the new WSDL. The following steps show how to perform the registration of the WSDL to the WebSphere Commerce Web Service framework.
- In the Project Explorer view, select WebServicesRouter > WebContent >wsdl > MyCompany > MyCompany-CustomerServices.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-CustomerServices.wsdl is specified and click Next.
- On the next page of the wizard, ensure that Service project is set to WebServiceRouter 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-CustomerServices.wsdl file.
To map the service to the WebSphere Commerce Web services framework:
- In the Project Explorer view, navigate to WebServicesRouter > WebContent > WEB-INF and open the MyCompany-CustomerServices_mapping.xml file.
- Search for the following line within the file: <service-endpoint-interface>com.mycompany.www.MyCompanyCustomerServicesPortType</service-endpoint-interface>
- Replace the service-endpoint-interface from com.mycompany.www.MyCompanyCustomerServicesPortType 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-CustomerServices_mapping.xml file and change the <java-method-name> value from syncCustomer to executeService. This will always be the method name to 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> ...- Save the changes to MyCompany-CustomerServices_mapping.xml and close the editor.
- In the Project Explorer view, double-click the WebContent/WEB-INF/webservices.xml file to open it in the Web Services Editor.
- In the Web Services panel...
- In the Web service descriptions section, select MyCompany-CustomerServices.
- In the Web service description implementation details section, change the WSDL file field to point to the MyCompany-CustomerServices.wsdl that you have originally created (wsdl/MyCompany/MyCompany-CustomerService.wsdl).
- In the Port Components panel...
- In the Web service description menu, select MyCompany-CustomerServices.
- Update the Service endpoint interface field with a value of com.ibm.commerce.webservices.OpenWebServicePortType to map the WSDL with the WebSphere Commerce Web Services framework.
- In the Port component implementation details section, under Service implementation bean, select OpenWebServiceBinding from the drop down menu 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).
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.
- Open the web.xml file.
- In the Servlets and JSPs panel, select the com_mycompany_www_CustomerServicesImpl servlet.
- Click the Remove button to remove the servlet.
- Save and close the editor.
At the end of this process, the WSDL should be mapped to the WebSphere Commerce Web Services framework for request handling. Within this process, the following is a list of new and change files that need to be updated when deploying the web services to an existing or new WebSphere Commerce instance.
- WEB-INF/ibm-webservices-bnd.xmi (updated)
- WEB-INF/ibm-webservices-ext.xmi (updated)
- WEB-INF/MyCompany-CustomerServices_mapping.xml (new)
- WEB-INF/webservices.xml (updated)
- wsdl/MyCompany/MyCompany-CustomerServices.wsdl (new)
- xsd/OAGIS/9.0/Overlays/MyCompany/BODs/SyncCustomerType.xsd (new)
- xsd/OAGIS/9.0/Overlays/MyCompany/Resources/Nouns/Customer.xsd (new)