Friday, March 18, 2011

WebSphere Commerce V561 WebService configuration

Enabling WebSphere Commerce as a service provider in WCS Developer

These steps are created base on information from WCS info center, but added with details needed.

1. Configure the program adapter.

At configuration file, <toolkit>/conf/config/config.xml, search HttpAdapter, where its deviceFormatType=”XmlHttp”, set enabled=”true”.

Also, at its supportedContentTypes attribute, it defines the request content-type that it treats as xmlHttp request. You may need modify/add the content-type needed.

One example, I found one of the SOAP request simulator sends out the request with content-type “text/xml;charset=utf-8”. There is no space between xml and charset. The WCS does not recognize this. Use the monitor tool to check the request header to make sure the content-type can be handled by WCS.

If the web service is SOAP based, the message mapper WCS.SOAPINTEGRATION will be used. Otherwise, it can be treated as xml over http (or RESTful web service) and the WCS.INTEGRATION message mapper will be used. This difference will lead to difference configuration. I will use SOAP and XML over HTTP to describe them respectfully.

2. See details of Program Adapter and Message mappers in infocenter.

http://publib.boulder.ibm.com/infocenter/wchelp/v5r6m1/index.jsp?topic=/com.ibm.commerce.integration.doc/tasks/tcvhttpcn.htm

3. Create the Controller command to implement your business logic.

4. Create a new URL for this command.

5. Define XSD, WSDL definition for the web service. (for the SOAP type web service)

Follow WCS6 info center tutorial to create XSD and WSDL,

http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.webservices.doc/concepts/cwvtutorials.htm

http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.webservices.doc/tutorial/twvinboundws3.htm

6. Map the incoming SOAP request to the command parameters by using the mapping template file.

Open xml/messaging/webservice_template.xml, if it does not exist. Copy from samples/webservices/xml/webservice_template.xml.

Sample:

<TemplateDocument>

<DocumentType version='1.0'>OrderCalculateRequest</DocumentType> -- donot include the name space prefix, but need version <StartElement>OrderCalculateRequest</StartElement> --match the root element in WSDL, same as above

<TemplateTagName>BatchorderCalculate10Map</TemplateTagName> --match the name of TemplateTag, below

<CommandMapping>

<Command CommandName='OrderCalculateWebService'> -- controller command to execute

<Constant Field='protocolName'>SOAP</Constant>

<Constant Field='protocolVersion'>1.1</Constant>

</Command>

</CommandMapping>

</TemplateDocument>

<TemplateTag name='BatchorderCalculate10Map'>

<Tag XPath='ControlArea/Credentials/logonId' Field='logonId' FieldInfo='CONTROL' /> -- CONTROL field will allow the framework to auto logon

<Tag XPath='ControlArea/Credentials/password' Field='logonPassword' FieldInfo='CONTROL' />

<Tag XPath='DataArea/orderId' Field='orderId' />

<Tag XPath='DataArea/address@addressType' XPathType='ATTRIBUTE' />

<Tag XPath='DataArea/address [@addressType="B"]' XPathType='VECTOR' Field='billingAddress' />

<Tag XPath='DataArea/address [@addressType="B"]@addressType' XPathType='EMPTY' />

<Tag XPath='DataArea/address [@addressType="B"]/firstName' Field='firstName' />

<Tag XPath='DataArea/address [@addressType="B"]/lastName' Field='lastName' />

<Tag XPath='DataArea/address [@addressType="B"]/address1' Field='address1' />

----

7. Create the response JSP file.

Use SoapUI tool (free download) to create the Soap project with wsdl file, create mock service.

Use the content created from mockService as template, create the jsp.

8. Test on the server.

9. Debugging: turn on the trace WC_TRANSPORT / WC_SERVER, to verify the result.

1 comment:

  1. thanks for this article, it is very helpful.
    Do you have similiar steps for version 7 as well?

    ReplyDelete