web-servicesosgicxfequinoxdosgi

how to expose and consume webservices from an Equinox OSGi application?


I need to develop an OSGi application with clear back-end front-end separation hopefully done using JAX-WS. The google results points to Apache-CXF which supports JAX-WS. The back-end and the front-end of the application will be run in two JVMs with separate Equinox OSGi containers. Is there a standard way to integrate Apache-CXF with Equinox? Will this need a servlet container like Tomcat or Jetty embedded in Equinox as well? Or is there a more convenient proven to work method to do this?


Solution

  • The simplest and best proven way to use CXF in OSGi is with Apache Karaf. It is an OSGi server based on Equinox or Felix and is optimized for integration with several Apache frameworks like CXF, Camel, ActiveMQ.

    If you want to use plain Equinox then the DOSGi distro mentioned above is a good starting point. It contains all bundles needed to run Distributed OSGi based on CXF. This means it is also suitable for most CXF JA-XWS use cases.

    In Karaf on the other hand you get a much better integration with all the CXF modules. It is also much better tested as it is used for Servicemix and several commercial solutions e.g. from Redhat and Talend where I work.

    For your special case Distributed OSGi itself may also be a very good option. It means that you do not directly provide/consume CXF services. Instead you publish and consume OSGi services and CXF takes care of the remoting.

    I have written a tutorial series that shows how to use CXF with Apache karaf: