Welcome to the IBM Websphere Commerce Hub


Welcome to the IBM Websphere Commerce Hub

Come join me in my journey to explore the various features and capabilities of IBM Websphere Commerce and understand how retailers can benefit from its really cool out-of-box functionality.

Monday, January 21, 2013

Service Oriented Integration (SOI) - Websphere Commerce Web Services

As part of the WebSphere Commerce transition to SOA, there is an effort to decouple components to allow re-use of WebSphere Commerce business services in other environments besides the WebSphere Commerce application. In order to support this decoupling, the core infrastructure is the first piece that needs to run independently so it can be leveraged in other environments as well. The request handling has changed to create a lightweight runtime environment that new and existing components can use. This lightweight runtime focuses on the processing of business object documents (BODs). This new architecture paves the road to SOA adoption by standardizing on how clients will talk with SOA components.
WebSphere Commerce now provides 4 SOI service modules -- logical groupings of business objects that have been grouped to standardize communication. These service modules are:
  • Member
  • Order
  • Catalog
  • Contract
The SOI modules ultimately maps to the ControllerCommand. And you would often extend the OOB commands for your custom logic - use EJBs for persistance much as the way as you did in WCS 6.0
( I can see a lot of v6 developers expressing a huge sigh of relief ). Most of the time what the developers struggle is how to map a service to a command name. I have put together a small diagram showing the complete flow - Taking a very common scenario - extending the Registration process to store custom membership attributes.

I hope you find it easy to understand and helpful!

 

The sad part is that we may not be able to really see the "actionCode" being used in the method ( registerPerson in this example ) since we do not have the access to the source code ( I narrowed down the command by my past experience in v6 ) - but what IBM is done is help the developer community at large is provide the methodName to CommandName mappings directly in the following link:

http://pic.dhe.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=%2Fcom.ibm.commerce.component-services.doc%2Fconcepts%2Fcwvcs.htm

The following is a mapping for the MemberFacadeClient methods and the corresponding URL commands:
  • Map registerPerson(Map) - UserRegistrationAdd
  • Map updatePerson(Map) - UserRegistrationUpdate
  • Map addAddressForPerson(Map) - AddressAdd
  • Map updateAddressForPerson(Map) - AddressUpdate
  • Map deleteAddressForPerson(Map) - AddressDelete
  • Map registerOrganization(Map) - OrgEntityAdd
  • Map updateOrganization(Map) - OrgEntityUpdate
  • Map addAddressForOrganization(Map) - AddressAdd
  • Map updateAddressForOrganization(Map) - AddressUpdate
  • Map deleteAddressForOrganization(Map) - AddressDelete

If you really want to appreciate the actionCode concept , refer the below method used in the SOITutorialStoreFacadeClient.java 

( Find the details of the above in the Infocenter TutorialStore )

So, though you may not need to follow the entire web of configurations but I feel this is worth knowing.

Happy learning!


10 comments:

  1. Hi Neha,

    Very Brief and useful post about web services. It's very useful. Can you please elaborate the same about BODs flow in commerce in your feature posts. It will be more useful.

    The above mentioned example implemented in Feature Pack 5? In FEP 4 Madison store we did not see such type of implementation. Does "actionCode" passed from facadeClient to PersonBODMapping.XML? So that based on actionCode it will invoke appropriate controller command !!

    Thanks.

    ReplyDelete
  2. Hi Kiran,

    Thanks for your feedback. That is on the plan - I will include a similar post for BOD Framework.

    This is based on the base - No feature packs installed and points out how the flow basically is for SOI framework!

    Your understanding is correct. We would have a corresponding controller command mapped for each actionCode in the component services XML file.

    So, if we consider the TutorialStore example , we would have the following mappings in the component-services-user-template.xml ( this is the file where all the custom services are mapped ) -


    <!--Start Code-->
    <ECTemplate>
    <!-- TutorialStore -->
    <TemplateDocument>
    <DocumentType version="*">ProcessTutorialStore</DocumentType>
    <StartElement>ProcessTutorialStore</StartElement>
    <TemplateTagName>ProcessTutorialStoreMap</TemplateTagName>
    <CommandMapping>
    <Command CommandName="com.ibm.commerce.store.commands.StoreOpenCmd" Condition='actionCode="Open" AND actionExpression="/TutorialStore"'>
    <Constant Field="URL">NoURL</Constant>
    <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
    <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
    </Command>
    <Command CommandName="com.ibm.commerce.store.commands.StoreCloseCmd" Condition='actionCode="Close" AND actionExpression="/TutorialStore"'>
    <Constant Field="URL">NoURL</Constant>
    <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
    <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
    </Command>
    </CommandMapping>
    </TemplateDocument>

    <TemplateTag name="ProcessTutorialStoreMap">
    <Tag XPath="ApplicationArea/BusinessContext/ContextData" XPathType="USERDATA"/>
    <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression@actionCode" Field="actionCode" FieldInfo="COMMAND"/>
    <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression" Field="actionExpression" FieldInfo="COMMAND"/>
    <Tag XPath="DataArea/TutorialStore/StoreIdentifier/UniqueID" Field="targetStoreId"/>
    </TemplateTag>
    </ECTemplate>
    <!--End Code-->



    In the example above , I have mapped the actionCode="Close" to StoreCloseCmd.
    I hope this clarifies.

    Happy learning,
    Neha Das

    ReplyDelete
  3. Hi Neha ,
    It is very help ful to wcs devlopers and supporting team . Can u give any new BOD example.It may helpful to us.

    ReplyDelete
    Replies
    1. Check the below post -

      http://www.wcs-hub.blogspot.in/2013/01/business-object-document-websphere.html

      More details to follow!

      Delete
  4. Hi Neha,

    I tried to follow infocenter for developing BOD services but its full of errors when generating java code for the xsd they have provided.
    If you have could explain with a simple example then it would be great.

    if possible with code.

    Regards
    Dilip Mallik

    ReplyDelete
    Replies
    1. Check the below post :

      http://www.wcs-hub.blogspot.in/2013/01/business-object-document-websphere.html

      More details to follow!

      Delete
  5. Will post similar stuff for bod as well.Stay tuned!

    ReplyDelete
  6. Hi Neha,
    This is an amazing blog and all the topics covered have been described extremely well..I would personally like to thank you for giving the WCS Community such a wonderful blog.

    Regards,
    Arjun

    ReplyDelete
    Replies
    1. Thanks Arjun for the kind words.. Glad it helped .. Spread the word.

      Happy Exploring!

      Best,
      Neha

      Delete
  7. Hi Neha,
    One information to add to your post. You can make the connection with actioncode and command from a configuration file. Taking into consideration the member module for eg, you can see the command-actionCode mapping in PersonBODMapping.xmlf

    Regards,
    Shillu Jos

    ReplyDelete