我在Apache Camel和CXF中遇到了一个有趣的困境。如何明确定义Apache Camel CXF消费者和生产者
我尝试建立以下路线。
from("servlet://proxy?matchOnUriPrefix=true") .to("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE");
`from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE").to("file:/META-INF/data/test.xml");`
我的愿望其实是接收与Servlet组件的要求,做一些与(处理器,转换等,但我不包括在这里为简单起见)重定向这对我的web服务的实现和文件组件会将文件的内容作为结果返回给WebService。
问题是,如果我从端点'from("servlet://proxy?matchOnUriPrefix=true")
'路由到端点'to("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
'骆驼认为这应该是CXF Consumer,但我希望它是一个生产者。
所以我其实我喜欢从from("servlet://proxy?matchOnUriPrefix=true")
到'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
',但我找不到一个办法。
如果我配置为第一个配置,servlet组件接收到请求,路由到CXF:consumer然后它启动到CXF的TCP调用:'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
'中定义的生产者它有效,但它很奇怪,我不想要开始一个TCP通话,我只想让这个消息去'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
'。
有没有一种方法可以达到我想要什么?我可以定义一个CXF消费者或提供者,然后使用'from','to'?
有趣地我与ServiceMix的/保险丝类似的东西。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgiRouter="http://osgi.salgar.org/osgirouter"
xmlns:http="http://servicemix.apache.org/http/1.0"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://servicemix.apache.org/http/1.0 http://servicemix.apache.org/http/1.0/servicemix-http.xsd">
<http:consumer service="http:FindOrders" endpoint="httpEndpoint" locationURI="http://localhost:8088/MockB2BService"
defaultMep="http://www.w3.org/2004/08/wsdl/in-out" targetService="osgiRouter:mediation" />
<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eip="http://servicemix.apache.org/eip/1.0"
xmlns:osgiRouter="http://osgi.salgar.org/osgirouter"
xmlns:orderProvider_v1="http://v1.salgar.org/B2BService"
xmlns:orderProvider_v2="http://v2.salgar.org/B2BService"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://servicemix.apache.org/eip/1.0 http://servicemix.apache.org/eip/1.0/servicemix-eip.xsd">
<eip:content-based-router endpoint="osgiRouterMediation"
service="osgiRouter:mediation">
<eip:rules>
<eip:routing-rule>
<eip:predicate>
<eip:xpath-predicate id="wsdl_version_predicate_v1"
xpath="(//namespace::*[.='http://v1.salgar.org/B2BService']) = 'http://v1.salgar.org/B2BService'" />
</eip:predicate>
<eip:target>
<eip:exchange-target service="orderProvider_v1:findOrders" />
</eip:target>
</eip:routing-rule>
<eip:routing-rule>
<eip:predicate>
<eip:xpath-predicate id="wsdl_version_predicate_v2"
xpath="(//namespace::*[.='http://v2.salgar.org/B2BService']) = 'http://v2.salgar.org/B2BService'" />
</eip:predicate>
<eip:target>
<eip:exchange-target service="orderProvider_v2:findOrders" />
</eip:target>
</eip:routing-rule>
</eip:rules>
</eip:content-based-router>
<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
xmlns:orderProvider_v1="http://v1.salgar.org/B2BService"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://servicemix.apache.org/cxfbc/1.0 http://servicemix.apache.org/cxfbc/1.0/servicemix-cxf-bc.xsd">
<cxfbc:provider endpoint="findOrdersProviderEndpoint"
useJBIWrapper="false" wsdl="classpath:v1/B2BService.wsdl" service="orderProvider_v1:findOrders"
locationURI="http://localhost:8989/MockB2BService" />
<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
</beans>
预期其中一期工程但我可以明确地定义端点CXF提供者,做我这里有同样的可能性大吗?
如果我使用“从( “servlet的://代理matchOnUriPrefix =真正的”)。为了 ( “CXF:?/事件WSDLURL = WSDL/OrderInfoService.wsdl&DATAFORMAT =报”)。为了 (“文件:/ META-INF/data/test.xml“);'和'to(”cxf:/ incident?wsdlURL = wsdl/OrderInfoService。wsdl&dataFormat = MESSAGE“)'尝试使用web服务(进行TCP调用)不生成它(提供web服务的实现逻辑)至少它在我的测试平台中以这种方式工作 – posthumecaver
您的解释不明确,但我已经更新了答案,希望它有帮助,让我知道如果它仍然没有帮助 – gnanagurus
不幸的是,我的用例更奇怪,你做内部调用Web服务的假设没有任何意义,但我想,当我从servlet端点接收到调用并且路由到web服务端点时,我仍然希望检查wsdl符合性,另外我在调用时还有一些web服务器头文件,他们也应该在Web服务端点进行解释,因此我需要一个内部Web服务终点 – posthumecaver