Tutorial: Defining a User Registration Web Service >
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:
- 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.
- 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.
- In the DocumentType field, type SyncCustomer.
- In the StartElement field, type Customer.
- 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.
- Right-click the TemplateDocument node and select Add Child > CommandMapping. This value of the TemplateDocument maps the business logic to the XML document.
- 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.
- 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.
- In the Field attribute of the Constant node, type URL. In the #PCDATA field, type noURL.
- Right-click the Command node and select Add Child > Constant.
- In the Field attribute of the Constant node, type viewTaskName. In the #PCDATA field, type ConfirmSyncCustomerSuccessBOD.
- Right-click the Command node and select Add Child > Constant.
- In the Field attribute of the Constant node, type errorViewName. In the #PCDATA field, type ConfirmSyncCustomerErrorBOD.
- 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.
- In the Name field of the TemplateTag node, type SyncCustomerMap.
- Expand the Tag node. For the XPath attribute, type DisplayName.
- Right-click the Tag node and select Add Attribute > Field. For the Field attribute, type displayName.
- Right-click the TemplateTag node and select Add Child > Tag.
- Expand the Tag node.For the XPath attribute, type Store.
- Right-click the Tag node and select Add Attribute > Field. For the Field attribute, type storeId.
- 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 - Right-click the last Tag node and select Add After > Comment.
- In the Comment field, type contact information.
- 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 - Right-click the last Tag node and select Add After > Comment.
- In the Comment field, type demographics.
- 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 - 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.