java - Howto extract data from the JSON body of REST request inside a WSO2 ESB Synapse handler -


i'm writing custom handler wso2 esb construct authentication credentials based on input request content. right have this:

public boolean handlerequest(messagecontext context) {     // todo: extract relevant information (clientid) json request body     string clientid;      map<string, string> headers = (map<string, string>) ((axis2messagecontext) context).getaxis2messagecontext().getproperty(             org.apache.axis2.context.messagecontext.transport_headers);      setauthorization(headers, clientid);      return true; } 

i can't find documentation regarding howto access rest json request body inside synapse handler. ideas? possible define property before handler runs , capture string clientid = (string)context.getproperty("clientid")?

you can try following;

// getting json payload string string jsonpayloadtostring = jsonutil.jsonpayloadtostring(((axis2messagecontext) context).getaxis2messagecontext()); // make json object jsonobject jsonbody = new jsonobject(jsonpayloadtostring); 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -