JAX-WS - Interview Questions

What are the APIs provided in Java EE to support web services?

 FAQ

Java EE provides two different APIs JAX-WS and JAX-RS to support web services.

JAX-WS - Java EE provides the JAX-WS (Java API for XML Web Services) for building web services and clients for SOAP/XML based Web Services.

JAX-RS - Java EE provides the JAX-RS (Java API for RESTful Web Services) for building web services and clients for RESTful Web Services

What are the key advantages of JAX-WS API that is provided in Java EE?

 FAQ

Java EE provides the JAX-WS API to support Web Services that use XML-based protocols such as SOAP.

The JAX-WS API hides the complexity of SOAP messages and protocol from the developer. The JAX-WS API converts the API calls or requests to the corresponding SAOP messages, hence the developer does not have to generate or parse the SOAP messages programmatically.

JAX-WS uses the standard W3C technologies HTTP, SOAP and WSDL. A JAX-WS client can access a web service that is not running on Java platform and vice versa.

What are service endpoint interfaces and service endpoint implementations?

 FAQ

A service endpoint interface is a Java interface that declares the methods that a client can invoke on the web service. A service endpoint implementation is a class that implements the methods defined in the service endpoint interface.

What are key annotations used in a JAX-WS service endpoint implementation?

 FAQ

Following are the key annotations used in a JAX-WS service endpoint implementation.

@WebService - A Java class is annotated as a JAX-WS web service endpoint using the @WebService annotation.

@WebMethod - A Java method is exposed to Web Service clients using the @WebMethod annotation.

import javax.jws.WebService;
import javax.jws.WebMethod;

@WebService
public class OrderService {

 public OrderService() { ... }

 @WebMethod
 public String getOrder(String orderNumber) { ... }
}

What are the key requirements of a JAX-WS Web Service endpoint?

 FAQ

JAX-RS endpoints have to follow certain requirements.

  • The implementing class must be annotated with either the @WebService or the @WebServiceProvider annotation.
  • The implementing classs must not be declared final.
  • The implementing class must not be declared abstract.
  • The implementing class must not define the finalize method.
  • Methods which are exposed to Web Service clients must be annotated with @WebMethod annotation.

How does the conversion happen between Java objects and XML documents in JAX-WS API?

 FAQ

The JAX-WS API leverages the JAXB API and tools as the binding technology for mapping between Java objects and XML documents.

What are the two approaches to developing JAX-RS Web Services?

 FAQ

JAX-RS Web Services can be developed via either of the following approaches.

1. Develop a JAX-RS Web Service from a WSDL (Top-Down Development) - In this approach the JAX-RS Web Service is created from an existing WSDL file using JavaBeans. The base Web Service endpoint classes and interfaces are generated via the 'wsimport' tool provided in the JAX-RS API.

2. Develop a JAX-WS Web service from a JavaBean (bottom-up development) - In this approach the JAX-WS Web Service endpoint interfaces and classes are created first using annotations. After the Web Service endpoint interfaces and classes are created, the WSDL file is generated by using the 'wsgen' tool provided in the JAX-RS API.

 
Subscribe to our Questions

 

Java EE - Interview Questions

Java ServletsJavaServer PagesJavaServer FacesJava API for XML Processing (JAXP)Java API for JSON Processing (JSON-P)Java Message Service API (JMS)Java Persistance API (JPA)Java Transaction API (JTA)JAX-WSJava API for RESTful Web Services (JAX-RS)Java Database Connectivity API (JDBC)Security
 
RECOMMENDED RESOURCES
Behaviorial Interview
Top resource to prepare for behaviorial and situational interview questions.

STAR Interview Example