Order Management Module - Different ways of invoking functionality
With WebSphere Commerce
feature pack 4 onward, we now have three variations of invoking the
Order Management URL's. Lets look at each of them and when and how to use them
considering the performance.
1. Struts Actions invoking WebSphere Commerce Command.
1. Struts Actions invoking WebSphere Commerce Command.
Invoke the struts Action
configured to a Websphere commerce command, either using the HTTP/HTTPS and
passing the request parameters using a GET or a POST method.
Ex: OrderItemAdd action invoking
the OrderItemAdd command.
<action
parameter="com.ibm.commerce.orderitems.commands.OrderItemAddCmd"
path="/OrderItemAdd"
type="com.ibm.commerce.struts.BaseAction">
<set-property property="https" value="0:1"/>
<set-property property="authenticate"
value="0:0"/>
</action>
Request:
https://localhost/....../OrderItemAdd?catEntryId-123&<otherparameters>
Here the request
parameters are passed from a browser or a any client as name/value pair and
processed directly by the OrderItemAdd command, well of course there can
be struts validator framework validating the parameter being passed.
2. SOI Actions invoking the SOI client and the
Commerce Command
Invoke the SOI action
configured in struts, which will further invoke the SOI client and then pass it
on to the Commerce Command.
Ex: AjaxOrderChangeServiceItemAdd
invoking the Component Service
<action parameter="order.addOrderItem"
path="/AjaxOrderChangeServiceItemAdd"
type="com.ibm.commerce.struts.AjaxComponentServiceAction">
<set-property
property="authenticate" value="0:0"/>
<set-property property="https"
value="0:1"/>
</action>
This action if invoked
from a browser passing the name-value pair parameters, will convert them to
OAGIS message first, then converts back into name-value pair and invokes the
OrderItemAddCmd. So there is a additional conversion of name-value pair to
OAGIS message and then back to name/value pair, as the OrderItemCmd will only
understand this format.
If invoked from
browsers, this could have negative impact on the performance of Order
management functionality.
This can be used if the
client needs to pass the OAGIS message format into the Websphere Commerce
Server.
3. REST services introduced in FEP4.
Invoke the struts action
and pass the request as JSON.
Ex: POST
/wcs/resources/store/10101/cart HTTP/1.1
Host:
localhost
Content-Type:
application/json
{
"orderItem": [
{
"productId":
"10541",
"quantity": "2.0",
"itemAttributes": [
{
"attrName":
"10297",
"attrValue":
"4T"
}
]
},
{
"productId":
"10823",
"quantity": "3.0"
},
{
"productId":
"10260",
"quantity": "1.0"
}
]
}
Here the request is
first interpreted by the REST webservice, which converts the JSON string into a
Map of name/value pairs and then invokes the SOI service of OrderManagement
(section 2 above), then further processing by SOI and the return response is
converted back into JSON.
With REST, we now have
two more conversions one from JSON to name/value pair, then name/value pair to
OAGIS message, then OAGIS to name/value pair.
JSON is very well used
format for AJAX requests and for exposing Restful services, but do we need two
level of conversion before the request is actually process.
Comments