Sunday, February 13, 2011

Accessing the HTTP method within a WSO2 ESB Mediator

I couldn't find this in the ESB property documentation - so thought of keeping a note here.

Also - there is a chance that you can confuse the constant "HTTP_METHOD" with org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD - which internally refers to ""HTTP_METHOD_OBJECT""
public boolean mediate(org.apache.synapse.MessageContext synCtx) {
org.apache.synapse.core.axis2.Axis2MessageContext.Axis2MessageContext axis2Msgcontext = null;
org.apache.axis2.context.MessageContext msgContext  = null;
axis2Msgcontext = (Axis2MessageContext) synCtx;
msgContext = axis2Msgcontext.getAxis2MessageContext();
String httpMethod = (String) msgContext.getProperty("HTTP_METHOD");
}

0 comments: