Java Web Services Interview Questions and answers


The most important and frequently asked java web services interview questions are mentioned below with easy to understand answers:

Java web services basic interview questions

Web service is an application component that can be accessed via network (or web) using standard protocols. Web services is independent of programming language or operating system on which its developed.
Web services are required because we need heterogeneous applications to interact with each others. Ex: an application written in java can interact with another application written in java but not with an application written in another technology like .net. But in real time we need such interactions and web service is what makes it possible. The reason for this is web service uses xml/JSON messages as the means of exchanging data with its cliet.
SoapUI is the world leading tool for testing SOAP based web services, latest version support REST as well.
Firefox poster plugin,

SOAP web services interview questions

There are 3 main components web services (mainly SOAP based).

SOAP

SOAP stands for Simple Object Access Protocol. It define architecture and formats of request/response messages. The web-service request and response both are transmitted as SOAP message (xml) over HTTP.

WSDL

Web Services Description Language (WSDL) is a xml document which is used as a formal contract to describe the interface that a web service offers. It may include operations, messages, bindings and location of the web service (end point).

UDDI

Universal Description and Discovery Integration.
A WSDL document describes web-service using below elements:
WSDL 1.1 : types, messages, portType(operation - input, output), binding, service(port).
WSDL 2.0 : types, interface(operation - input, output), binding, service(endpoint).

Its easy to remember these elements with an analogy to java class:
portType is equivalent to name of class.
Each operation in portyType gives name of a method in the class.
The input and output tags inside operation corresponds to input parameter and return value.
types and messages define structure of these input, output in xml.
service element provides url where the web-service is hosted.
Top-down development or contract (WSDL) first approach.
Bottom-up development or code first approach.
Apache Axis is a web services framework which provides implementation of JAX-RPC(Axis 1.x) and JAX-WS(Axis 2) web services specifications.
Apache CXF is a web services framework which provides implementation of JAX-WS and JAX-RS web services specifications.
Apache CXF is a web services framework which provides implementation of JAX-WS and JAX-RS web services specifications.

REST Web Services Interview Questions

REST stands for REpresentational State Transfer. Its and architectural style and not a standard or protocol. In the REST architecture style, clients and servers exchange representations of resources using a standardized interface and protocol.
In the REST architectural style, data and functionality are considered resources, and these resources are accessed using Uniform Resource Identifiers (URIs), typically links on the web. The resources are acted upon by using a set of simple, well-defined operations (CRUD operations).
Jersey, Restlet, EasyRest etc.
Jersey Jersey is the reference implementation provided by Sun. Its most widely used REST framework.
Restlet 2nd
REST is more simple and easy to use than SOAP. REST language is based on use of nouns and verbs (better readability)
REST is lightweight as compared to SOAP.
REST supports different format like text, JSON and XML while SOAP only support XML.
Does the service expose data or business logic? (REST is a better choice for exposing data, SOAP WS might be a better choice for logic).Do the consumers and the service providers require a formal contract? (SOAP has a formal contract via WSDL)
SOAP WS supports both SSL security and WS-security, which adds some enterprise security features like maintaining security right up to the point where it is needed, maintaining identities through intermediaries and not just point to point SSL only, securing different parts of the message with different security algorithms, etc. The REST supports only point-to-point SSL security. The SSL encrypts the whole message, whether all of it is sensitive or not.
SOAP has better support security. SOAP has better support for ACID transactions management. SOAP has formal contract via WSDL. for everything else REST is better. Does the service expose data or business logic? REST is a better choice for exposing data, SOAP WS might be a better choice for logic. Do the consumers and the service providers require a formal contract? (SOAP has a formal contract via WSDL)
SOAP WS supports both SSL security and WS-security, which adds some enterprise security features like maintaining security right up to the point where it is needed, maintaining identities through intermediaries and not just point to point SSL only, securing different parts of the message with different security algorithms, etc. The REST supports only point-to-point SSL security. The SSL encrypts the whole message, whether all of it is sensitive or not.
XMethods directory of web services. IBM web services browser on IBM Alphaworks site.