Using Java-First Approach - 6.1

Talend ESB Service Developer Guide

EnrichVersion
6.1
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
Installation and Upgrade
EnrichPlatform
Talend ESB

Combining JAX-RS and JAX-WS using the Java-First approach is about annotating the interface or concrete class with both JAX-WS and JAX-RS annotations:

package server;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

@WebService
@Path("/bookstore")
@Consumes("application/xml")
@Produces("application/xml")
public interface BookStoreJaxrsJaxws {
    
   @WebMethod
   @GET
   @Path("/{id}")
   @Consumes("application/xml")
   Book getBook(@PathParam("id") @WebParam(name = "id") Long id);

   @WebMethod
   @POST
   @Path("/books")
   Book addBook(@WebParam(name = "book") Book book);
}           
          

In this example, the BookStoreJaxrsJaxws implementation class will need to be declared as a standalone bean and referenced from JAX-WS and JAX-RS endpoints. Both JAX-WS and JAX-RS proxies will be able to reuse this interface for consuming SOAP and RESTful web services. Please see the jaxrs_jaxws_java_first demo in the Talend ESB Examples distribution for a concrete example.