Search code examples
web-serviceswebsphereosgicxfjax-ws

Websphere 8.5 + CXF in OSGi bundle. Is it possible?


I am writing a PoC for a design based on Websphere 8.5 and OSGi.

I need to get SOAP webservices running us as an OSGi bundle and consume OSGi services exposed by other OSGi bundles within the app.

I am stuck with trying to get JAX-WS service within OSGi bundle.

What I tried so far:

  1. Getting plain servlet running as an OSGi bundle (works)
  2. Getting JAX-RS service running as an OSGi bundle (works)
  3. Getting JAX-WS service running as an OSGi bundle using JAX-WS runtime provided by Websphere. This doesn't seem to work with exeptions thrown from the JAX-WS runtime
  4. Getting JAX-WS service running as an OSGi bundle disabling the Websphere provided JAX-WS runtime and trying to embedd CXF2 runtime withing the OSGi bundle. Doesn't work with exeptions thrown from JAXB (class conflicts of some sort).

Before I get too far explaining the exceptions and such. Has anybody had any joy getting JAX-WS service deployed as an OSGi bundle in Websphere 8.5? There are resources out there about doing this in Karaf, but I am restricted to Websphere.


Solution

  • To answer my own question,

    It seems to be the case that creating JAX-WS service from within an OSGi bundle is not supported in the same way as Servlets and REST services.

    Edit: The above statement is not true, please see the thread on WASDEV forum. The rest of this answer is still valid though for OSGi and SCA (though SCA's services seem to be implemented with Axis2 and not CXF)

    What is supported is exposing an OSGi service as a SOAP service using SCA.

    The rest of this answer assumes that:

    1. You have an OSGi application with one of the bundles exposing a service via blueprint.xml that you want to be exposed via SOAP.
    2. You have Eclipse IDE without SCA tools.
    3. You have Eclipse IDE with Websphere tools (giving you OSGi tooling)
    4. You have access to WAS console web app

    These are the steps required to get the service accessible via SOAP web service

    Preparing the OSGi application

    1. In the APPLICATION.MF of the OSGi application project, mark the service interface with Application-ExportService header: Application-ExportService: service.ExternalService
    2. In the blueprint.xml file of the OSGi bundle with the service, add the <entry key="service.exported.interfaces" value="*"/> property, for example:

    <service id="externalService" ref="externalServiceBean" interface="ccb.service.ExternalService"> <service-properties> <entry key="service.exported.interfaces" value="*"/> </service-properties> </service>

    1. Export the project as EBA

    Preparing The SCA artifact

    1. Create a Java project with the following structure

    /service.composite /META-INF/sca-contribution.xml

    1. The sca-contribution.xml can look like this:

    <?xml version="1.0" encoding="UTF-8"?> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"> <deployable xmlns:ns1="http://www.example.com" composite="ns1:ServiceComposite" /> </contribution>

    1. The service.composite can look like this:

      <?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:scafp="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06" targetNamespace="http://www.example.com" name="ServiceComposite"> <component name="ServiceComponent"> <scafp:implementation.osgiapp applicationSymbolicName="[Your OSGi Application name]" applicationVersion="1.0.0" /> <service name="[maching the ID of the service in the blueprint.xml]"> <binding.ws /> </service> </component> </composite>

    2. Export the project as jar

    Deploying the whole lot via WAS console

    1. Create new empty BLA

    Applications -> Application Types -> Business-level applications -> new

    1. Deploy both the EBA and the SCA jar as Assets

    Applications -> Application Types -> Assets -> Import

    1. Add first the EBA and then the SCA jar to Deployed assets of the Business level app

    Applications -> Application Types -> Business-level applications -> [Your app] -> Add (under 'Deployed assets')

    You are done! You should see the endpoint url in the server's logs

    Resources:

    http://ianrobinson.blogspot.co.uk/2010/05/osgi-and-sca-come-together-in-websphere.html

    http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.osgi.doc/ae/ca_sca.html