Expose Core Services as Web Services

 

A Core Service defines a technical service which is needed in the DSB kernel to run. It can be a service registry, a transport layer, a binding manager,...

The DSB provides simple ways to expose core services as Web services without any extra configuration:

  1. By using JAXWS @Webservice annotation
  2. By using DSB @WebServicre annotation

The procedures are detailled below. 

JAXWS WebService

The only things which are needed are :

  1. Add JAX-WS annotations (javax.xml.ws.WebService) to core services or generate your service from a WSDL generation tool (Apache CXF is a good choice).
  2. Adding the core service to the right fractal composite
  3. There is no 3

To illustrate this feature, we provide a sample to expose a simple TestService service as Web service.

Create your interface

TestService interface

In this sample, we start from a JAXWS annotated Java interface. This is the only thing to check in this step.

Create your service

Creating your service means implement the interface we just defined in the previous step. Now we have to create a Fractal component which implement the JAXWS annotated TestService interface.

Fractal Component
  • As a Fractal component, you MUST check that you put all the Fractal annotations (@FractalComponent, @Provides, @LifeCycle)
  • This component MUST implements the TestService interface

Add service to the architecture

Once the Fractal component has been created, you have to add it to the component architecture provided by the DSB. For now, it is only possible at configuration time by adding the component at the right place. By default, the Tools.fractal definition file located in trunk/research/commons/dsb/distributions/dsb-distribution/src/main/resources (or in your own distribution) contains a WebServiceManagerImpl (org.petalslink.dsb.kernel.tools.ws.WebServiceManagerImpl) component which will detect JAXWS annotated components defined in the Tools.fractal composite and which will expose them automatically at startup on the management port (the same Petals ESB uses).

Adding your component is just instanciating it in Tools.fractal like this:

Component definition

That's all! Your TestService is now exposed by the DSB at startup and is available at : http://localhost:7600/petals/ws/TestService (where TestService is the Java interface name ie the one with the @WebService annotation).

DSB WebService

There are some cases which are not compatible with the previously described approach. For some reason, JAXWS annotated classes may produce a wrong result. In order to directly be able to work with Web services payload, the DSB provide a simple way to expose a bean as Web service as detailed below.

Create your service

Your service MUST implement the org.petalslink.dsb.soap.api.Service interface or extends the org.petalslink.dsb.soap.AbstractService class like for example

As you can see, you have the possibility to get operation from the incoming message, process things and set the response with the exchange.setOut(Document) method if needed. The DSB will be in charge of receiving the initial message, transforming it and then calling your service. Once the method is complete, it will send back the message to the client.

Once your service is implemented, you have to wrap it into a DSB component as defined below:

It is important to note:

  • You have to give the WSDL location (local resource in the classpath), endpoint, interface and service.
  • Your DSB component MUST be annotated with the org.petalslink.dsb.annotations.service.WebService annotation. If not, the service will not be exposed as Web service by the DSB.

Add service to the architecture

As specified above, you have to annotate the service with the org.petalslink.dsb.annotations.service.WebService annotation. With the help of this annotation, the DSB will be able to detect this class and expose it automatically. This is only true if you have instantiated the DSB component with the fractal stuff as described in the JAXWS section.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.