【问题标题】:apache camel webservice clientapache骆驼网络服务客户端
【发布时间】:2015-04-13 15:36:24
【问题描述】:

我在camel-context.xml 中创建了端点和路由,如下所示:

<cxf:cxfEndpoint id="testEndpoint" address="https://127.0.0.1:443/ws"
            serviceClass="pl.test.ws.testWsImpl"
            wsdlURL="/META-INF/wsdl/testCFService.wsdl"
            endpointName="s:test_Port"
            serviceName="s:testDescriptor"
            xmlns:s = "test.namespace"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
       <route>
         <from uri="direct://start" />
         <to uri="cxf:bean:testEndpoint" />
       </route>
    </camelContext>

然后我试图通过创建ProducerTemplate 来调用这个网络服务

@Produce(uri="direct:start")
    ProducerTemplate pt;

并向其中发送消息:

pt.send(new Processor() {
  public void process(Exchange exchange_) throws Exception {
    TestRequest test = new TestRequest();
    test.setRequest("hello world");
    exchange_.getIn().setBody(test);
    System.out.println(exchange_.getOut().getBody());
}});

我在本地启动并运行了WebService,因此我可以看到正在发送请求,因为它正在被接收,但是我不知道如何处理响应。

WebService 发送Received 作为响应时,System.out.println(exchange_.getOut().getBody()); 行正在返回null 值。

谁能告诉我如何处理来自Exchange 的回复?

【问题讨论】:

    标签: java web-services apache-camel


    【解决方案1】:

    回复来自 pt.send 返回的内容。

    process 方法仅用于配置请求方法。得不到答复。回复来自pt.send 返回的内容。

    Exchange reply = pt.send(...)
    

    还要注意 OUT 与 IN,请参阅此常见问题解答 http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 2012-04-26
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多