jmhostalet
jmhostalet

Reputation: 4639

WSO2 ESB handling servlet response as binary

I have a soap to rest conversion in my inSecuence, for testing I am using soap-ui as cliente and a servlet developed with eclipse and axis in local. So far so good, everything works fine.

But... when I change the http endpoint to the real servlet i am getting the response as binary

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Body> 
  <axis2ns1073:binary xmlns:axis2ns1073="...">T0z=</axis2ns1073:binary> 
</soapenv:Body> 
</soapenv:Envelope> 

When I call the servlet with any browser (eg Firefox) using the same url I am getting "NOK"

That means:

I've used tcpmon to see the differences between the response of the mock and the response of the real servlet. The main difference is that the real servlet is responding with transfer encoding: chunked

¿What could I do to treat the response properly?

enter image description here

Upvotes: 0

Views: 704

Answers (1)

Harshana Martin
Harshana Martin

Reputation: 857

Does your servlet has the "Content-Type" header in the response?

As I can see in your attached image the Content-Type header is missing. When Content-Type header is missing in the response, ESB assumes the Content-Type as binary and parse the response as Binary.

So to fix your problem, please update your servlet to include the Content-Type header in the response with proper Content-Type , e.g: text/plain and try the invocation again. It should work.

If you are not able to change your servlet, you need to configure the ESB to use a default Content Type when the Content Type header is missing. You can find the details on how to do it in http://charithaka.blogspot.sg/2014/07/how-to-enforce-default-http-content.html

Hope this helps!

Thanks and Regards,

Harshana

Upvotes: 1

Related Questions