Saturday 5 September 2015

Discuss various approaches to develop SOAP based web service ?

There are 2 approaches : Contract-first & Contract-last. 
Contract-first starts with defining first XML schema / WSDL and then creating the Java classes based on them. In Contract-last approach Java classes are defined first than WSDL is generated from that.

What are Tools/API are there for developing/testing web service?

Testing Tools for Web Service : SoapUI for SOAP Web Service, Firefox plugin for testing RESTFul Services.
REST APIs : Spring REST Web Service using MVC, Jersey API, CFX, Axis, Restlet etc. 
SOAP APIs : Axis, Spring Web Service etc

What are Tools/API are there for developing/testing web service?

Testing Tools for Web Service : SoapUI for SOAP Web Service, Firefox plugin for testing RESTFul Services.
REST APIs : Spring REST Web Service using MVC, Jersey API, CFX, Axis, Restlet etc. 
SOAP APIs : Axis, Spring Web Service etc

What is REST ?

REST is architectural style for building web service using HTTP protocol, where web services are treated as resources and some basic HTTP methods like GET, POST, DELETE are used
to identify standard action on resources.RESTful web API (also called a RESTful web service) is a web API implemented using HTTP and the REST principles.

What are the different application integration styles?

There are a number of different integration styles like
1. Shared database
2. batch file transfer
3. Invoking remote procedures (RPC)
4. Exchanging asynchronous messages over a message oriented middle-ware (MOM).

What is meant by JAX-WS and JAX-RS?

Java API for XML Web Services(JAX-WS)
Java API for RESTful Web Services (JAX-RS)

Can I use GET request instead of PUT to create resources?

No, you are supposed to use PUT or POST. GET operations should only have view rights.

What is REST and RESTful web services?

This is the first REST interview question on most of interviews as not everybody familiar with REST and also start discussion based on candidates response. Anyway REST stands for REpresentational State Transfer (REST) its a relatively new concept of writing web services which enforces a stateless client server design where web services are treated as resource and can be accessed and identified by there URL unlike SOAP web services which were defined by WSDL.
Web services written by apply REST Architectural concept are called RESTful web services which focus on System resources and how state of Resource should be transferred over http protocol to a different clients written in different languages. In RESTful web services http methods like GET, PUT, POST and DELETE can can be used to perform CRUD operations.

What happens if RestFull resources are accessed by multiple clients ? do you need to make it thread-safe?

Since a new Resource instance is created for every incoming Request there is no need to make it thread-safe or add synchronization. multiple client can safely access RestFull resources concurrently.

What is difference between top-down and bottom-up approach of developing web services ?

In top-down approach first WSDL document is created and than Java classes are developed based on WSDL contract, so if WSDL contract changes you got to change your Java classes while in case of bottom up approach of web service development you first create Java code and then use annotations like @WebService to specify contract or interface and WSDL field will be automatically generated from your build.

Which HTTP methods are supported by RestFull web services ?

Another common REST interview questioning RESTFul web service each Resource supports GET, POST, PUT and DELETE http methods.GET is mapped to represent(), POST - acceptRepresentation(), PUT- storeRepresentation and DELET for rmeoveRepresentation.

How to display custom error pages using RestFull web services ?

In order to customize error you need to extend StatusService and implement getRepresentation(Status, Request, Response) method with your custom code now assign instance of your CustomStatusService to appropriate "statusService property".

Can you use Restlet without any web-container ?

Yes, Restlet framework provide default server which can be used to handle service request in web container is not available.

What is Resource in REST framework ?

it represent a "resource" in REST architecture. on RESTLET API it has life cycle methods like init(), handle() and release() and contains a Context, Request and Response corresponding to specific target resource. This is now deprecated over ServerResource class and you should use that. see Restlet documentation for more details.

What is Restlet framework ?

Restlet is leading RESTful web framework for Java applications is used to build RESTFul web services it has two part Restlet API and a Restlet implementation much like Servlet specification. There are many implementation of Restlet framework available you just need to add there jar in your classpath to use them. By using Restlet web framework you can write client and server.

What is differences between RESTful web services and SOAP web services ?

Though both RESTful web series and SOAP web service can operate cross platform they are architecturally different to each other, here is some of differences between REST and SOAP:
1) REST is more simple and easy to use than SOAP
2) REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
3) REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDA's.
4) REST supports different format like text, JSON and XML while SOAP only support XML.
5) REST web services call can be cached to improve performance.

What is REST and RESTful web services ?

