Monday, May 30, 2011

POST variables get dropped while going through the WSO2 ESB proxy ... ?

This is more of a small note in case I forget what i did while trying things out. First of all I created a ESB proxy for a back-end service that accepts post request and does some manipulation on the received request.

Once you create a ESB proxy by giving the above REST service as the service endpoint , the InSequence element of the proxy.xml will look like this.

<inSequence>
         <send>
            <endpoint name="endpoint_urn_uuid_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
               <address uri="http://localhost/restServiceEndPoint" format="rest" />
            </endpoint>
         </send>
      </inSequence>

The problem is the configuration drops the POST variables while building the SOAP envelope. Some debugging in to the Axis2 code revealed that the transport is attaching the incoming variable list to the Axis2MessageContext, but the attached data structure is MultipleEntryHashMap(It removes the value from the data-structure once you access it) which is a Axis2 implementation. However I couldnot access the the stored variables in the data structure within a Custom mediator, (the data has been already consumed at that point, may be by once of the dispatchers.)

So the other option was to use binary relay. It worked fine for me. Here are the steps I followed to get it working. First you have to enable the binary relay builder / Formatter for the relevant application-content type (In my case XForm-URL-encoded).

Then remove the format="rest"  attribute from the address element (InSequence of proxy.xml)

Thats it, the binary relay builder wraps your request as it is and expand it back when it sends back to to actual service.

1 comment:

  1. This article is very informative and cool. Thanks for share this beautiful article.
    access Torrent Downloads in UK

    ReplyDelete