Search This Blog

Wednesday, March 28, 2012

WCS Web service call returns a null response object

The problem that I was facing was that when the web service was called to get the Inventory response than there is a connection error at Mule.
WCS Framework is returning null object for our web Service.

There was nothing in the System logs from WCS related to this. We can see the following Connection error at the Mule Server End.


Following exception came at the Mule End
WARN 2012-03-13 16:42:36,448 [[MNSIntelligentStubs].connector.http.mule.default.receiver.02] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://www.ibm.com/xmlns/prod/commerce/inventory}InventoryServicesPortTypeService#{http://www.ibm.com/xmlns/prod/commerce/inventory}ProcessOrderInventory has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:224)
at org.mule.module.cxf.CxfInboundMessageProcessor$1.write(CxfInboundMessageProcessor.java:383)
at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:315)
at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:164)
at org.mule.work.WorkerContext.run(WorkerContext.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at java.io.DataOutputStream.write(Unknown Source)
at org.apache.commons.httpclient.ChunkedOutputStream.flushCache(ChunkedOutputStream.java:100)
at org.apache.commons.httpclient.ChunkedOutputStream.finish(ChunkedOutputStream.java:143)
at org.apache.commons.httpclient.ChunkedOutputStream.close(ChunkedOutputStream.java:199)
at org.mule.module.cxf.support.DelegatingOutputStream.close(DelegatingOutputStream.java:39)
at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:188)
at org.mule.module.cxf.transport.MuleUniversalDestination$ResponseConduit.close(MuleUniversalDestination.java:81)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 9 more


I checked if there was a problem at the web service itself. However, there was no problem at the web service level because I used SoapUI client to test the web service from Mule and I could get the response xml back.

Problem that we are not able to get the response from the web Service is following.

The problem was that WCS did not parse for response when Content-Length header was not available in the response. For smaller responses, the Content-Length http header was available and hence WCS was displaying the response whereas for large responses, there was no Content-Length header in the response which made WCS think that there was no response and hence return a null response object before the response body could processed.

The chunked encoding modifies the body of a message in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer containing entity-header fields. This allows dynamically produced content to be transferred along with the information necessary for the recipient to verify that it has received the full message.

Since the messages are passed as chunks, there is no Content-Length header present. Content-Length header is present only when the actual size of the message and the size of the transmission is the same. In case of “chunked” the sizes are different.


To Resolve the Issue

We need to change following attribute in the wc-server.xml
1. Find the following entry in the wc-server.xml
<OutboundConnector default="true" enabled="true" id="-101" name="HTTP-WS" retries="3">

Now add following tag
<EditableProperty Admin="bufferResponse" display="false" editable="yes" name="setIsBufferResponse" value="false" />

Once the files are updated, restart the websphere application server. This should resolve the problem.

2. Ensure that the WCS is restarted.

3.Now Configure the message to use the bufferResponse property.
1. Open the WebSphere Commerce Administration Console
2. Select Configuration -> Message Types
3. Open the message
4. Click Next
5. In the Change Message Transport Assignment panel, set bufferResponse to true

Now you are able to get response back in WCS.


IBM links
http://www-01.ibm.com/support/docview.wss?uid=swg1JR36471

No comments:

Post a Comment