簡體   English   中英

apache camel webservice客戶端

[英]apache camel webservice client

我已經在我的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來調用此Web服務

@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 ,因此可以看到正在發送請求,因為它已經被接收,但是我不知道如何處理響應。

System.out.println(exchange_.getOut().getBody()); WebService在響應中發送Received時返回null值。

誰能告訴我如何處理來自Exchange的響應?

回復來自pt.send返回的內容。

處理方法僅用於配置請求方法。 沒有得到答復。 回復來自pt.send返回的內容。

Exchange reply = pt.send(...)

另外請注意OUT與IN,請參閱以下常見問題解答:http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM