在cxf POJO模式下来自camel的空响应

时间:2015-11-04 08:42:59

标签: apache-camel cxf

以下是我在camel和cxf中的示例Web服务的路由。

    from("cxf:http://localhost:9000/sampleService?serviceClass=com.sample.CommonIntf")
.id("wsProxy")
.bean(MyBean.class)

我只是将输入pojo对象传递给bean。在bean里面我设置了ws响应。这是bean类。

@Handler
public SOut handle(SInput sin){
    SOut s = new SOut();
    s.setName(sin.getName());
    s.setSurName("aa");
    return s;
}

但是,我可以看到输入对象被转换并传递处理程序方法soap响应为空。

这是我的网络服务签名。

public interface CommonIntf{
    SOut sampleMethod(SInput input);
}

我的问题是虽然我的处理程序返回响应,为什么响应soap是空的?

2 个答案:

答案 0 :(得分:0)

我认为,你只是没有设置交换输出体(请求 - 回复模式)。

尝试修改您的路线:

from("cxf:http://localhost:9000/sampleService?serviceClass=com.sample.CommonIntf")
.id("wsProxy")
.to("bean:MyBean?method=handle");

MyBean类必须在bundle上下文中注册。

<bean id="MyBean" class="com.sample.MyBean"/>

答案 1 :(得分:0)

尝试以下操作,定义CXF端点 [根据http://camel.apache.org/schema/cxf/]在端点定义bean中,在此引用服务类, 并在Camel路由中引用相同的id(例如wsCxfId)。 所以路线如下:

from("cxf:bean:wsCxfId")
.id("wsProxy")
.to("bean:MyBean?method=handle");

希望这有帮助。

相关问题