1. Can you change System A to send content-type just like system B 
[application/x-www-form-urlencoded]
2. If that is possible, you can access the form variables thru header values of 
exchange in your custom bean, instead of using getBody..

-Ravi
________________________________________
From: abhijit.kulkarni [abhijit.kulka...@globalcharge.com]
Sent: Thursday, July 03, 2014 12:32 AM
To: users@camel.apache.org
Subject: Restlet and mesaage body null based on content type

Hello,

I am using Apache camel 2.10.7 and have a route which is a restlet

<from uri="restlet:/abc/xyz?restletMethods=POST"/>
<to uri="bean:myBean?method=myBeanMethod/>

This route is called by various external systems posting data. In this
route, I access the body / payload of the http request in java bean using
the following code

@Handler
public void myBeanMethod(Exchange exchange)
{
  String body = exchange.getIn().getBody(String.class);
  // further processing on the body
}

when this restlet is called by system A, by doing an HTTP POST to the url
http://host:port/abc/xyz, the http request payload is successfully obtained
and processed. Please note the system A, sets the content-type header when
doing the POST to value "text/plain".
There is another system B, when it calls the same restlet, (doing a POST to
the url http://host:port/abc/xyz) the body comes to be null. somehow the
http request body is not getting copied to exchange message body. The
exchange when I logged is  Exchange[ExchangePattern:InOut, BodyType:null,
Body:[Body is null], CaughtExceptionType:......]
While debugging I have noticed that this happens when the system B -
1. sets the content type to "application/x-www-form-urlencoded" (which is a
web application form submit)
2. does not set any content type explicitly, so the default gets set which
is "application/x-www-form-urlencoded".

The System B is an external system and cannot be changed. The System A has
been already integrated with this restlet based route and is in production.

As per the documentation, the message header content-type is defaulted to
application/x-www-form-urlencoded, but when I accessed and printed this
header, it was printed as null.
Also, message request header CamelAcceptContentType also got printed as
null.

Please help, as I have to re-use this route for the integration with the
System B.

Cheers,
Abhijit





--
View this message in context: 
http://camel.465427.n5.nabble.com/Restlet-and-mesaage-body-null-based-on-content-type-tp5753232.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.

Reply via email to