Java 调用restfulwebservice并希望使用apachecamel以字符串形式发送XML

Java 调用restfulwebservice并希望使用apachecamel以字符串形式发送XML,java,web-services,rest,apache-camel,Java,Web Services,Rest,Apache Camel,我有三方Web服务,我想调用它并将xml放入其中。我已经使用了ApacheCamel 这是我想放在Web服务上的XML: 到目前为止我所尝试的: 我在路由中使用了驼峰http组件,如: .convertBodyTo(String.class, "UTF-8") .setHeader(Exchange.HTTP_URI, simple("http://localhost:8080/RestfulWebService/crunchify/d

我有三方Web服务,我想调用它并将xml放入其中。我已经使用了ApacheCamel

  • 这是我想放在Web服务上的XML:
  • 到目前为止我所尝试的:

    我在路由中使用了驼峰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:
    异常


    我不确定这是调用/生成restful Web服务的最佳方式,请推荐我找到的在internet上查找任何内容的更好方式。

    为什么不改用Camel Restlet? 这里举一个例子:

    .convertBodyTo(String.class, "UTF-8")
    .to("restlet:http://localhost:" + portNum + "/?restletMethod=GET");
    

    在REST中,使用HTTP方法POST或PUT完成生成调用。可能这就是问题所在。
    .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")
    
    .convertBodyTo(String.class, "UTF-8")
    .to("restlet:http://localhost:" + portNum + "/?restletMethod=GET");