Hi,

In the synapse code ClientWorker.java[1] has the method to handle the
content type when there is no content-type with the payload.
And default content type is application/octet-stream hence, your response
is get build as binary.


Please follow the Malaka's suggestion.

Thanks


[1]


private String inferContentType() { //Check whether server sent
Content-Type in different case Map<String,String> headers = response.
getHeaders(); for(String header : headers.keySet()){ if(HTTP.CONTENT_TYPE.
equalsIgnoreCase(header)){ return headers.get(header); } } String cType =
response.getHeader("content-type"); if (cType != null) { return cType; }
cType = response.getHeader("Content-type"); if (cType != null) { return
cType; } // Try to get the content type from the message context Object
cTypeProperty = responseMsgCtx.getProperty(PassThroughConstants.CONTENT_TYPE
); if (cTypeProperty != null) { return cTypeProperty.toString(); } // Try
to get the content type from the axis configuration Parameter cTypeParam =
cfgCtx.getAxisConfiguration().getParameter( PassThroughConstants.
CONTENT_TYPE); if (cTypeParam != null) { return cTypeParam.getValue().
toString(); } // When the response from backend does not have the
body(Content-Length is 0 ) // and Content-Type is not set; ESB should not
do any modification to the response and pass-through as it is. if (headers.
get(HTTP.CONTENT_LEN) == null || "0".equals(headers.get(HTTP.CONTENT_LEN)))
{ return null; } // Unable to determine the content type - Return default
value * return PassThroughConstants.DEFAULT_CONTENT_TYPE;* }


