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
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