This is the first REST interview question on most of interviews as not everybody familiar with REST and also
start discussion based on candidates response. Anyway REST stands for REpresentational State Transfer (REST) its a relatively new concept of writing web services which enforces a stateless client server design where web services are treated as resource and can be accessed and identified by there URL unlike SOAP web services which were defined by WSDL.
Web services written by apply REST Architectural concept are called RESTful web services which focus on System resources and how state of Resource should be transferred over http protocol to a different clients written in different languages. In RESTful web services http methods like GET, PUT, POST and DELETE can can be used to perform CRUD operations.

Explain REST web service?

 Representational State Transfer
 Architectural style (technically not a standard)
 A network of web pages where the client progresses through an application by selecting links. When client traverses link, accesses new resource (i.e., transfers state)
 Uses existing standards, e.g., HTTP

Explain UDDI ?

 UDDI stands for Universal Description, Discovery and Integration.
 UDDI is a directory for storing information about web services , like yellow pages.
 UDDI is a directory of web service interfaces described by WSDL.

What types of Operations available in WSDL ?

 One-way : The operation can receive a message but will not return a response
 Request-response: The operation can receive a request and will return a response
 Solicit-response: The operation can send a request and will wait for a response
 Notification: The operation can send a message but will not wait for a response

What is WSDL Ports ?

 The <portType> element is the most important WSDL element. 
 It defines a web service, the operations that can be performed, and the messages that are involved.
 The <portType> element can be compared to a function library (or a module, or a class) in a traditional programming language.

Can you explain WSDL Document Structure ?

 A WSDL document is just a simple XML document.
 It defines a web service using these major elements:
 port type: The operations performed by the web service.
 message: The messages used by the web service.
 types: The data types used by the web service.
 binding: The communication protocols used by the web service.

What is WSDL ?

 WSDL stands for Web Services Description Language.
 WSDL is an XML vocabulary for describing Web services. It allows developers to describe Web Services and their capabilities, in a standard manner. 
 WSDL specifies what a request message must contain and what the response message will look like in unambiguous notation. In other words, it is a contract between the XML Web service and the client who wishes to use this service.
 In addition to describing message contents, WSDL defines where the service is available and what communications protocol is used to talk to the service.

Explain the Web Service Model?

The Web Services architecture is based upon the interactions between three roles:
 Service provider
 Service registry
 Service requestor
 The interactions involve the:
 Publish operations
 Find operation
 Bind operations.

What are the Benefits of JAX-RPC ?

 Portable and interoperable web services 
 Ease of development of web services endpoints & clients
 Increased developer productivity 
 Support for open standards: XML, SOAP, WSDL 
 Standard API developed under Java Community Process 
 Support for tools 
 RPC programming model with support for attachments 
 Support for SOAP message processing model & extensions 
 Secure web services 
 Extensible type mapping

What is JAX-RPC ?

 JAX-RPC hides this complexity from the application developer.
 On the server side, the developer specifies the remote procedures by defining methods in an interface. 
 The developer also codes one or more classes that implement those methods. 
 Client programs create a proxy, a local object representing the service, and then simply invokes methods on the proxy

What is SOAP ?

 SOAP is a lightweight protocol for exchange of information in a decentralised, distributed environment
 Web Services expose useful functionality to Web users through a standard Web protocol called SOAP. 
 Soap is an XML vocabulary standard to enable programs on separate computers to interact across any network. SOAP is a simple markup language for describing messages between applications. 
 Soap uses mainly HTTP as a transport protocol. That is, HTTP message contains a SOAP message as its payload section.

What kind of Data Transport is possible using Web service ?

Data format :
XML (subset of XML 1.0), URL encoding. 
Data format schema definition: XML Schema 
Wire format :
XML Protocol (XML-RPC, SOAP), URI 
Transfer protocol: HTTP, SMTP, JMS, BEEP, …

What are the Web Services Components ?

 XML – eXtensible Markup Language – A uniform data representation and exchange mechanism.
 SOAP – Simple Object Access Protocol – A standard way for communication.
 UDDI – Universal Description, Discovery and Integration specification – A mechanism to register and locate WS based application.
 WSDL – Web Services Description Language – A standard meta language to described the services offered.

What are the Advantages of Web service ?

 Not based on a programming language: Java, .Net, C, C++, Python, Perl, … 
 Not based on a programming data model: Objects vs non-objects environments.
 Convergence of SOA (Service-Oriented Architecture) and Web.
 Based on web technologies
 Do not need huge framework of memory
 Basic usage is b-to-b ,remote controlled devices,internal external appl communications

What is Web service ?

