XML over HTTP
HCL Commerce can receive inbound XML messages over HTTP using the Program Adapter.
The following steps illustrate the overall flow of an XML over HTTP request:
- An external system sends an XML message to HCL Commerce over HTTP via a POST request. For example, http://host_name/webapp/wcs/stores/servlet/.
- The request is mapped to the Program Adapter.
- The Program Adapter passes the XML request to the appropriate message mapper.
- The message mapper converts the XML request into a CommandProperty object and passes it back to the Program Adapter.
- The Program Adapter prepares the command for execution and passes it to the WebController for execution.
- The Program Adapter generates the proper XML response and returns the XML response to the external system that made the request.
When the Program Adapter receives the XML request, it must verify the credentials of the external system that sent the request. Not all XML requests can be processed. Even if the XML request can be mapped to an HCL Commerce command, there must be some verification to ensure that the request should be processed.
Note:
To support the XML/HTTP adapter under the Struts 2.0 implementation, update the
Stores.WAR\WEB-INF\web.xml configuration file by changing
filter-class from
"org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter"
to "com.ibm.commerce.struts.v2.ECActionStrutsServletFilter"
. For
example, change<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,struts-stores.xml</param-value>
</init-param>
<init-param>
<param-name>ServletName</param-name>
<param-value>Stores</param-value>
</init-param>
</filter>
to<filter>
<filter-name>struts2</filter-name>
<filter-class>com.ibm.commerce.struts.v2.ECActionStrutsServletFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,struts-stores.xml</param-value>
</init-param>
<init-param>
<param-name>ServletName</param-name>
<param-value>Stores</param-value>
</init-param>
</filter>
Note:
For HCL Commerce version 9.0.1.19 and greater, do
the following to support the XML/HTTP adapter under the Struts 2.0
implementation:
- Update the Stores.WAR\WEB-INF\web.xml configuration
file by removing the filter section, so that the file is similar to the
following code snippet:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name> Stores</display-name> <servlet> <description/> <display-name>Stores Request Servlet</display-name> <icon> <small-icon/> <large-icon/> </icon> <servlet-name>Stores Request Servlet</servlet-name> <servlet-class>com.ibm.commerce.struts.v2.ECActionStrutsServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,struts-stores.xml</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>validate</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>configFactory</param-name> <param-value>com.ibm.commerce.struts.config.UpdatableModuleConfigFactory</param-value> </init-param> <init-param> <param-name>webpath</param-name> <param-value>/webapp/wcs/stores</param-value> </init-param> <init-param> <param-name>isStoreServlet</param-name> <param-value>true</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Stores Request Servlet</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> <servlet> <description/> <display-name>CompositionRequestServlet</display-name> <icon> <small-icon/> <large-icon/> </icon> <servlet-name>CompositionRequestServlet</servlet-name> <servlet-class>com.ibm.commerce.messaging.composer.servlet.CompositionRequestServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CompositionRequestServlet</servlet-name> <url-pattern>/IBM.WC.Compose/*</url-pattern> </servlet-mapping> <servlet> <servlet-name>StoreImageServlet</servlet-name> <servlet-class>com.ibm.commerce.catalog.facade.client.StoreImageServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>StoreImageServlet</servlet-name> <url-pattern>/StoreImageServlet/*</url-pattern> </servlet-mapping> <filter> <icon/> <filter-name>RuntimeServletFilter</filter-name> <filter-class>com.ibm.commerce.webcontroller.RuntimeServletFilter</filter-class> <init-param> <param-name>ServletName</param-name> <param-value>Stores</param-value> </init-param> </filter> <filter-mapping> <filter-name>RuntimeServletFilter</filter-name> <servlet-name>Stores Request Servlet</servlet-name> </filter-mapping> <filter> <icon/> <filter-name>CacheFilter</filter-name> <filter-class>com.ibm.commerce.dynacache.filter.CacheFilter</filter-class> <init-param> <param-name>ServletName</param-name> <param-value>StoresRequestServlet</param-value> </init-param> </filter> <filter-mapping> <filter-name>CacheFilter</filter-name> <servlet-name>Stores Request Servlet</servlet-name> </filter-mapping> <filter> <filter-name>HttpSecurityFilter</filter-name> <filter-class>com.ibm.commerce.foundation.server.services.servlet.filter.HttpSecurityFilter</filter-class> </filter> <filter-mapping> <filter-name>HttpSecurityFilter</filter-name> <servlet-name>Stores Request Servlet</servlet-name> </filter-mapping> <filter> <icon/> <filter-name>CompositionFilter</filter-name> <filter-class>com.ibm.commerce.messaging.composer.servlet.CompositionFilter</filter-class> </filter> <filter-mapping> <filter-name>CompositionFilter</filter-name> <servlet-name>CompositionRequestServlet</servlet-name> </filter-mapping> <filter> <icon/> <filter-name>JspExecutionServiceLoggingFilter</filter-name> <filter-class>com.ibm.commerce.webcontroller.JspExecutionServiceLoggingFilter</filter-class> <init-param> <param-name>ServletName</param-name> <param-value>JspExecutionServiceLoggingFilter</param-value> </init-param> </filter> <filter-mapping> <filter-name>JspExecutionServiceLoggingFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping> <ejb-local-ref> <ejb-ref-name>ejb/BusinessContextServiceWrapperLocal</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.ibm.commerce.component.contextservice.objects.BusinessContextServiceWrapperLocalHome</local-home> <local>com.ibm.commerce.component.contextservice.objects.BusinessContextServiceWrapperLocal</local> <ejb-link>Enablement-BusinessContextEngineInterface.jar#BusinessContextServiceWrapper</ejb-link> </ejb-local-ref> <ejb-local-ref> <ejb-ref-name>ejb/MemberGroupMemberService</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>com.ibm.commerce.user.objects.service.MemberGroupMemberServiceLocalHome</local-home> <local>com.ibm.commerce.user.objects.service.MemberGroupMemberServiceLocal</local> <ejb-link>Member-MemberManagementData.jar#MemberGroupMemberService</ejb-link> </ejb-local-ref> <ejb-local-ref> <ejb-ref-name>ejb/ContextManagement</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>com.ibm.commerce.context.objects.ContextManagementLocalHome</local-home> <local>com.ibm.commerce.context.objects.ContextManagementLocal</local> <ejb-link>Enablement-BusinessContextEngineData.jar#ContextManagement</ejb-link> </ejb-local-ref> <ejb-local-ref> <ejb-ref-name>ejb/ContextData</ejb-ref-name> <ejb-ref-type>Entity</ejb-ref-type> <local-home>com.ibm.commerce.context.objects.ContextDataLocalHome</local-home> <local>com.ibm.commerce.context.objects.ContextDataLocal</local> <ejb-link>Enablement-BusinessContextEngineData.jar#ContextData</ejb-link> </ejb-local-ref> <jsp-config> <taglib> <taglib-uri>flow.tld</taglib-uri> <taglib-location>/WEB-INF/flow.tld</taglib-location> </taglib> </jsp-config> <listener> <listener-class>com.ibm.commerce.struts.v2.StrutsConfigFilesServletContextListener</listener-class> </listener> <context-param> <param-name>component-plugin-file</param-name> <param-value>ComponentPlugins.xml</param-value> </context-param> <context-param> <param-name>initServlet</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>isStruts2</param-name> <param-value>true</param-value> </context-param> </web-app>
- Make sure you have the file Enablement-Struts2Logic/src/com/ibm/commerce/struts/v2/dispatcher/mapper/ECActionMapper.java class in the latest Enablement-Struts2Logic.jar
- Add the following code lines in the top section of the file
Stores/src/struts-stores.xml.
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="ecActionMapper" class="com.ibm.commerce.struts.v2.dispatcher.mapper.ECActionMapper" /> <constant name="struts.mapper.class" value="ecActionMapper" />