Hi,
after a lot of test I learnt how to expose an external web service through
http-component.

Suppose you have a web service with this wsdl :

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://localhost:8080/helloworldws/services/HelloWorldService";
xmlns="http://schemas.xmlsoap.org/wsdl/";
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:impl="http://localhost:8080/helloworldws/services/HelloWorldService";
xmlns:intf="http://localhost:8080/helloworldws/services/HelloWorldService";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<wsdl:types/>
  <wsdl:message name="echoResponse">
    <wsdl:part name="echoReturn" type="xsd:string"/>
  </wsdl:message>
  <wsdl:message name="echoRequest">
  </wsdl:message>
  <wsdl:portType name="HelloWorldService">
    <wsdl:operation name="echo">
      <wsdl:input message="impl:echoRequest" name="echoRequest"/>
      <wsdl:output message="impl:echoResponse" name="echoResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="HelloWorldServiceSoapBinding"
type="impl:HelloWorldService">
    <wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="echo">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="echoRequest">
        <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://localhost:8080/helloworldws/services/HelloWorldService";
use="encoded"/>
      </wsdl:input>
      <wsdl:output name="echoResponse">
        <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://localhost:8080/helloworldws/services/HelloWorldService";
use="encoded"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="HelloWorldServiceService">
    <wsdl:port binding="impl:HelloWorldServiceSoapBinding"
name="HelloWorldService">
      <wsdlsoap:address
location="http://localhost:8080/helloworldws/services/HelloWorldService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Then you have to define an http-component provider with this xbean.xml :

<?xml version="1.0" encoding="UTF-8"?>
<beans
        xmlns:http="http://servicemix.apache.org/http/1.0";
       
xmlns:ns1="http://localhost:8080/helloworldws/services/HelloWorldService";
>
<http:endpoint
        service="ns1:HelloWorldServiceService"
        endpoint="HelloWorldService"
        role="provider"
       
locationURI="http://localhost:8080/helloworldws/services/HelloWorldService";
       
wsdlResource="http://localhost:8080/helloworldws/services/HelloWorldService?wsdl";
/>
</beans>

where
- ns1 : must match namespaces in wsdl
- service : must match value of attribute name of element wsdl:service in
wsdl
  <wsdl:service name="HelloWorldServiceService">
- endpoint : must match value of attribute name of element wsdl:port
    <wsdl:port binding="impl:HelloWorldServiceSoapBinding"
name="HelloWorldService">

Now you have to define http-component consumer with this xbean.xml :

<?xml version="1.0" encoding="UTF-8"?>
<beans
        xmlns:http="http://servicemix.apache.org/http/1.0";
       
xmlns:ns1="http://localhost:8080/helloworldws/services/HelloWorldService";
>
<http:endpoint
        service="ns1:HelloWorldServiceConsumer"
        endpoint="HelloWorldEndpointConsumer"
        role="consumer"
        targetService="ns1:HelloWorldServiceService"
        locationURI="http://localhost:8192/services/HelloWorldService/";
        defaultMep="http://www.w3.org/2004/08/wsdl/in-out";
/>
</beans>

where
- ns1 : must match namespaces in wsdl
- targetService : must match service value in xbean.xml of provider
<http:endpoint
        service="ns1:HelloWorldServiceService"
        endpoint="HelloWorldService"
        role="provider"

And this is the jbi.xml of Service Assembly :
<?xml version="1.0" encoding="UTF-8"?>
<jbi xmlns="http://java.sun.com/xml/ns/jbi"; version="1.0">
  <service-assembly>
    <identification>
      <name>helloworld-sa</name>
      <description>Codices :: HelloWorld :: SA</description>
    </identification>
    <service-unit>
      <identification>
        <name>http-su-provider</name>
        <description>Http BC provider</description>
      </identification>
      <target>
        <artifacts-zip>http-su-provider.zip</artifacts-zip>
        <component-name>servicemix-http</component-name>
      </target>
    </service-unit>
    <service-unit>
      <identification>
        <name>http-su-consumer</name>
        <description>Http BC consumer</description>
      </identification>
      <target>
        <artifacts-zip>http-su-consumer.zip</artifacts-zip>
        <component-name>servicemix-http</component-name>
      </target>
    </service-unit>
  </service-assembly>
</jbi>

That's all folks

This is the source  http://www.nabble.com/file/5642/helloworld-sa.zip
helloworld-sa.zip 

Massimo
-- 
View this message in context: 
http://www.nabble.com/Expose-external-web-service-with-http-component-%28very-simplified%29-tf3014055s12049.html#a8370000
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to