【发布时间】:2014-07-29 15:41:09
【问题描述】:
我正在开发一个示例应用程序,以使用骆驼路由调用 RESTful Web 服务。并且 REST 服务是安全的。我是这样编码的
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>
如果您能对此有所了解,我将不胜感激。谢谢你。 我正在使用骆驼版本:2.13。
【问题讨论】:
标签: java rest apache-camel