On Fri, Dec 12, 2014 at 12:28 PM, Malaka Silva <[email protected]> wrote:
>
> Hi Sriashalya,
>
> Can you try section 'Handling messages with no content type' in [1].
>
> Also in this case you can try building using builder mediator [2]
>
> [1]
> https://docs.wso2.com/display/ESB481/Working+with+Message+Builders+and+Formatters
>
> [2] https://docs.wso2.com/display/ESB481/Builder+Mediator
>
> Best Regards,
> Malaka
>
> On Fri, Dec 12, 2014 at 10:24 AM, Sriashalya Srivathsan <[email protected]>
> wrote:
>>
>> When I send the request to back end ,it sends the response without any
>> content type.So ESB sends the binary format to the REST Client.
>>
>> Can anyone please help me to handle this situation.
>>
>>
>>
>> [2014-12-11 16:53:24,701] DEBUG - wire >> "POST
>> /services/zoho_GetAuthToken HTTP/1.1[\r][\n]"
>> [2014-12-11 16:53:24,701] DEBUG - wire >> "Host:
>> sriashalyas-macbook-pro.local:8280[\r][\n]"
>> [2014-12-11 16:53:24,701] DEBUG - wire >> "Connection: keep-alive[\r][\n]"
>> [2014-12-11 16:53:24,701] DEBUG - wire >> "Content-Length: 59[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Cache-Control:
>> no-cache[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Origin:
>> chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "User-Agent: Mozilla/5.0
>> (Macintosh: Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko)
>> Chrome/39.0.2171.71 Safari/537.36[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Content-Type:
>> application/json[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Accept: */*[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Accept-Encoding: gzip,
>> deflate[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Accept-Language:
>> en-US,en;q=0.8,ta;q=0.6[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "Cookie:
>> a8c61fa0dc=251e1e57ff3f515d68618b394d194dbd;
>> edfb7d8656=9c1fd4635ab50f92ceb89a2f6139a417;
>> JSESSIONID=4A7E75C2CF4973B11FA41904382E29DF[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "[\r][\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> "{[\n]"
>> [2014-12-11 16:53:24,702] DEBUG - wire >> ""EMAIL_ID":"[email protected]
>> ",[\n]"
>> [2014-12-11 16:53:24,703] DEBUG - wire >> ""PASSWORD":"12345678"[\n]"
>> [2014-12-11 16:53:24,703] DEBUG - wire >> "}[\n]"
>> [2014-12-11 16:53:25,433] DEBUG - wire << "POST
>> https://accounts.zoho.com/apiauthtoken/nb/create HTTP/1.1[\r][\n]"
>> [2014-12-11 16:53:25,433] DEBUG - wire << "Accept-Language:
>> en-US,en;q=0.8,ta;q=0.6[\r][\n]"
>> [2014-12-11 16:53:25,433] DEBUG - wire << "Cookie:
>> a8c61fa0dc=251e1e57ff3f515d68618b394d194dbd;
>> edfb7d8656=9c1fd4635ab50f92ceb89a2f6139a417;
>> JSESSIONID=4A7E75C2CF4973B11FA41904382E29DF[\r][\n]"
>> [2014-12-11 16:53:25,433] DEBUG - wire << "Host: invoice.zoho.com
>> [\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Accept-Encoding: gzip,
>> deflate[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Origin:
>> chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Content-Type:
>> application/x-www-form-urlencoded; charset=UTF-8[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Accept: */*[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Cache-Control:
>> no-cache[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Transfer-Encoding:
>> chunked[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
>> [2014-12-11 16:53:25,449] DEBUG - wire << "User-Agent:
>> Synapse-PT-HttpComponents-NIO[\r][\n]"
>> [2014-12-11 16:53:25,450] DEBUG - wire << "[\r][\n]"
>> [2014-12-11 16:53:25,450] DEBUG - wire << "5a[\r][\n]"
>> [2014-12-11 16:53:25,450] DEBUG - wire <<
>> "SCOPE=ZohoInvoice%2Finvoiceapi&accept=text&EMAIL_ID=watsan86%40yahoo.com
>> &PASSWORD=12345678[\r][\n]"
>> [2014-12-11 16:53:25,450] DEBUG - wire << "0[\r][\n]"
>> [2014-12-11 16:53:25,450] DEBUG - wire << "[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "HTTP/1.1 200 OK[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "Server: ZGS[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "Date: Thu, 11 Dec 2014
>> 11:23:25 GMT[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "Transfer-Encoding:
>> chunked[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "Connection: keep-alive[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "X-Content-Type-Options:
>> nosniff[\r][\n]"
>> [2014-12-11 16:53:25,745] DEBUG - wire >> "X-XSS-Protection: 1[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "Set-Cookie:
>> iamcsr=84dad3b5-e9c2-4dd8-ba99-03bea52480d2; Path=/; Secure[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "X-FRAME-OPTIONS:
>> SAMEORIGIN[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "Strict-Transport-Security:
>> max-age=15768000[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "57[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "#[\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "#Thu Dec 11 03:23:25 PST
>> 2014[\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "
>> CAUSE=EXCEEDED_MAXIMUM_ALLOWED_AUTHTOKENS[\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "RESULT=FALSE[\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "0[\r][\n]"
>> [2014-12-11 16:53:25,746] DEBUG - wire >> "[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "Strict-Transport-Security:
>> max-age=15768000[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "X-XSS-Protection: 1[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "X-FRAME-OPTIONS:
>> SAMEORIGIN[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "Set-Cookie:
>> iamcsr=84dad3b5-e9c2-4dd8-ba99-03bea52480d2; Path=/; Secure[\r][\n]"
>> [2014-12-11 16:53:25,751] DEBUG - wire << "Content-Type:
>> application/json; charset=UTF-8[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "X-Content-Type-Options:
>> nosniff[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "Date: Thu, 11 Dec 2014
>> 11:23:25 GMT[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "Transfer-Encoding:
>> chunked[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "Connection: keep-alive[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "81[\r][\n]"
>> [2014-12-11 16:53:25,752] DEBUG - wire << "
>> {"binary":"IwojVGh1IERlYyAxMSAwMzoyMzoyNSBQU1QgMjAxNApDQVVTRT1FWENFRURFRF9NQVhJTVVNX0FMTE9XRURfQVVUSFRPS0VOUwpSRVNVTFQ9RkFMU0UK"}
>> [\r][\n]"
>> [2014-12-11 16:53:25,753] DEBUG - wire << "0[\r][\n]"
>> [2014-12-11 16:53:25,753] DEBUG - wire << "[\r][\n]"
>>
>>
>
> --
>
> Best Regards,
>
> Malaka Silva
> Senior Tech Lead
> M: +94 777 219 791
> Tel : 94 11 214 5345
> Fax :94 11 2145300
> Skype : malaka.sampath.silva
> LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
> Blog : http://mrmalakasilva.blogspot.com/
>
> WSO2, Inc.
> lean . enterprise . middleware
> http://www.wso2.com/
> http://www.wso2.com/about/team/malaka-silva/
> <http://wso2.com/about/team/malaka-silva/>
>
> Save a tree -Conserve nature & Save the world for your future. Print this
> email only if it is absolutely necessary.
>


-- 
Sivajothy Vanjikumaran
*Senior Software Engineer*
*Integration Technologies Team*
*WSO2 Inc. http://wso2.com <http://wso2.com/>*
*Mobile:(+94)777219209*
[image: Facebook] <https://www.facebook.com/vanjikumaran> [image: Twitter]
<https://twitter.com/vanjikumaran> [image: LinkedIn]
<http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image:
Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare]
<http://www.slideshare.net/vanjikumaran>

This communication may contain privileged or other confidential information
and is intended exclusively for the addressee/s. If you are not the
intended recipient/s, or believe that you may have received this
communication in error, please reply to the sender indicating that fact and
delete the copy you received and in addition, you should not print,
copy, re-transmit, disseminate, or otherwise use the information contained
in this communication. Internet communications cannot be guaranteed to be
timely, secure, error or virus-free. The sender does not accept liability
for any errors or omissions
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to