4 Replies Latest reply on Mar 29, 2011 9:03 AM by manta7

    Exposing a web service

    manta7

      Hello,

       

      I know this is a common problem but i didn't find the solution on this problem..

       

      I have create a web service with axis2/tomcat on this address: http://localhost:8080/axis2/services/HelloService2?wsdl

       

      And I would like to expose it through my ESB (for a centralized exposition of all my services).

      So I have create a SA project, and a servicemix-cxf-bc. Into the BC directory I have put my WSDL and I configured my xbean like that :

       

      <beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"

             xmlns:HelloService2="http://hello.registry.test">

       

            <cxfbc:consumer wsdl="classpath:HelloService2.wsdl"

                            targetService="HelloService2:HelloService2"

                            targetInterface="HelloService2:HelloService2PortType"/>

       

      </beans>

       

      I thought it was the good solution but when I'm trying to reach my tomcat address (http://localhost:8080), it's replaced by Apache CFX that list my "known services" which contains my HelloService2. Also when I'm trying to make a soap request on this service, it necessarily don't works.

       

      So ok, it's not the good solution, but do I have to write a cxfbc:provider tag on my xbean also ? I don't think so cause I just want to expose an external service, external in the sense of providing by an another system (Axis 2) but on the same machine.

       

      Need help !

        • 1. Re: Exposing a web service
          ffang

          Hi,

           

          You do need a cxfbc:provider in this case.

           

          The workflow is

           

          external client ====>cxfbc:consumer====> cxfbc:provider====>external service(axis server in your case)

           

          cxfbc:consumer will start a listening port and play the server side role, cxf bc:provider play the client side role.

           

          Here cxfbc:consumer====> cxfbc:provider just like a bridge,  we actually have a testcase[1] which can demonstrate how this bridge works.

           

          Btw, you need ensure your axis server not use rpc/encoded style as that style is quite old and not supported by cxf.

           

          https://svn.apache.org/repos/asf/servicemix/components/trunk/bindings/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderConsumerTest.java

           

           

          Freeman

          • 2. Re: Exposing a web service
            manta7

            Ok ok, thanks for the answer! I understand..

             

            I wrote that:

             

            <beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"

                   xmlns:HelloService2="http://hello.registry.test">

             

                <cxfbc:consumer wsdl="classpath:HelloService2.wsdl"

                                  targetService="HelloService2:HelloService2"

                                  targetInterface="HelloService2:HelloService2PortType"/>

            +                         + 

            +     <cxfbc:provider wsdl="classpath:HelloService2.wsdl"+

                                  locationURI="http://localhost:8092/HelloService2"

                                  service="HelloService2:HelloService2"

                                  endpoint="HelloService2PortProxy"

                                  interfaceName="HelloService2:HelloService2PortType"/>

             

            </beans>

             

            With a consumer and a provider. But I still have a problem.

             

            You said "cxfbc:consumer will start a listening port", indeed, when I'm going on http://localhost:8080 I fall on CFX (no more on Tomcat), as if it erase my previous listening port. So how can I change the listening port of my consumer ?

            • 3. Re: Exposing a web service
              ffang

              Hi,

               

              In cxfbc:consumer, you can specify locationURI using any port you want, this is the webservice url you exposed for external client.

              And in cxfbc:provider,  you can specify another locationURI which should be the same as the one used for your axis server, so that cxfbc:provider can talk to your server.

               

              Freeman

              • 4. Re: Exposing a web service
                manta7

                Great, it works!

                 

                We can find more information here: http://servicemix.apache.org/servicemix-cxf-bc.html

                 

                Thanks again