Sunday, April 5, 2015

WSO2 ESB: How get response http status code

The http status code of the response message is in the response Axis2MessageContext as a property. We can get the value from the Axis2MessageContext as follows.


This will return an object. We can type cast that object.
Eg: If we want to get an integer value we can cast it to Integer.

 (Integer) Axis2MessageContext.getProperty(NhttpConstants.HTTP_SC);

If we want to get the response message http status code from the Synapse message context first get Axis2 message context from the Synapse message context and then get the http status code as the same way.
 (Integer) (((Axis2MessageContext) synapseMessageContext).getAxis2MessageContext().getProperty(NhttpConstants.HTTP_SC));

No comments:

Post a Comment