Skip to main content
  • New archived content: Talend MDM, Talend Data Catalog 8.0, and Talend 7.3 products reached their end of life in 2024. Their documentation was moved to the Talend Archive page and will no longer receive content updates.
Close announcements banner

Using Java-First Approach

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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!