[英]Calling restful webservice and want to send XML as string using Apache Camel
I have 3 party webservice which I want to call and put xml into it. 我有3个第三方Web服务,我想调用它并将xml放入其中。 I have using 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>
Endpoint is http://localhost:8080/RestfulWebService/crunchify/dspservice 端点为http:// localhost:8080 / RestfulWebService / crunchify / dspservice
Client implementation which I cannot change: 我无法更改的客户端实现:
@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; }
What I have tried so far: 到目前为止我尝试过的是:
I have used Camel http component in my route like: 我在路线中使用了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")
In which I am trying to pass the complete string in the header key 'CamelHttpUri', but I am getting the java.net.URISyntaxException:
exception. 在其中尝试在标头键“ CamelHttpUri”中传递完整的字符串,但在获取java.net.URISyntaxException:
异常。
I am not sure this is the best way to call/produce the restful webservice, please suggest the better way I have found hard way to find anything over the internet. 我不确定这是调用/生成静态Web服务的最佳方法,请提出更好的方法,我发现很难在Internet上找到任何东西。
Why don't you use Camel Restlet instead? 为什么不使用Camel Restlet? http://camel.apache.org/restlet.html An example here: http://camel.apache.org/restlet.html此处的示例:
.convertBodyTo(String.class, "UTF-8")
.to("restlet:http://localhost:" + portNum + "/?restletMethod=GET");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.