After many, many, too many attempts, finally I have understood how to expose external webservice, that is how to proxy one or more webservices (wsdl included). (servicemix.xml file is attached)
Suppose I have two webservice to proxy at urls http://pc-webservice:8080/axis/services/AxisWebservice http://pc-webservice2:8080/xfire/services/XFireWebservice 1) I have to connect the wsdl and the remote webservices to the endpoints (providers) <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="ns1:AxisWebservice" role="provider" locationURI="http://pc-webservice:8080/axis/services/AxisWebservice" wsdlResource="http://pc-webservice:8080/axis/services/AxisWebservice?wsdl" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="ns2:XFireWebservice" role="provider" locationURI="http://pc-webservice2:8080/xfire/services/XFireWebservice" wsdlResource="http://pc-webservice2:8080/xfire/services/XFireWebservice?wsdl" /> 1) I have to make a connector for riceiving requests form clients (consumers). I used http-component to make this: <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="myns:routerForAxis" role="consumer" soap="true" targetInterfaceName="ns1:AxisWebservicePortType" locationURI="http://localhost:8080/services/AxisService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="myns:routerForXFire" role="consumer" soap="true" targetInterfaceName="ns1:XFireWebserviceSEI" locationURI="http://172.30.10.183:8888/services/XFireService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> 3) I have to create an invoker for the webservice <sm:activationSpec componentName="axisServiceComponent" service="myns:targetForAxis" endpoint="axisService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice:8080/axis/services/AxisWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="xfireServiceComponent" service="myns:targetForXFire" endpoint="xfireService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice2:8080/xfire/services/XFireWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> 4) Now let's create a service for redirecting the request, for example the wireTrap router. <sm:activationSpec componentName="wireTrapAxis"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapAxisEndpoint" service="myns:axisWireTrap"> <eip:target> <eip:exchange-target service="myns:targetForAxis" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="wireTrapXFire"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapXFireEndpoint" service="myns:xfireWireTrap"> <eip:target> <eip:exchange-target service="myns:targetForXFire" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> The myns:trace service is simply a logger components that log messages 5) The chain is finished now we have the two external webservices exposed at urls http://localhost:8080/services/AxisService/ http://localhost:8080/services/XFireService/ and their wsdl http://localhost:8080/services/AxisService?wsdl http://localhost:8080/services/XFireService?wsdl 6) complete listing of servicemix.xml and some explanation <!-- Namespaces of the webservices wsdl must match the local namespaces of the servicemix local services. Take a look at the ns1 and ns2 namespaces. You can retrieve this namespaces from the first line of the wsdl document as attribute of the root tag definitions. <definitions name="AxisWebservice" targetNamespace="http://axis.webservice.namespace"> The myns namespace is a user choosen namespace for dividing external service from servicemix internal services --> <beans xmlns:sm="http://servicemix.apache.org/config/1.0" xmlns:eip="http://servicemix.apache.org/eip/1.0" xmlns:http="http://servicemix.apache.org/http/1.0" xmlns:ns1="http://axis.webservice.namespace" xmlns:ns2="http://xfire.webservice.namespace" xmlns:myns="http://myNameSpace/servicemix/1.0"> <!-- the JBI container --> <sm:container id="jbi" useMBeanServer="true" createMBeanServer="true" dumpStats="true" statsInterval="10"> <sm:activationSpecs> <sm:activationSpec componentName="provider"> <sm:component> <http:component> <http:endpoints> <!-- REMEBER: Namespaces of the webservices wsdl must match the local namespaces of the servicemix local services. You can retrieve this namespace from the first line of the wsdl document as attribute of the root tag definitions. <definitions name="AxisWebservice" targetNamespace="http://axis.webservice.namespace"> The name of the local servicemix service and targetService (service="ns1:AxisWebservice" targetService="ns1:AxisWebservice") must match the name of the webservice. This information is in the wsdl too, as attribute of tag <service name="AxisWebservice"> (at the end of wsdl) The endpoint name (endpoint="axisWebserviceEP") is a your choice. The role must be provider (role="provider") The wsdlResource must point to the wsdl definition (wsdlResource="http://pc-webservice:8080/axis/services/AxisWebservice?wsdl") The locationURI is the address where the webservice is listening. (locationURI="http://pc-webservice:8080/axis/services/AxisWebservice") Also this can be retrieved from wsdl as attribute of tag <wsdlsoap:address location="http://pc-webservice:8080/axis/services/AxisWebservice"/> at the end of wsdl --> <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="ns1:AxisWebservice" role="provider" locationURI="http://pc-webservice:8080/axis/services/AxisWebservice" wsdlResource="http://pc-webservice:8080/axis/services/AxisWebservice?wsdl" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="ns2:XFireWebservice" role="provider" locationURI="http://pc-webservice2:8080/xfire/services/XFireWebservice" wsdlResource="http://pc-webservice2:8080/xfire/services/XFireWebservice?wsdl" /> </http:endpoints> </http:component> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="consumer"> <sm:component> <http:component> <http:endpoints> <!-- The name of the local servicemix service and endpoint must match the linked provider http:endpoint (service="ns1:AxisWebservice" endpoint="axisWebserviceEP") The role must be consumer (role="consumer") The soap attribute must be true for compliant wsdl (soap="true") The locationURI is the address where servicemix must expose the webservice. (locationURI="http://localhost:8080/services/AxisService/") The targetInterface name is the name of the interface to expose. You can retrieve this from wsdl as attribute of tag <portType name="AxisWebservicePortType"> in the middle of wsdl. The defaultMep attribute is for specifying if the endpoint is for in-out (wait for response) (defaultMep="http://www.w3.org/2004/08/wsdl/in-out") The targetService is the servicemix local service to forwarding received message (targetService="myns:routerForAxis") --> <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="myns:routerForAxis" role="consumer" soap="true" targetInterfaceName="ns1:AxisWebservicePortType" locationURI="http://localhost:8080/services/AxisService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="myns:routerForXFire" role="consumer" soap="true" targetInterfaceName="ns1:XFireWebserviceSEI" locationURI="http://172.30.10.183:8888/services/XFireService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> </http:endpoints> </http:component> </sm:component> </sm:activationSpec> <!-- This component invokes the remote service. The soapAction property is the default soapAction. Without this property set no SOAPAction header is addes and some webservices providers (like Axis) could not work --> <sm:activationSpec componentName="axisServiceComponent" service="myns:targetForAxis" endpoint="axisService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice:8080/axis/services/AxisWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="xfireServiceComponent" service="myns:targetForXFire" endpoint="xfireService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice2:8080/xfire/services/XFireWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> <!-- This is a simple trace component to log messages routed here --> <sm:activationSpec componentName="trace" service="int:trace"> <sm:component> <bean xmlns="http://xbean.org/schemas/spring/1.0" class="org.apache.servicemix.components.util.TraceComponent" /> </sm:component> </sm:activationSpec> <!-- The routing services --> <sm:activationSpec componentName="wireTrapAxis"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapAxisEndpoint" service="myns:routerForAxis"> <eip:target> <eip:exchange-target service="myns:targetForAxis" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="wireTrapXFire"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapXFireEndpoint" service="myns:routerForXFire"> <eip:target> <eip:exchange-target service="myns:targetForXFire" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> </sm:activationSpecs> </sm:container> </beans>
<!-- Namespaces of the webservices wsdl must match the local namespaces of the servicemix local services. Take a look at the ns1 and ns2 namespaces. You can retrieve this namespaces from the first line of the wsdl document as attribute of the root tag definitions. <definitions name="AxisWebservice" targetNamespace="http://axis.webservice.namespace"> The myns namespace is a user choosen namespace for dividing external service from servicemix internal services --> <beans xmlns:sm="http://servicemix.apache.org/config/1.0" xmlns:eip="http://servicemix.apache.org/eip/1.0" xmlns:http="http://servicemix.apache.org/http/1.0" xmlns:ns1="http://axis.webservice.namespace" xmlns:ns2="http://xfire.webservice.namespace" xmlns:myns="http://myNameSpace/servicemix/1.0"> <!-- the JBI container --> <sm:container id="jbi" useMBeanServer="true" createMBeanServer="true" dumpStats="true" statsInterval="10"> <sm:activationSpecs> <sm:activationSpec componentName="provider"> <sm:component> <http:component> <http:endpoints> <!-- REMEBER: Namespaces of the webservices wsdl must match the local namespaces of the servicemix local services. You can retrieve this namespace from the first line of the wsdl document as attribute of the root tag definitions. <definitions name="AxisWebservice" targetNamespace="http://axis.webservice.namespace"> The name of the local servicemix service and targetService (service="ns1:AxisWebservice" targetService="ns1:AxisWebservice") must match the name of the webservice. This information is in the wsdl too, as attribute of tag <service name="AxisWebservice"> (at the end of wsdl) The endpoint name (endpoint="axisWebserviceEP") is a your choice. The role must be provider (role="provider") The wsdlResource must point to the wsdl definition (wsdlResource="http://pc-webservice:8080/axis/services/AxisWebservice?wsdl") The locationURI is the address where the webservice is listening. (locationURI="http://pc-webservice:8080/axis/services/AxisWebservice") Also this can be retrieved from wsdl as attribute of tag <wsdlsoap:address location="http://pc-webservice:8080/axis/services/AxisWebservice"/> at the end of wsdl --> <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="ns1:AxisWebservice" role="provider" locationURI="http://pc-webservice:8080/axis/services/AxisWebservice" wsdlResource="http://pc-webservice:8080/axis/services/AxisWebservice?wsdl" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="ns2:XFireWebservice" role="provider" locationURI="http://pc-webservice2:8080/xfire/services/XFireWebservice" wsdlResource="http://pc-webservice2:8080/xfire/services/XFireWebservice?wsdl" /> </http:endpoints> </http:component> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="consumer"> <sm:component> <http:component> <http:endpoints> <!-- The name of the local servicemix service and endpoint must match the linked provider http:endpoint (service="ns1:AxisWebservice" endpoint="axisWebserviceEP") The role must be consumer (role="consumer") The soap attribute must be true for compliant wsdl (soap="true") The locationURI is the address where servicemix must expose the webservice. (locationURI="http://localhost:8080/services/AxisService/") The targetInterface name is the name of the interface to expose. You can retrieve this from wsdl as attribute of tag <portType name="AxisWebservicePortType"> in the middle of wsdl. The defaultMep attribute is for specifying if the endpoint is for in-out (wait for response) (defaultMep="http://www.w3.org/2004/08/wsdl/in-out") The targetService is the servicemix local service to forwarding received message (targetService="myns:routerForAxis") --> <http:endpoint service="ns1:AxisWebservice" endpoint="axisWebserviceEP" targetService="myns:routerForAxis" role="consumer" soap="true" targetInterfaceName="ns1:AxisWebservicePortType" locationURI="http://localhost:8080/services/AxisService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> <http:endpoint service="ns2:XFireWebservice" endpoint="xfireWebserviceEP" targetService="myns:routerForXFire" role="consumer" soap="true" targetInterfaceName="ns1:XFireWebserviceSEI" locationURI="http://172.30.10.183:8888/services/XFireService/" defaultMep="http://www.w3.org/2004/08/wsdl/in-out" /> </http:endpoints> </http:component> </sm:component> </sm:activationSpec> <!-- This component invokes the remote service. The soapAction property is the default soapAction. Without this property set no SOAPAction header is addes and some webservices providers (like Axis) could not work --> <sm:activationSpec componentName="axisServiceComponent" service="myns:targetForAxis" endpoint="axisService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice:8080/axis/services/AxisWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="xfireServiceComponent" service="myns:targetForXFire" endpoint="xfireService"> <sm:component> <bean class="org.apache.servicemix.components.saaj.SaajBinding"> <property name="soapAction" value="" /> <property name="soapEndpoint"> <bean class="javax.xml.messaging.URLEndpoint"> <constructor-arg value="http://pc-webservice2:8080/xfire/services/XFireWebservice" /> </bean> </property> </bean> </sm:component> </sm:activationSpec> <!-- This is a simple trace component to log messages routed here --> <sm:activationSpec componentName="trace" service="int:trace"> <sm:component> <bean xmlns="http://xbean.org/schemas/spring/1.0" class="org.apache.servicemix.components.util.TraceComponent" /> </sm:component> </sm:activationSpec> <!-- The routing services --> <sm:activationSpec componentName="wireTrapAxis"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapAxisEndpoint" service="myns:routerForAxis"> <eip:target> <eip:exchange-target service="myns:targetForAxis" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> <sm:activationSpec componentName="wireTrapXFire"> <sm:component> <eip:component> <eip:endpoints> <eip:wire-tap endpoint="wireTrapXFireEndpoint" service="myns:routerForXFire"> <eip:target> <eip:exchange-target service="myns:targetForXFire" /> </eip:target> <eip:outListener> <eip:exchange-target service="myns:trace" /> </eip:outListener> </eip:wire-tap> </eip:endpoints> </eip:component> </sm:component> </sm:activationSpec> </sm:activationSpecs> </sm:container> </beans>
