How to deploy a Service Assembly, developed in ServiceMix, in other JBI container, concretely in Open-ESB

Goals

The goal of this tutorial is to know how ServiceMix and Open-ESB are compliant with JBI, and the way of make this is, developing a Service Assembly in ServiceMix and deploying it in Open ESB.

Pre-Requisites

For this tutorial is necessary to have installed correctly ServiceMix 3.1 and Open ESB Starter Kit.

Developed of Service Assembly (SA)

The firts step is created a SA in ServiceMix.

The SA of the example exposes a external web services in the ESB, it's to say, we can access to external web services throw ESB. It's a simple example that it have the advantage that, if we have some clients using the external web services throw the ESB, and in sometime the web services's address change, we don't have to change all client configurations, but only in Binding Component conexion configuration.

Structure of wsexample-sa.zip:

Structure of wsexample-su.zip:

The jbi.xml file is necessary for Open ESB, but it isn't necessary for ServiceMix.

jbi.xml of SA:

<?xml version="1.0" encoding="UTF-8"?>
<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
  <service-assembly>
    <identification>
      <name>wsexample-sa</name>
      <description>Example of WS</description>
    </identification>
    <service-unit>
      <identification>
        <name>wsexample-su</name>
        <description>Contains the http components</description>
      </identification>
      <target>
        <artifacts-zip>wsexample-su.zip</artifacts-zip>
        <component-name>servicemix-http</component-name>
      </target>
    </service-unit>
  </service-assembly>
</jbi>

jbi.xml of SU:

<?xml version="1.0" encoding="UTF-8"?>
<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
  <services binding-component="true" xmlns:firma="http://servidor.webservice.esb">
    <consumes interface-name="firma:InterfazVerificarFirma"/>
  </services>
</jbi>

xbean.xml of SU:

<?xml version="1.0"?>
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
       xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:firma="http://servidor.webservice.esb">

  <!-- PROVIDER -->
  <http:endpoint service="firma:ServicioVerificarFirmasService"
                 targetService="firma:ServicioVerificarFirmasService"
                 endpoint="endpointProviderFirma"
                 interfaceName="firma:InterfazVerificarFirma"
                 soapVersion="1.1"
                 soap="true"
                 role="provider"
                 locationURI="http://172.18.1.163:6080/suplantacion@firma/services/ServicioVerificarFirmas"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                 wsdlResource="http://172.18.1.163:6080/suplantacion@firma/services/ServicioVerificarFirmas?wsdl" />

  <!-- CONSUMER -->
  <http:endpoint service="firma:ServicioVerificarFirmasService"
                 endpoint="endpointConsumerFirma"
                 targetService="firma:ServicioVerificarFirmasService"
                 soapVersion="1.1"
                 interfaceName="firma:InterfazVerificarFirma"
                 soap="true"
                 role="consumer"
                 locationURI="http://0.0.0.0:8787/test/VerificarFirmas"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out" />

</beans>

We should change the specific options by us web services in the Provider section.

The namespace should be equal that wsdl definitions targetNamespace.

The provider service and targetService should be equal that wsdl service name.

The locationURI is the URL of the external web services, and wsdlResource is the URL of the external wsdl.

Pre-Requisites in Open ESB

Open ESB must be installed, i have used the Open ESB starter kit, the tooling for this runtime is provided through Netbeans Enterprise Pack which is part of Java EE SDK tools bundle.

The SU described aboved depends of servicemix-http Binding Component, and it as well depends of servicemix-shared, reason why we needs install this components before deploy the SA.

Preparing dependecies in Open ESB

First we will install servicemix-shared, because it's necessary for servicemix-http, the problem is that servicemix-share don't included all dependencies for servicemix-http and we should add more libraries.

Extract the content of servicemix-shared-3.1-incubating-SNAPSHOT-installer.zip, and in the lib directory should be the next libraries, if not we add them. We can find it in ServiceMix distribution:

Now it's necessary modify the jbi.xml file into META-INF directory of servicemix-shared-3.1-incubating-SNAPSHOT-installer.zip by add the news libraries:

<?xml version="1.0" encoding="UTF-8"?>
<jbi xmlns="http://java.sun.com/xml/ns/jbi" version="1.0">
  <shared-library class-loader-delegation="parent-first" version="3.1-incubating-SNAPSHOT">
    <identification>
      <name>servicemix-shared</name>
      <description>ServiceMix :: Shared</description>
    </identification>
    <shared-library-class-path>
      <path-element>lib/activemq-core-4.1-incubator-20061101.081006-35.jar</path-element>
      <path-element>lib/servicemix-core-3.1-incubating-SNAPSHOT.jar</path-element>
      <path-element>lib/xbean-classloader-2.7.jar</path-element>
      <path-element>lib/backport-util-concurrent-2.2.jar</path-element>
      <path-element>lib/servicemix-services-3.1-incubating-SNAPSHOT.jar</path-element>
      <path-element>lib/xbean-kernel-2.7.jar</path-element>
      <path-element>lib/bcprov-jdk14-124.jar</path-element>
      <path-element>lib/servicemix-shared-3.1-incubating-SNAPSHOT.jar</path-element>
      <path-element>lib/xbean-server-2.7.jar</path-element>
      <path-element>lib/commons-logging-1.0.4.jar</path-element>
      <path-element>lib/servicemix-soap-3.1-incubating-SNAPSHOT.jar</path-element>
      <path-element>lib/xbean-spring-2.7.jar</path-element>
      <path-element>lib/jetty-util-6.0.1.jar</path-element>
      <path-element>lib/spring-2.0.jar</path-element>
      <path-element>lib/xmlsec-1.3.0.jar</path-element>
      <path-element>lib/opensaml-1.1.jar</path-element>
      <path-element>lib/wsdl4j-1.5.1.jar</path-element>
      <path-element>lib/servicemix-common-3.1-incubating-SNAPSHOT.jar</path-element>
      <path-element>lib/wss4j-1.5.0.jar</path-element>
    </shared-library-class-path>
  </shared-library>
</jbi>

Now that i have the servicemix-shared prepared, we need to package it in a .jar file, by make this it's necessary to used the jar tool provided by Java SDK by this way:

jar cvf servicemix-shared-3.1-incubating-SNAPSHOT-installer.jar -C servicemix-shared-3.1-incubating-SNAPSHOT-installer.zip_FILES/ .

By the same method we package the servicemix-http component:

jar cvf servicemix-http-3.1-incubating-SNAPSHOT-installer.jar -C servicemix-http-3.1-incubating-SNAPSHOT-installer.zip_FILES/ .

Install dependencies in Open ESB

First we install servicemix-shared in Shared Libraries, click-right install New Shared Library. Second we install servicemix-http in Binding Components, click-right install New Binding Component.

At the moment, if no errors, we have installed the ServiceMix-HTTP Binding Component in Open ESB, because it's compliant with JBI and it can be installed in any JBI conatiner.

Deploying the Service Assembly in Open ESB

Now we can deploy the SA in Open ESB, by this click-right on Service Assemblies, Deploy New Service Assembly.

Notice that the image names for SA and SU are differents with the theory

Now, if no errors, we go to http://localhost:8787 and find the web services address.

  • No labels