Sunday, November 17, 2013

Configuring inbound messages


When I am new to WC environment. My first challenging task was to provide inbound message to our SAP team.
Given the fact that i am not new to integration, I know exactly what has to be done in typical J2EE environment but not in WC environment.

In typical J2EE environment, First i will design what should be the XML format, Then configuration MQ and many more based on the requirement. But in WC XML format is available for most of the requirements.

WC provide XML format for following functionalities.
  1. Create/Update Customer
  2. Update order status
  3. Update product inventory
  4. Create pick batch
  5. Inquire PickpackList details
  6. Inventory Reciept
  7. Expected inventory record
  8. Shipment confirmation
  9. Price and availability
  10. Shopping cart transfer
  11. Batch availability

All the files has to adhere to the definitions given by WC. To know in details

wc-server.xml:

In wc-server.xml search for "Messaging" you will see

<Messaging
            EcInboundMessageDtdFiles="NCCommon.mod, NCCustomer_10.mod, Create_NC_Customer_10.dtd, Update_NC_Customer_10.dtd, Update_NC_OrderStatus_10.dtd, Update_NC_ProductInventory_10.dtd, Update_NC_ProductPrice_10.dtd, Create_WCS_Customer_20.dtd, Create_WCS_Customer_30.dtd, Update_WCS_Customer_20.dtd, Update_WCS_Customer_30.dtd, Update_WCS_OrderStatus_20.dtd, Update_WCS_ProductPrice_20.dtd, Inquire_WCS_PickPackListDetail_10.dtd, Create_WCS_PickBatch_10.dtd, Create_WCS_ExpectedInventoryRecord_10.dtd, Create_WCS_InventoryReceipt_10.dtd, Update_WCS_InventoryReceipt_10.dtd, Create_WCS_ShipmentConfirmation_10.dtd, Create_WCS_ShipmentConfirmation_20.dtd, Update_WCS_ProductInventory_20.dtd, Request_WCS_BE_ProductInventory_10.dtd, Update_WCS_OrderStatus_30.dtd, Update_WCS_PriceAndAvailability_10.dtd, Update_WCS_ShoppingCartTransfer_10.dtd, Update_WCS_BatchAvailability_10.dtd"
            EcInboundMessageDtdPath="messaging"
            EcMimePropFile="lang_mime.data"
            EcSystemTemplateFile="sys_template.xml"
            EcTemplatePath="messaging"
            EcUserTemplateFile="user_template.xml" XMLWebControllerUserId="wcsadmin"/>
 EcInboundMessageDtdFiles gives information on what all definitions are available in WC.
 EcInboundMessageDtdPath gives where these files are present
 EcSystemTemplateFile gives the mapping between dtd file and parameters we can use in the code.
 EcUserTemplateFile : If you want to update any parameter in sys_template.xml , Copy entire template to user_template.xml and modify in this file. Do not modify anything in sys_template

Lets take and example and see understand what is happening.

Consider your procurement team found a particular order has to be returned/refund. Procurement has to send message to WC.

How should be the structure of xml? Open Update_WCS_OrderStatus_20.dtd . This file give the definition of how should the xml looks like.

After procurement team creates the xml and send to WC. WC reads the understands the xml. But how would we access the values defined in the xml? for that
Open sys_template.xml and search for Update_WCS_orderstatus and consider the version in TemplateDocument/DocType version attribute is has to be 2.0

Now you understand name of the dtd and name inside the sys_template.xml are related for understanding purpose.

Lets go little depth to understand sys_template:

<TemplateDocument>
        <DocumentType version='2.0'>Update_WCS_OrderStatus</DocumentType>
        <StartElement>Update_WCS_OrderStatus</StartElement>
        <TemplateTagName>OrderStatus20Map</TemplateTagName>
        <CommandMapping>
            <Command CommandName='OrderConfirmStatus' Condition='OrderConfirmCommand' />
            <Command CommandName='OrderShippingStatus' Condition='OrderShippingCommand' />
            <Command CommandName='OrderInvoiceStatus' Condition='OrderInvoiceCommand' />
            <Command CommandName='OrderStatus' Condition='OrderStatusCommand' />
        </CommandMapping>

</TemplateDocument>

Notice TemplateTagName element in above example. This element states that refer to
<TemplateTag name='OrderStatus30Map'> in sys_template for relation between DTD and WC parameters.

Lets take a tag
<Tag XPath='DataArea/OrderStatus/OrderStatusItem/TotalPriceInfo/TotalNetPrice' Field='priceTotal' />

This tag states value under Xpath DataArea/OrderStatus/OrderStatusItem/TotalPriceInfo/TotalNetPrice  is present in priceTotal parameter.

Lets move to CommandMapping element:

 Below tag defines, If xml contains XPath = DataArea/OrderStatus then OrderStatusCommand condition matches with commandName OrderStatus

 <Tag XPath='DataArea/OrderStatus' Field='OrderStatusCommand' FieldInfo='COMMAND' />

 To know what command will be triggered for OrderStatus , Search in struts-config.xml for "/OrderStatus", by this you will know what command is called.

For customizing extend the command the command and overwrite

public  boolean doProcess(TypedProperty typedproperty)

typedproperty contains the properties that are defined in sys_template.xml

To find outbound messages OOTB provides click here

No comments:

Post a Comment