Service Oriented JBI: Invoking External Web Services from ServiceMix

4 min read

You can use XFire to create stub classes based on your WSDL exposed by your external web service. Now you can inject the stub into your JSR181 SU. The stub will be used by the proxy to generate the exchange with the HTTP provider (which should be referenced as the “service”).

Using JBI proxy now, it is possible to invoke web services in the RPC style from within the JBI bus. For this we leverage the stub classes generated out from the web service WSDL using Axis.

Web Service Code Listing

We are interested in proxy setup to access a remote web service, hence we will not discuss the details of the web service deployment in this section. Instead, we will just browse through the important web service interfaces and the associated WSDL and then move on to binding the proxy.

The web service implements the IHelloWeb remote interface which in turn extends the IHello business interface. They are listed here as follows:

  • IHello is a simple BI, having a single business method hello.
  • public interface IHello
    String hello(String param);

  • In order to deploy a web service, we need an interface complying with the Java RMI semantics, and IHelloWeb will serve this purpose.
  • public interface IHelloWeb extends IHello, java.rmi.Remote {}

  • HelloWebService.wsdl: The main sections in the web service WSDL is shown as follows:
  • <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://AxisEndToEnd." ...>
    <wsdl:types ... />
    <wsdl:message ... />
    <wsdl:portType name="IHelloWeb">
    <wsdl:binding name="HelloWebServiceSoapBinding"
    <wsdl:service name="IHelloWebService">
    <wsdl:port binding="impl:HelloWebServiceSoapBinding"

This is enough about the web service and we will move on to the next step.

Axis Generated Client Stubs

We use org.apache.axis.wsdl.WSDL2Java class in the wsdl2java task to generate client-side binding classes and stubs. The main classes are available in the folder ch13JbiProxy3_AccessExternalWebService1_wsgensrc and they are as follows:


All the above artifacts are Axis generated client-side stubs, hence we will not look into the details of them here. Instead, let us look into the structural relationship between the various developer created and Axis generated artifacts shown in the following figure:

Service Oriented Java Business Integration

Referring to the above diagram, let us understand the relevant artifacts. Here our aim is to generate a JBI proxy for an externally bound web service. We are doing this using the following classes:

  • This interface is synonymous to the BI IHello, having a single business method hello. We want to auto-route request-response through the JBI proxy. In order to facilitate this we have retained the method signature in the interfaces the same.

  • public interface ITarget
    String hello(String input);

  • In TargetService, we auto-wire the web service stub. So, the helloWeb instance field in TargetService will hold a reference to the stub to the web service. When the hello method is invoked in TargetService, the call is delegated to the stub which will invoke the remote web service.
  • public class TargetService implements ITarget
    private com.binildas.apache.axis.AxisEndToEnd.
    IHelloWeb helloWeb;
    public TargetService(){}
    public TargetService(com.binildas.apache.axis.
    AxisEndToEnd.IHelloWeb helloWeb)
    this.helloWeb = helloWeb;
    public String hello(String input)
    System.out.println("TargetService.echo : String. this = " +
    return helloWeb.hello(input);
    catch(Exception exception)
    return exception.getMessage();

  • We now need to wire the JBI proxy to the web services stub. IHelloProxy is an interface defined for this purpose and hence is having the same single business method, hello.

  • public interface IHelloProxy
    public String hello(String input);

  • HelloProxyService is a wrapper or adapter for the JBI proxy. In other words, the helloProxy instance field in HelloProxyService will refer to the JBI proxy.
  • public class HelloProxyService implements IHelloProxy
    private IHelloProxy helloProxy;
    public void setHelloProxy(IHelloProxy helloProxy)
    this.helloProxy = helloProxy;
    public String hello(String input)
    System.out.println("HelloProxyService.hello. this = " + this);
    return helloProxy.hello(input);

The bean wiring discussed in this section is done using Spring and is shown in the next section.


Please enter your comment!
Please enter your name here