A Web service is a software system identified by a URI, whose public interfaces and bindings are defined and described using XML. Its definition can be discovered by other software systems. These systems may then interact with the Web service in a manner prescribed by its definition, using XML based messages conveyed by Internet protocols.
Loosely coupled, reusable software components that semantically encapsulate discrete functionality and are distributed and programmatically accessible over standard Internet protocols.

Why not favor traditional style middle-ware such as RPC, CORBA, RMI and DCOM as opposed to Web services?

The traditional middle-wares tightly couple connections to the applications and it can break if you make any modification to your application. Tightly coupled applications are hard to maintain and less reusable. Generally do not support heterogeneity. Do not work across Internet. Can be more expensive and hard to use. 

Web Services support loosely coupled connections. The interface of the Web service provides a layer of abstraction between the client and the server. The loosely coupled applications reduce the cost of maintenance and increases re-usability. Web Services present a new form of middle-ware based on XML and Web. Web services are language and platform independent. You can develop a Web service using any language and deploy it on to any platform, from small device to the largest supercomputer. Web service uses language neutral protocols such as HTTP and communicates between disparate applications by passing XML messages to each other via a Web API. Do work across internet, less expensive and easier to use.

What is the difference between SOA and a Web service?

SOA is a software design principle and an architectural pattern for implementing loosely coupled, reusable and coarse grained services. You can implement SOA using any protocols such as HTTP, HTTPS, JMS, SMTP, RMI, IIOP (i.e. EJB uses IIOP), RPC etc. Messages can be in XML or Data Transfer Objects (DTOs).
Web service is an implementation technology and one of the ways to implement SOA. You can build SOA based applications without using Web services – for example by using other traditional technologies like Java RMI, EJB, JMS based messaging, etc. But what Web services offer is the standards based and platform-independent service via HTTP, XML, SOAP, WSDL and UDDI, thus allowing interoperability between heterogeneous technologies such as J2EE and .NET.

What tools do you use to test your Web Services?

SoapUI tool for SOAP WS and the Firefox "poster" plugin for RESTFul services.

How would you decide what style of Web Service to use? SOAP WS or REST?

In general, a REST based Web service is preferred due to its simplicity, performance, scalability, and support for multiple data formats. SOAP is favored where service requires comprehensive support for security and transactional reliability.

The answer really depends on the functional and non-functional requirements. Asking the questions listed below will help you choose.
  • 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)
  • Do we need to support multiple data formats?
  • Do we need to make AJAX calls? (REST can use the XMLHttpRequest)
  • Is the call synchronous or  asynchronous?
  • Is the call stateful or stateless? (REST is suited for statless CRUD operations)
  • What level of security is required? (SOAP WS has better support for security)
  • What level of transaction support is required? (SOAP WS has better support for transaction management)
  • Do we have limited band width? (SOAP is more verbose)
  • What’s best for the developers who will build clients for the service? (REST is easier to implement, test, and maintain)

What are the differences between both SOAP WS and RESTful WS?

  • The SOAP WS supports both remote procedure call (i.e. RPC) and message oriented middle-ware (MOM) integration styles. The Restful Web Service supports only RPC integration style.
  • The SOAP WS is transport protocol neutral. Supports multiple protocols like HTTP(S),  Messaging, TCP, UDP SMTP, etc. The REST is transport protocol specific. Supports only HTTP or HTTPS protocols.
  • The SOAP WS permits only XML data format.You define operations, which tunnels through the POST. The focus is on accessing the named operations and exposing the application logic as a service. The REST permits multiple data formats like XML, JSON data, text, HTML, etc. Any browser can be used because the REST approach uses the standard GET, PUT, POST, and DELETE Web operations. The focus is on accessing the named resources and exposing the data as a service. REST has AJAX support. It can use the XMLHttpRequest object. Good for stateless CRUD (Create, Read, Update, and Delete) operations. 

             GET - read()
             POST - create()
             PUT - update()
             DELETE - delete() 
  • SOAP based reads cannot be cached. REST based reads can be cached. Performs and scales better.
  • 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.
  • The SOAP has comprehensive support for both ACID based  transaction management  for short-lived transactions and compensation based transaction management for long-running transactions. It also supports two-phase commit across distributed resources. The REST supports transactions, but it  is neither ACID compliant nor can provide two phase commit across distributed transactional resources as it is limited by its HTTP protocol.
  • The SOAP has success or retry logic built in and provides end-to-end reliability even through SOAP intermediaries. REST does not have a standard messaging system, and expects clients invoking the service to deal with communication failures by retrying.

What are the different styles of Web Services used for application integration?

SOAP WS and RESTful Web Service

Web Services Links