10 Replies Latest reply on Jun 10, 2012 8:50 PM by Freeman(Yue) Fang

    Axis 2 integration

    Robert Kozura Newbie

      Hello,

       

      I am trying to use axis2 in a RESTful web service.  The osgi bundle fails to deploy:

       

      karaf@root> ERROR: Error starting proxy-1.0.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle : Unable to resolve 187.0: missing requirement package; (&(package=javax.xml.namespace(version>=1.0.0)))

       

      Here is the axis2 dependency in my pom file:

       

       

      <dependency>

         <groupId>org.apache.axis2</groupId>

         <artifactId>org.apache.axis2.osgi</artifactId>

         <version>1.5.3</version>

         <type>bundle</type>

      </dependency>

       

      And here is the MANIFEST file for the OSGI bundle:

       

      Manifest-Version: 1.0

      Export-Package: uses:="org.apache.axis2,or

      g.apache.axis2.databinding.types,org.apache.axis2.context,org.apache.

      cxf.message,org.apache.cxf.interceptor,org.apache.cxf.phase,org.apach

      e.commons.httpclient.methods,javax.ws.rs,org.apache.cxf.jaxrs.impl,or

      g.apache.commons.httpclient,javax.ws.rs.core"

      Built-By: rkozura

      Tool: Bnd-0.0.357

      Bundle-Name: Service

      Created-By: Apache Maven Bundle Plugin

      Require-Bundle: org.apache.cxf.bundle

      Bundle-Vendor: The Apache Software Foundation

      DynamicImport-Package: javax.ws.rs.*

      Build-Jdk: 1.6.0_23

      Bundle-Version: 1.0.0

      Bnd-LastModified: 1296757373785

      Bundle-ManifestVersion: 2

      Bundle-Description: This pom provides project information that is comm

      on to all ServiceMix branches.

      Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt

      Bundle-SymbolicName: proxy

      Bundle-DocURL: http://www.apache.org/

      Import-Package: META-INF.cxf,META-INF.cxf.osgi,javax.net.ssl,javax.ws.rs;version="1.0",javax.ws.rs.core;version

      ="1.0",javax.wsdl,javax.xml.bind,javax.xml.bind.annotation,javax.xml.

      namespace;version="1.0",javax.xml.stream;version="1.0",org.apache.axi

      om.om,org.apache.axiom.om.impl.llom,org.apache.axiom.soap,org.apache.

      axis2;version="1.5",org.apache.axis2.addressing;version="1.5",org.apa

      che.axis2.client;version="1.5",org.apache.axis2.context;version="1.5"

      ,org.apache.axis2.databinding;version="1.5",org.apache.axis2.databind

      ing.types;version="1.5",org.apache.axis2.databinding.utils;version="1

      .5",org.apache.axis2.databinding.utils.reader;version="1.5",org.apach

      e.axis2.databinding.utils.writer;version="1.5",org.apache.axis2.descr

      iption;version="1.5",org.apache.axis2.transport;version="1.5",org.apa

      che.commons.httpclient,org.apache.commons.httpclient.methods,org.apac

      he.commons.httpclient.params,org.apache.commons.httpclient.protocol,o

      rg.apache.cxf.binding,org.apache.cxf.bus,org.apache.cxf.bus.resource,

      org.apache.cxf.bus.spring,org.apache.cxf.configuration.spring,org.apa

      che.cxf.interceptor,org.apache.cxf.jaxrs.impl,org.apache.cxf.jaxrs.ut

      ils,org.apache.cxf.message,org.apache.cxf.phase,org.apache.cxf.resour

      ce,org.apache.cxf.transport.http_osgi

       

      If I change the javax.xml.naming version to 0.0.0, there is an unresolved exception with org.apache.axis2 now.

       

      Anyone have any idea why this is happening?  Anyone use Axis2 with the FUSE ESB?

       

      Has anyone used Axis2 in OSGI bundles who can help me out?

        • 1. Re: Axis 2 integration
          Gert Vanthienen Novice

          L.S.,

           

           

          Not sure where/how you got that Axis OSGi bundle, but if I install that bundle, it does not have the javax.xml.namespace version (it says javax.xml.namespace;version=0.0.0 instead) and does not have all the CXF imports either.

           

          And now that we're talking about CXF: What use case do you have for Axis2 that CXF wouldn't solve?  We pre-integrated CXF to help you solve all WS-* and RESTful services problem, so we'd definitely be interested to learn about the scenarios we need to add support for.

           

           

          Regards,

           

          Gert

          • 2. Re: Axis 2 integration
            Robert Kozura Newbie

            I may be a bit confused.  Here is what I am trying to do in a nutshell:

             

            - Create a RESTful web service that does some tedious operation

            - Intercept that RESTful request

            - Once intercepted, use SOAP to connect to a web service

            - Depending on the SOAP response, continue with the message path or not

             

            I took your advice and went away from Axis2.  Axis 2 was used to create java code from a WSDL.

             

            I am now using cxf's wsdl2java plugin to great effect, but something is wrong...I can't seem to use the SOAP client within a RESTful code block.

             

            Here is what I have been using for a reference of sorts:

             

            http://logicsector.wordpress.com/2008/10/19/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/

             

             

            Any advice would be greatly appreciated.

            • 3. Re: Axis 2 integration
              Gert Vanthienen Novice

              L.S.,

               

              Those all look like good use cases for CXF to me, so at least that's a good start.

               

              Have you tried invoking the webservice client from a simple Java program or a unit test to see if the generated client works for you there?  What's the exception you're seeing when you try to use the client from within you RESTful service code?

               

              Regards,

               

              Gert

               

              Edited by: gertv on Feb 8, 2011 2:06 PM

              • 4. Re: Axis 2 integration
                Robert Kozura Newbie

                Thank you so much for helping me.  I am able to run the standalone client created by the wsdl2java plugin.  Here is what I have constructed so far to make the client work inside a RESTful web service:

                 

                 

                - I created an InInterceptor in the beans.xml configuration file.  This allows me to intercept the message before reaching the RESTful endpoint.

                 

                <?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:jaxrs="http://cxf.apache.org/jaxrs"*

                *     xmlns:cxf="http://cxf.apache.org/core"*

                    xmlns:osgi="http://www.springframework.org/schema/osgi"

                *     xsi:schemaLocation="*

                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

                http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd

                http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd

                http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd

                http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">

                    <import resource="classpath:META-INF/cxf/cxf.xml" />

                    <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />

                    <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />

                    <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

                *     *

                *     *

                    <jaxrs:server id="Apps" address="/" >

                        <jaxrs:serviceBeans>

                            <ref bean="proxyWebService"/>

                        </jaxrs:serviceBeans>

                    </jaxrs:server>

                     

                    <bean id="interceptor" class="com.company.Interceptor"/>

                     

                *     *

                 

                    <bean id="proxyWebService" class="com.company.Proxy"/>

                 

                </beans>

                 

                - When I deployed the OSGI bundle on the ESB, I was getting an exception like: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered.  In order to fix this, I had to add <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

                 

                - Something to note, when I followed the steps per http://logicsector.wordpress.com/2008/10/19/how-to-create-a-wsdl-first-soap-client-in-java-with-cxf-and-maven/ to fix the problem, the REST web service would deploy, but will it would not be visible on the ESB for some reason, maybe because the OSGi container could not decide what type of service it was.  I had to only add the cxf-extension-soap.xml import statement and not the others.

                 

                - Another problem I had was after the code ran the SOAP client, the InInterceptor was catching the request or response for some reason, resulting in an infinite loop.  To fix this issue, I tried to find a discrepancy in the true REST message and the SOAP client message.  The difference was the Message.PATH_INFO being null for the SOAP client message.  So I simply added an if statement to check for it.

                 

                I wish there was a more elegant way to handle this...

                 

                Edited by: rkozura on Feb 8, 2011 6:43 PM

                 

                Edited by: rkozura on Feb 8, 2011 8:12 PM

                • 5. Re: Axis 2 integration
                  Willem Jiang Master

                  Hi,

                   

                  You can set up the interceptor per endpoint instead of bus. In this way your CXF client will not be affected by the custom interceptor.

                   

                  Willem

                  • 6. Re: Axis 2 integration
                    Robert Kozura Newbie

                    Thanks!  Works like a charm!

                     

                     

                    • 7. Re: Axis 2 integration
                      racem smaoui Newbie

                      Hi,

                       

                      i tried invoking the webservice client from a simple Java program and it works but when i tried to use the client from within you RESTful service code i receive the following exception

                       

                       

                      20:20:36,744 | ERROR | ead #2 - myTimer | DefaultErrorHandler              | ?                                   ? | 89 - org.apache.camel.camel-core - 2.8.0.fuse-05-03 | Failed delivery for exchangeId: ID-PaymentServer-33385-1339183083120-1-15. Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: ]

                      org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: ]

                              at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1173)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:287)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:182)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.fabric.FabricTraceProcessor.process(FabricTraceProcessor.java:81)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:319)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:210)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:304)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.Pipeline.process(Pipeline.java:116)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.Pipeline.process(Pipeline.java:79)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:134)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:63)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at java.util.TimerThread.mainLoop(Timer.java:512)[:1.6.0_31]

                              at java.util.TimerThread.run(Timer.java:462)[:1.6.0_31]

                      Caused by: javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.cxf.jaxws.spi.ProviderImpl not found

                              at javax.xml.ws.spi.FactoryFinder$2.run(FactoryFinder.java:130)

                              at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:220)

                              at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:124)

                              at javax.xml.ws.spi.FactoryFinder.access$200(FactoryFinder.java:44)

                              at javax.xml.ws.spi.FactoryFinder$3.run(FactoryFinder.java:211)

                              at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:220)

                              at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:160)

                              at javax.xml.ws.spi.Provider.provider(Provider.java:43)

                              at javax.xml.ws.Service.(VersionService.java:52)[43:camel-bundle:0.0.1]

                              at com.ingenico.esb.camel.bundle.MyTransform.transform(MyTransform.java:25)[43:camel-bundle:0.0.1]

                              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_31]

                              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_31]

                              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_31]

                              at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_31]

                              at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:329)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:231)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:171)[89:org.apache.camel.camel-core:2.8.0.fuse-05-03]

                              ... 35 more

                       

                      can you help me?

                      • 8. Re: Axis 2 integration
                        racem smaoui Newbie

                        bellow my spring configuration maybe i have error in this configuration !!

                         

                         

                         

                            <property name="prefix" value="$"/>

                          </bean>

                        • 9. Re: Axis 2 integration
                          Gert Vanthienen Novice

                          L.S.,

                           

                          It rather looks like your problem is in the client code invoking the REST endpoint instead of in the XML for the routes.  Could you attach the code you have in your transform bean?  Also, could you do an osgi:headers  for this bundle/xml file as well and provide us with that output?

                           

                          Thanks,

                           

                          Gert Vanthienen

                          • 10. Re: Axis 2 integration
                            Freeman(Yue) Fang Master

                            Hi,

                             

                            First of all, I don't think your question here is related to this thread "Axis 2 integration", so you should create a new thread to ask your question if your question is about use CXF in FUSE ESB but has nothing to do with Axis, this is for a better track, and easily for other guys for search similar issues.

                             

                            Back to the exception you encounter, seems your customer bundle didn't import necessary cxf related packages. If you're new with FUSE ESB/CXF, the cxf-osgi example should be a good start for you.

                             

                            Freeman