Reputation: 1853
I am experiencing an interesting dilemma with Apache Camel and CXF.
I try to build following routes.
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");`
My wish actually is to receive the request with Servlet Component, do something with (processor, transform, etc but I excluded here for simplicity reasons) redirect this to my WebService implementation and the file component return the content of a file as a result to WebService.
The problem is, if I make from Endpoint 'from("servlet://proxy?matchOnUriPrefix=true")
' routing to Endpoint 'to("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
' Camel thinks this should be CXF Consumer but I want it to be a Producer.
So I actually I like to route from from("servlet://proxy?matchOnUriPrefix=true")
to 'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
' but I could not figure out a way to do it.
If I configure as the first configuration, the servlet component receives the request, routes to CXF:consumer then it starts a TCP call to CXF:Producer defined in 'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
' it works but it is weird, I don't want to start a TCP call, I just want that the message goes to 'from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
'.
Is there a way to achieve what I want? Can I define a CXF Consumer or Provider other then using 'from', 'to'?
Funnily I did something similar with ServiceMix/Fuse.
<?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>
Which works as expected but there I could define the endpoint explicitly as CXF provider, do I have the same possibility here?
Upvotes: 0
Views: 580
Reputation: 903
If I understand your problem right, this will work (and ideal solution in camel)
Route A
from("servlet://proxy?matchOnUriPrefix=true")
.to("direct:webservice-business-logic")
.to("direct:process-to-file");
Route B
from("direct:webservice-business-logic")
.to("actual-processors-to-do-webservice-business-logic");
Route C
from("cxf:/incident?wsdlURL=wsdl/OrderInfoService.wsdl&dataFormat=MESSAGE")
.to("direct:webservice-business-logic);
Basically, Route C will be used only by external parties who wants to use the webservice.
Route B will be used only by Route A, So Route B is meant for Internal camel processing. Because there is no point in calling a webservice , where the webservice logic also sits in the camel route.
Hope this helps !
Upvotes: 0