我有3个派对网络服务,我想调用它并将xml放入其中。我使用了apache camel。
<parameter>
<name>LastModified</name>
<value>2015-11-24 11:15:38.0</value>
</parameter>
<parameter>
<name>UpdatedAttribute</name>
<value>PORT2PROVISIONSTATUS</value>
</parameter>
<parameter>
<name>NewValue</name>
<value>Configured</value>
</parameter>
<parameter>
<name>EntityType</name>
<value>Pluggable</value>
</parameter> </parameterSet>
端点是 http://localhost:8080/RestfulWebService/crunchify/dspservice
我无法改变的客户端实施:
@Path("{event}")
@GET
@Produces("application/json")
public String getICLEvent(@PathParam("event") String event)
{
System.out.println("ICL Event :: "+ event);
String result = "@Produces(\"application/xml\") Output: \n\nICL Event: \n\n" + event;
return result;
}
到目前为止我尝试了什么:
我在我的路线中使用了Camel http组件,如:
.convertBodyTo(String.class, "UTF-8")
.setHeader(Exchange.HTTP_URI, simple("http://localhost:8080/RestfulWebService/crunchify/dspservice/${in.body}"))
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
//.setHeader(Exchange.HTTP_QUERY, constant("event=${in.body}"))
//.setHeader(Exchange.CONTENT_TYPE, constant("application/form-urlencoded"))
.to("http://localhost:8080/RestfulWebService/crunchify/dspservice")
我试图在标题键'CamelHttpUri'中传递完整的字符串,但我得到java.net.URISyntaxException:
例外。
我不确定这是打电话/制作宁静的网络服务的最佳方式,请建议我找到更好的方式在网上找到任何东西。
答案 0 :(得分:0)
为什么不使用Camel Restlet呢? http://camel.apache.org/restlet.html 这里有一个例子:
.convertBodyTo(String.class, "UTF-8")
.to("restlet:http://localhost:" + portNum + "/?restletMethod=GET");