Java 调用Camel restlet producer并给出异常

Java 调用Camel restlet producer并给出异常,java,rest,apache-camel,Java,Rest,Apache Camel,我正在开发一个示例应用程序,以使用驼峰路由调用RESTful web服务。剩下的服务是安全的。我是这样编码的 from("file:data/source?noop=true") .process(new Processor() { @Override public void proce

我正在开发一个示例应用程序,以使用驼峰路由调用RESTful web服务。剩下的服务是安全的。我是这样编码的

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");
我只是从端点选取xml文件,它是REST服务的输入或主体。在将此xml传递给REST服务之前,我将设置头部以确保安全性。但是我不能点击服务,这给了我一个例外

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>
org.apache.camel.component.restlet.restleOperationException:restlet操作调用失败http://xxxx/xxxxx/batch/query-by-hwid.xml 带状态代码:405/n响应主体:
错误405--不允许使用方法


错误405--不允许使用方法 来自RFC 2068超文本传输协议——HTTP/1.1: 10.4.6不允许使用405方法

请求行中指定的方法不允许用于由请求URI标识的资源。响应必须包含一个Allow标头,其中包含请求资源的有效方法列表。

如果你能解释一下,我将不胜感激。非常感谢。
我使用的是Camel版本:2.13。

Rest服务通常需要并使用Accept标头

所以你应该设置这个标题

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

谢谢你,克劳斯。但是,在添加了所提到的头之后,我得到了相同的异常。“请求行中指定的方法不允许用于由请求URI标识的资源。响应必须包括一个包含请求资源的有效方法列表的Allow头。”克劳斯,此异常有何说明。。。