Configuring message mapping to process a Web service request

In this lesson, you are enabling the WebSphere Commerce Web services framework to handle your Web Service Description Language (WSDL) document. To enable your Web services framework you must configure message mapping to process a Web service request.

About this task

In the WebSphere Commerce development environment, the default XML configuration files are placed in the xml directory under the installation directory. It is recommended that you use the Rational XML tools to update the message mapping template. You update the template to configure the request operations and determine how the XML document maps as parameters that pass to the business logic.

Procedure

  1. Open the webservice_SOABOD_template.extension.xml file to configure the message mapping settings:
    1. In the Enterprise Explorer view, navigate to WC > xml > messaging.
    2. Right-click the webservice_SOABOD_template.extension.xml file; select Open With XML Editor. The XML editor displays.
  2. Create a template document for the webservice_SOABOD_template.extension.xml file:
    1. In the XML Editor, click the Design tab.
    2. Right-click the ECTemplate node; select Add Child > TemplateDocument. A template document node is created. This node identifies the request and configures this request to the appropriate business operation.
    3. Expand the TemplateDocument node.
    4. In the DocumentType field, enter the value SyncCustomer for the type.
    5. In the StartElement field, enter the value Customer for the element.
    6. In the TemplateTagName field, enter the value SyncCustomerMap for the name. The name refers to the TemplateTag node that matches the XPath expression of the XML request to the parameter that passes to the business logic.
    7. Right-click the TemplateDocument node; select Add Child > CommandMapping. The command mapping maps the business logic to the XML document.
    8. Expand the CommmandMapping/Command nodes.
    9. In the CommandName field, enter the value com.ibm.commerce.usermanagement.commands.UserRegistrationAddCmd for the name. The name represents the view that generates the response to the request.
    10. Right-click the Command node; select Add Child > Constant. Constants are passed to the business logic for processing and are used as runtime constants for processing the business logic.
    11. Expand the Constant node.
    12. In the Field field, enter URL for the field value.
    13. In the #PCDATA field, enter noURL for the field value. The #PCDATA field is denoted by the icon
    14. Repeat Steps 2.j to 2.m to create the following constants:
      Field #PCDATA
      viewTaskName ConfirmSyncCustomerSuccessBOD
      errorViewName ConfirmSyncCustomerErrorBOD
  3. Create the template tags for the webservice_SOABOD_template.extension.xml file:
    1. Right-click the ECTemplate node; select Add Child > TemplateTag. This template tag contains the map between the XML document and the parameters that are passed to the business logic.
    2. Expand the TemplateTag node.
    3. In the Name field, enter the value SyncCustomerMap for the name.
    4. Right-click the TemplateTag node; select Add Child > Tag.
    5. Expand the Tag node.
    6. In the XPath field, enter the value DisplayName for the attribute.
    7. Right-click the Tag node; select Add Attribute > Field.
    8. In the Field field, enter the value displayName for the attribute
    9. Repeat steps 3.d - 3.h to create the following tags:
      XPATH FIELD
      Store storeId
      ParentOrganization parentMember
      ProfileType profileType
      PreferredCurrency preferredCurrency
      PreferredLanguage preferredLanguage
      Authentication/Logon logonId
      Authentication/Password logonPassword
      Authentication/PasswordVerify logonPasswordVerify
      Authentication/ChallengeQuestion challengeQuestion
      Authentication/ChallengeAnswer challengeAnswer
    10. Right-click the last Tag node; select Add After > Comment.
    11. In the Comment field, enter the value Contact Information.
    12. Repeat steps 3.d - 3.h to create the following tags for contact information:
      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
    13. Right-click the last Tag node; select Add After > Comment.
    14. In the Comment field, enter the value Demographics.
    15. Repeat steps 3.d - 3.h to create the following tags for demographics information:
      XPATH FIELD
      Demographics/Gender gender
      Demographics/Age age
      Demographics/Income income
      Demographics/IncomeCurrency incomeCurrency
      Demographics/MaritalStatus maritalStatus
      Demographics/Hobbies hobbies
      Demographics/AdditionalInformation demographicField5
    16. Save your changes.

Results

After you complete the preceding steps, you can verify your changes by clicking the Source tab and search for the following code:
<TemplateDocument>
		<DocumentType>SyncCustomer</DocumentType>
Compare your source code with the following code snippets to ensure that your message mapping is configured:
<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>
		<Tag XPath="Authentication/Password" Field="logonPassword" />
		<Tag XPath="Authentication/PasswordVerify" Field="logonPasswordVerify" />
		<Tag XPath="Authentication/ChallengeQuestion" Field="challengeQuestion" />
		<Tag XPath="Authentication/ChallengeAnswer" Field="challengeAnswer" ></Tag>
		<!--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>
		<Tag XPath="Contact/Email" Field="email1" ></Tag>
		<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>
		<Tag XPath="Demographics/Hobbies" Field="hobbies" />
		<Tag XPath="Demographics/AdditionalInformation" Field="demographicField5" />
	</TemplateTag>

You have configured WebSphere Commerce to accept the SyncCustomer Web service request and call the existing business logic to process the request.