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.

Showing posts with label webservices. Show all posts
Showing posts with label webservices. Show all posts

Monday, April 7, 2014

Debugging BOD Framework

Important Trace Strings to debug BOD


BOD Request / Response:  

com.ibm.commerce.foundation.server.command.bod.*

Data Service Facade Trace String: 

com.ibm.commerce.foundation.server.services.dataaccess.DataServiceFacade 

Get Service Flow Trace Strings:

Useful to understand if the code is breaking midway and if you would like to enable tracing for individual commands.

Fetch<ComponentName>Cmd 

The first point to debug the Get / Search service failures. 
The Fetch command fetches the data.Extensions of this Fetch command are associated with a particular XPath expression.The command framework can use the XPath expression and Fetch task command to resolve the Get request to a particular implementation by using the existing WebSphere Commerce command registry (CMDREG) data. Instead of having one implementation for a Fetch business task, the command framework uses the XPath as the selector to resolve the implementation. If a specific implementation is not defined for the given XPath, then a default Fetch is used.

For example , The InventoryAvailability noun uses a default Fetch implementation and to debug , you must enable the trace for :



com.ibm.commerce.inventory.facade.server.commands.FetchInventoryAvailabilityForDKCmdImpl
 
Compose<ComponentName>Cmd 

The Fetch Command calls the Compose commands to composes the response.When the Get command calls the Compose command, it uses the access profile of the request as the key to select the appropriate Compose implementation. Because the access profile is just a superset of another access profile, the Compose commands delegates to the parent access profile to first populate the logic model and add any required information.

For example , The InventoryAvailability noun uses the below Compose implementations and to debug , you must enable the trace depending on the Inventory system used :



DOMInventorySystem com.ibm.commerce.inventory.facade.server.commands.ComposeDOMInventoryAvailabilityForDKInBatchCmdImpl

NonATPInventorySystem
com.ibm.commerce.inventory.facade.server.commands.ComposeNonATPInventoryAvailabilityCmdImpl

ATPInventorySystem
com.ibm.commerce.inventory.facade.server.commands.ComposeATPInventoryAvailabilityForDKCmdImpl
 
ReadBusinessObjectMediators 

The read mediator constructs the logical object based on the values in the corresponding physical entity.The Read mediators can be found by looking at the below file:



/WC/xml/config/<component-name>/wc-business-object-mediator.xml


For example , The InventoryAvailability service debugging , enable the trace for the below :
com.ibm.commerce.inventory.facade.server.services.dataaccess.bom.mediator.ReadInventoryAvailabilityMediator  
If you do not wish to enable the trace on a granular level , you could also enable the trace for the entire component service.

For example , for Inventory services , enable the below trace :
com.ibm.commerce.inventory.facade.server.*

Debugging Query Template File


XPATH Syntax Validator (wcs_xpathkey utility):

The XPath key generator command-line utility takes an XPath expression as input and generates an XPath key. This key is used to locate the XPATH_TO_SQL_STATEMENT template in the query template file.This utility can help you validate the format of the XPATH Key as well such as missing closing brackets etc or misplaced tokens. Please note this would not however match the XPATH with the actual Noun definition.

wcs_xpathkey MyXPath
For example:
wcs_xpathkey /CatalogEntry[(@catalogEntryTypeCode='ProductBean' 
  or @catalogEntryTypeCode='ItemBean') and 
   ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier='Coffee Table']]]

The output from this command , if sucessful, would be:
/CatalogEntry[(@catalogEntryTypeCode=) and 
   ParentCatalogGroupIdentifier[ExternalIdentifier[GroupIdentifier=]]]

In case of failures , would display certain error messages.

Query Template File Syntax Validator

Use this page to validate your query template file syntax.
http://localhost/webapp/wcs/admin/servlet/dsl.jsp

In case you are seeing NullPointer exceptions on querying even the OOB services, make the below changes in the dsl.jsp.

Search for the below line:
sc.setXPath(sbQuery.toString());

Add the following line of code below the above line:
sc.setComponentId(componentId); 

Reloading the configuration of a BOD service module

During development, you may want to modify and reload configuration, without having to restart the server. Follow the below Infocenter link  for more details:


http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.soa.doc/tasks/tsdreloadconfig.htm

Sunday, January 27, 2013

Business Object Document : Websphere Commerce Web Services

The WebSphere Commerce BOD command framework architecture uses well defined interfaces to decouple the implementation of the presentation layer, business logic layer and persistence layer. From the business logic layer perspective, OAGIS messages are used as the interface for making requests to retrieve business data or invoke business logic. The BOD command framework provides the capability to process these BOD requests and responses.

Found this really nice pictorial description of the various assets and processes involved in the BOD development in the  IBM Red Book (sg247619)

More to come to BOD Command Framework... 

On reader's requests -

See Also:

 

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!