You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Raju Mandala <ir...@gmail.com> on 2014/07/29 18:34:44 UTC

Invoking Camel restlet producer giving an exception

Hi,

I am working on a sample application to invoke a RESTful web service using
camel routing. And the REST service is secured. I coded like this

from("file:data/source?noop=true")
                        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange)
throws Exception {

exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");

exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/xml");

exchange.getIn().setHeader(RestletConstants.RESTLET_LOGIN, "xxxx");

exchange.getIn().setHeader(RestletConstants.RESTLET_PASSWORD, "xxxx");
                            }
                        })
                        .to("restlet:http://xxxx/xxxx/batch/query-by-hwid.xml");

 I am just picking xml file in from endpoint which is input or body to the
REST service. And before passing this xml to the REST service, am setting
up the headers for security. But am not able to hit the service and it is
giving me an exception saying

org.apache.camel.component.restlet.RestletOperationException: Restlet
operation failed invoking http://xxxx/xxxxx/batch/query-by-hwid.xml
with statusCode: 405 /n responseBody:<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Draft//EN"><HTML><HEAD><TITLE>Error 405--Method
Not Allowed</TITLE><META NAME="GENERATOR" CONTENT="WebLogic
Server"></HEAD><BODY bgcolor="white"><FONT FACE=Helvetica><BR
CLEAR=all><TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all><FONT
FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 405--Method Not
Allowed</H2></FONT></TD></TR></TABLE><TABLE border=0 width=100%
cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT
FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068
<i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3></FONT><FONT
FACE="Helvetica" SIZE="3"><H4>10.4.6 405 Method Not
Allowed</H4></FONT><P><FONT FACE="Courier New">The method specified in
the Request-Line is not allowed for the resource identified by the
Request-URI. The response MUST include an Allow header containing a
list of valid methods for the requested
resource.</FONT></P></FONT></TD></TR></TABLE>
</BODY></HTML>

 I will be thankful if you can shed some light on this. Thank you. I am
using Camel Version : 2.13.

~Raju.

Re: Invoking Camel restlet producer giving an exception

Posted by sandp <sa...@gmail.com>.
Add  the option* restletMethod=POST* to the URL you are posting to.



--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-Camel-restlet-producer-giving-an-exception-tp5754603p5754687.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking Camel restlet producer giving an exception

Posted by rajumandala <ir...@gmail.com>.
Yeah Claus...but even after adding that header am getting the same exception.
Am i going in the right direction ?



--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-Camel-restlet-producer-giving-an-exception-tp5754603p5754616.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking Camel restlet producer giving an exception

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Rest services usually requires and use the Accept header

exchange.getIn().setHeader("Accept", "application/xml");

On Tue, Jul 29, 2014 at 6:34 PM, Raju Mandala <ir...@gmail.com> wrote:
> Hi,
>
> I am working on a sample application to invoke a RESTful web service using
> camel routing. And the REST service is secured. I coded like this
>
> from("file:data/source?noop=true")
>                         .process(new Processor() {
>                             @Override
>                             public void process(Exchange exchange)
> throws Exception {
>
> exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST");
>
> exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/xml");
>
> exchange.getIn().setHeader(RestletConstants.RESTLET_LOGIN, "xxxx");
>
> exchange.getIn().setHeader(RestletConstants.RESTLET_PASSWORD, "xxxx");
>                             }
>                         })
>                         .to("restlet:http://xxxx/xxxx/batch/query-by-hwid.xml");
>
>  I am just picking xml file in from endpoint which is input or body to the
> REST service. And before passing this xml to the REST service, am setting
> up the headers for security. But am not able to hit the service and it is
> giving me an exception saying
>
> org.apache.camel.component.restlet.RestletOperationException: Restlet
> operation failed invoking http://xxxx/xxxxx/batch/query-by-hwid.xml
> with statusCode: 405 /n responseBody:<!DOCTYPE HTML PUBLIC
> "-//W3C//DTD HTML 4.0 Draft//EN"><HTML><HEAD><TITLE>Error 405--Method
> Not Allowed</TITLE><META NAME="GENERATOR" CONTENT="WebLogic
> Server"></HEAD><BODY bgcolor="white"><FONT FACE=Helvetica><BR
> CLEAR=all><TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all><FONT
> FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 405--Method Not
> Allowed</H2></FONT></TD></TR></TABLE><TABLE border=0 width=100%
> cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT
> FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068
> <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3></FONT><FONT
> FACE="Helvetica" SIZE="3"><H4>10.4.6 405 Method Not
> Allowed</H4></FONT><P><FONT FACE="Courier New">The method specified in
> the Request-Line is not allowed for the resource identified by the
> Request-URI. The response MUST include an Allow header containing a
> list of valid methods for the requested
> resource.</FONT></P></FONT></TD></TR></TABLE>
> </BODY></HTML>
>
>  I will be thankful if you can shed some light on this. Thank you. I am
> using Camel Version : 2.13.
>
> ~Raju.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/