2015-04-12 45 views
0

我需要從駱駝調用在WildFly上運行的外部Web服務。 我設法使用以下路線來調用它:來自外部Web服務的駱駝返回值

public class CamelRoute extends RouteBuilder { 


final String cxfUri = 
     "cxf:http://localhost:8080/DemoWS/HelloWorld?" + 
     "serviceClass=" + HelloWorld.class.getName(); 
@Override 
public void configure() throws Exception { 
    from("direct:start") 
    .id("wsClient") 
    .log("${body}") 
    .to(cxfUri + "&defaultOperationName=greet"); 


} 
} 

我的問題是如何從Web服務調用的返回值?使用該方法返回一個字符串:如果在野外飛行服務返回的值即可看到值,你可以做

@WebService 
public class HelloWorld implements Hello{ 

    @Override 
    public String greet(String s) { 
     // TODO Auto-generated method stub 
     return "Hello "+s; 
    } 

} 

回答

0

以下

公共類CamelRoute擴展RouteBuilder {

final String cxfUri = 
    "cxf:http://localhost:8080/DemoWS/HelloWorld?" + 
    "serviceClass=" + HelloWorld.class.getName(); 
@Override 
public void configure() throws Exception { 
    from("direct:start") 
    .id("wsClient") 
    .log("${body}") 
    .to(cxfUri + "&defaultOperationName=greet").log("${body}"); 

//beyond this to endpoint you can as many number of componenets to manipulate the response data. 
} 
} 

第二個日誌將記錄您返回的Web服務的響應。如果您需要操作或者在響應中進行一些路由和轉換,那麼您應該查看響應的類型,因此您應該使用適當的變壓器。

希望這會有所幫助。