Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel 从camel cxf组件向客户端发送响应_Apache Camel - Fatal编程技术网

Apache camel 从camel cxf组件向客户端发送响应

Apache camel 从camel cxf组件向客户端发送响应,apache-camel,Apache Camel,我不熟悉camel,我正在尝试使用camel cxf组件来创建soap web服务。我从《骆驼行动》的一个样本开始。我已经使用cxf组件配置了一个路由,并添加了一个处理器来处理请求。我在用于处理服务的bean中收到了请求,但我无法将响应发送回客户端。提前谢谢 这是我使用的路线: <route> <from uri="cxf:bean:orderEndpoint" /> <setExchangePattern pattern="InOut"/> <to u

我不熟悉camel,我正在尝试使用camel cxf组件来创建soap web服务。我从《骆驼行动》的一个样本开始。我已经使用cxf组件配置了一个路由,并添加了一个处理器来处理请求。我在用于处理服务的bean中收到了请求,但我无法将响应发送回客户端。提前谢谢

这是我使用的路线:

<route>
<from uri="cxf:bean:orderEndpoint" />
<setExchangePattern pattern="InOut"/>
<to uri="bean:productService" />
</route>
Sysout语句打印在控制台上,但我得到的soap响应是空的

以下是我点击/从浏览器中点击时的回应:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body/>
</soap:Envelope>

您的响应是您在死记硬背结束后在路由正文中的响应,因此您必须在路由结束前创建massege响应对象。

您应该使用以下方法实现、拦截和处理消息:

public class MyProcessor implements Processor {
  public void process(Exchange exchange) throws Exception {
    ...
    // Set your response here
    exchange.getOut().setBody(product);
  }
}
然后在路线中引用处理器

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body/>
</soap:Envelope>
public class MyProcessor implements Processor {
  public void process(Exchange exchange) throws Exception {
    ...
    // Set your response here
    exchange.getOut().setBody(product);
  }
}