Tutorials > Web services > Define a User Registration Web Service

< Previous | Next >


Map 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.


Enable WebSphere Commerce to handle the Web Service

Enable 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.


Map 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, we will have the required files to create the mapping and update the web services deployment descriptors to register the new WSDL.


Procedure

  1. In the Enterprise Explorer view, select WebServicesRouter > WebContent > wsdl > MyCompany > MyCompany-CustomerServices.wsdl.

  2. Right click the WSDL file and select Web Services > Generate Java bean Skeleton.

  3. In the Web Service wizard, ensure that the Web service type is Skeleton Java bean Web Service. This should be the default value.

  4. Clear all the check boxes and click Next.

  5. 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.

  6. On the next page of the wizard, ensure that Service project is set to WebServiceRouter and EAR project to WC.

  7. 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.

  8. 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.

  9. To map the service to the WebSphere Commerce Web services framework:

    1. In the Enterprise Explorer view, navigate to WebServicesRouter > WebContent > WEB-INF and open the MyCompany-CustomerServices_mapping.xml file.

    2. Search for the following line within the file:

      <service-endpoint-interface>com.mycompany.www.MyCompanyCustomerServicesPortType</service-endpoint-interface> 
      

    3. 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.

    4. 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> ...
      

    5. Save the changes to MyCompany-CustomerServices_mapping.xml and close the editor.

    6. In the Enterprise Explorer view, double-click the WebContent/WEB-INF/webservices.xml file to open it in the Web Services Editor.

    7. In the Web Services panel, do the following:

      1. In the Web service descriptions section, select MyCompany-CustomerServices.

      2. 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).

    8. In the Port Components panel, do the following:

      1. In the Web service description menu, select MyCompany-CustomerServices.

      2. 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.

      3. 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.

    9. Go to the Handlers tab.

    10. Select the Web service description and Port Component you just updated.

    11. Select the Add button to add a new handler. A window will open in which you can specify the class name of the handler.

    12. Find the class com.ibm.commerce.webservices.OpenWebServiceHandlerImpl and click OK.

    13. 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

    14. 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.

    15. Save the file and close the Web Services Editor.

    There is an unneeded servlet created in the web.xml for the WebServicesRouter web module.

    1. Open the web.xml file.

    2. In the Servlets and JSPs panel, select the com_mycompany_www_CustomerServicesImpl servlet.

    3. Click the Remove button to remove the servlet.

    4. 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 WCS 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)

< Previous | Next >


+

Search Tips   |   Advanced Search