Tutorial: Defining a User Registration Web Service >

< Previous | Next >

 

Configure message mapping for a Web service request

This section describes how to enable 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. Note: In the Project Explorer view, you can dynamically link your WCDE_installdir/xml folder in Enterprise Applications > WC.To do this, right-click WC and select New > Other > Simple > Folder > Next > Advanced > Link to folder in the file system. Then click Browse and navigate to WCDE_installdir/xml. To use the Rational XML tools to update the message mapping:

  1. Open the webservice_SOABOD_template.xml file in the XML Editor. By default, the webservice_SOABOD_template.xml file is found in the WCDE_installdir/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. In the DocumentType field, type SyncCustomer.

  4. In the StartElement field, type Customer.

  5. In the TemplateTagName field, type SyncCustomerMap. 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 node. In the CommandName field, type com.ibm.commerce.usermanagement.commands.UserRegistrationAddCmd. 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 URL. In the #PCDATA field, type noURL.

  10. Right-click the Command node and select Add Child > Constant.

  11. In the Field attribute of the Constant node, type viewTaskName. In the #PCDATA field, type ConfirmSyncCustomerSuccessBOD.

  12. Right-click the Command node and select Add Child > Constant.

  13. In the Field attribute of the Constant node, type errorViewName. In the #PCDATA field, type ConfirmSyncCustomerErrorBOD.

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

  15. In the Name field of the TemplateTag node, type SyncCustomerMap.

  16. Expand the Tag node. For the XPath attribute, type DisplayName.

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

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

  19. Expand the Tag node.For the XPath attribute, type Store.

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

  21. Repeat steps 18-20 for the following XPATH and Field values:

    XPATH FIELD
    ParentOrganization parentMember
    ProfileType profileType
    PreferredCurrency preferredCurrency
    PreferredLanguage preferredLanguage
    Authentication/Logon logonId
    Authentication/Password logonPassword
    Authentication/PasswordVerify logonPasswordVerify
    Authentication/ChallengeQuestion challengeQuestion
    Authentication/ChallengeAnswer challengeAnswer

  22. Right-click the last Tag node and select Add After > Comment.

  23. In the Comment field, type contact information.

  24. Repeat steps 18-20 for the following XPATH and Field values:

    XPATH FIELD
    Contact/FirstName firstName
    Contact/LastName lastName
    Contact/PhoneNumber phone1
    Contact/FaxNumber fax1
    Contact/Email email1
    Contact/Address/StreetAddress address1
    Contact/Address/City city
    Contact/Address/State state
    Contact/Address/Country country
    Contact/Address/ZipCode zipCode

  25. Right-click the last Tag node and select Add After > Comment.

  26. In the Comment field, type demographics.

  27. Repeat steps 18-20 for the following XPATH and Field values:

    XPATH FIELD
    Demographics/Gender gender
    Demographics/Age age
    Demographics/Income income
    Demographics/IncomeCurrency incomeCurrency
    Demographics/MaritalStatus maritalStatus
    Demographics/Hobbies hobbies
    Demographics/AdditionalInformation demographicField5

  28. Save and close the file.

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

      <TemplateDocument>
            <DocumentType>SyncCustomer</DocumentType>
            <StartElement>Customer</StartElement>
            <TemplateTagName>SyncCustomerMap</TemplateTagName>
            <CommandMapping>
                  <Command CommandName="com.ibm.commerce.usermanagement.commands.UserRegistrationAddCmd">
                        <Constant Field="URL">noURL</Constant>
                        <Constant Field="viewTaskName">ConfirmSyncCustomerSuccessBOD</Constant>
                        <Constant Field="errorViewName">ConfirmSyncCustomerErrorBOD</Constant>
                  </Command>
            </CommandMapping>
      </TemplateDocument>
      <TemplateTag name="SyncCustomerMap">
            <Tag XPath="DisplayName" Field="displayName"/>
            <Tag XPath="Store" Field="storeId"/>
            <Tag XPath="ParentOrganization" Field="parentMember"/>
            <Tag XPath="ProfileType" Field="profileType"/>
            <Tag XPath="PreferredCurrency" Field="preferredCurrency"/>
            <Tag XPath="PreferredLanguage" Field="preferredLanguage"/>
            <Tag XPath="Authentication/Logon" Field="logonId"/>
            <Tag XPath="Authentication/Password" Field="logonPassword"/>
            <Tag XPath="Authentication/PasswordVerify" Field="logonPasswordVerify"/>
            <Tag XPath="Authentication/ChallengeQuestion" Field="challengeQuestion"/>
            <Tag XPath="Authentication/ChallengeAnswer" Field="challengeAnswer"/>
            <!--contact information -->
            <Tag XPath="Contact/FirstName" Field="firstName"/>
            <Tag XPath="Contact/LastName" Field="lastName"/>
            <Tag XPath="Contact/PhoneNumber" Field="phone1"/>
            <Tag XPath="Contact/FaxNumber" Field="fax1"/>
            <Tag XPath="Contact/Email" Field="email1"/>
            <Tag XPath="Contact/Address/StreetAddress" Field="address1"/>
            <Tag XPath="Contact/Address/City" Field="city"/>
            <Tag XPath="Contact/Address/State" Field="state"/>
            <Tag XPath="Contact/Address/Country" Field="country"/>
            <Tag XPath="Contact/Address/ZipCode" Field="zipCode"/>
            <!--demographics -->
            <Tag XPath="Demographics/Gender" Field="gender"/>
            <Tag XPath="Demographics/Age" Field="age"/>
            <Tag XPath="Demographics/Income" Field="income"/>
            <Tag XPath="Demographics/IncomeCurrency" Field="incomeCurrency"/>
            <Tag XPath="Demographics/MaritalStatus" Field="maritalStatus"/>
            <Tag XPath="Demographics/Hobbies" Field="hobbies"/>
            <Tag XPath="Demographics/AdditionalInformation" Field="demographicField5"/>
   </TemplateTag>
After completing this section, WebSphere Commerce should be configured to be able to accept the SyncCustomer Web service request and call the existing business logic to process the request.

< Previous | Next >