Tutorials > Web services > Define an inbound Web service

< Previous | Next >


Configure message mapping for the Web service request

This section describes the second part of enabling the WebSphere Commerce Web services framework to handle the WSDL document. Now that you have mapped the WSDL document to the WebSphere Commerce Web services framework, you are ready to configure message mapping to process a Web service request.

In the WebSphere Commerce development environment, the default XML configuration files are placed in the xml directory under the installation directory. IBM recommends that you use the Rational XML tools to update the message mapping template. You do this to configure the request operations and to determine how the rest of the XML document will be mapped as parameters that will be passed to the business logic.

Before creating the message mapping of the request to the business logic, refer to the WebSphere Commerce documentation on the message mapping template file to understand how an XML document will be mapped to the business logic ( TemplateTag element of a template definition file).

To use the Rational XML tools to update the message mapping:


Procedure

  1. Open the webservice_SOABOD_template.extension.xml file in the XML Editor. By default, the webservice_SOABOD_template.extension.xml file is found in the WC_EAR/xml/messaging folder.

  2. Right-click the ECTemplate node and select Add Child > TemplateDocument.

    This creates a Template Document node that is used to identify the request and configure this request to the appropriate business operation.

  3. A new TemplateDocument is added to the GetProductInformation XML document. Expand TemplateDocument.

  4. To the right of DocumentType and StartElement, type GetProductInformation.

  5. In the TemplateTagName value of the TemplateDocument, type GetProductInformationMap. This value refers to the TemplateTag node which will match the XPath expression of the XML request to the parameter that is passed to the business logic.

  6. Right-click the TemplateDocument node and select Add Child > CommandMapping. This value of the TemplateDocument maps the business logic to the XML document.

  7. Expand the CommandMapping > Command node. In the CommandName field, type ShowProductInformationView. This value represents the view that will be used to generate the response to the request.

  8. Right-click the Command node and select Add Child > Constant. This will create constants that will be passed to the business logic for processing. This also specifies runtime constants that will be used for processing the business logic.

  9. In the Field attribute of the Constant node, type ibm.wc.responseOnly to indicate that this is a read-only request and only a view will be called to process it. In the #PCDATA field, type true.

  10. Right-click the ECTemplate node and select Add Child > TemplateTag. This template tag contains the map between the XML document and the parameters that are passed to the business logic.

  11. In the Name field of the TemplateTag node, type GetProductInformationMap. This matches the TemplateDocument attribute that was created in step 5.

  12. Expand the Tag node. For the XPath attribute, type StoreIdentifier.

  13. Right-click the Tag node and select Add Attribute > Field. For the Field attribute, type storeId.

    After completing steps 11 and 12, we will have mapped the XPath expression of GetProductInformation/StoreIdentifier to the parameter name of storeId which will be passed to the business logic.

  14. Right-click the TemplateTag node and select Add Child > Tag.

  15. Expand the Tag node. For the XPath attribute, type ProductSKU .

  16. Right-click the Tag node and select Add Attribute > Field. For the Field attribute, type productSKU.

  17. Save the template mapping.

    After you have completed the preceding steps, you can verify the changes by clicking the Source tab and comparing the source code with the following:

    <ECTemplate>  
    <TemplateDocument>    
    <DocumentType>GetProductInformation</DocumentType>                       
       
    <StartElement>GetProductInformation</StartElement>                      
       
    <TemplateTagName>GetProductInformationMap</TemplateTagName>    
    <CommandMapping>      
    <Command CommandName="ShowProductInformationView">        
    <Constant Field="ibm.wc.responseOnly">true</Constant>      
    </Command>    
    </CommandMapping>  
    </TemplateDocument>                 
     
    <TemplateTag name="GetProductInformationMap">    
    <Tag XPath="StoreIdentifier" Field="storeId"/>    
    <Tag XPath="ProductSKU" Field="productSKU"/>  
    </TemplateTag>
    </ECTemplate>
    

  18. Open the WebSphere Commerce configuration file.

  19. Search on "<MessageMapper".

  20. Ensure the following element exists in the message mapping section:

    <MessageMapper 
      classname="com.ibm.commerce.messaging.programadapter.messagemapper.ecsax.ECSAXMessageMapper" 
      enable="true" messageMapperId="-4" name="WCS.SOABODINTEGRATION"> 
      
     
    <configuration DuplicateCreatesArray="true" 
        EcInboundMessageDtdFiles="" 
        EcInboundMessageDtdPath="messaging" 
        EcSystemTemplateFile="webservice_SOABOD_template.xml" 
        EcTemplatePath="messaging" 
        EcUserTemplateFile="webservice_SOABOD_template.extension.xml" 
        EmptyElementClearsData="true" 
        isValidating="false"/> 
    
    </MessageMapper>
    

< Previous | Next >


+

Search Tips   |   Advanced Search