Thursday, December 27, 2018

Web Services Interview Questions and answers – SOAP, RESTful

Welcome to the Web Services some Interview Questions with detailed answers.

What is a Web Service?

Web Services work on client-server model where client applications can access web services over the network. Web services provide endpoint URLs and expose methods that can be accessed over network through client programs written in C#, shell script or any other different technologies.
Web services are stateless and doesn’t maintain user session like web applications.

What is SOAP?

SOAP stands for Simple Object Access Protocol. SOAP is an XML based industry standard protocol for designing and developing web services. Since it’s XML based, it’s platform and language independent. So our server can be based on JAVA and client can be on .NET, PHP etc. and vice versa.

What is WSDL?
WSDL stands for Web Service Description Language. WSDL is an XML based document that provides technical details about the web service. Some of the useful information in WSDL document are: method name, port types, service end point, binding, method parameters etc.
What are different components of WSDL?
Some of the different tags in WSDL xml are:
    • xsd:import namespace and schemaLocation: provides WSDL URL and unique namespace for web service.
    • message: for method arguments
    • part: for method argument name and type
    • portType: service name, there can be multiple services in a wsdl document.
    • operation: contains method name
    • soap:address for endpoint URL.

What is REST Web Services?

REST is the acronym for REpresentational State Transfer. REST is an architectural style for developing applications that can be accessed over the network. REST architectural style was brought in light by Roy Fielding in his doctoral thesis in 2000.
REST is a stateless client-server architecture where web services are resources and can be identified by their URIs. Client applications can use HTTP GET/POST methods to invoke Restful web services. REST doesn’t specify any specific protocol to use, but in almost all cases it’s used over HTTP/HTTPS. When compared to SOAP web services, these are lightweight and doesn’t follow any standard. We can use XML, JSON, text or any other type of data for request and response.
What are advantages of REST web services?
Some of the advantages of REST web services are:
  • Learning curve is easy since it works on HTTP protocol
  • Supports multiple technologies for data transfer such as text, xml, json, image etc.
  • No contract defined between server and client, so loosely coupled implementation.
  • REST is a lightweight protocol
  • REST methods can be tested easily over browser.

What are disadvantages of REST web services?

Some of the disadvantages of REST are:
  • Since there is no contract defined between service and client, it has to be communicated through other means such as documentation or emails.
  • Since it works on HTTP, there can’t be asynchronous calls.
  • Sessions can’t be maintained.

What is a Resource in Restful web services?

Resource is the fundamental concept of Restful architecture. A resource is an object with a type, relationship with other resources and methods that operate on it. Resources are identified with their URI, HTTP methods they support and request/response data type and format of data.

What are different HTTP Methods supported in Restful Web Services?

Restful web services supported HTTP methods are – GET, POST, PUT, DELETE and HEAD.

Compare SOAP and REST web services?

SOAPREST
SOAP is a standard protocol for creating web services.REST is an architectural style to create web services.
SOAP is acronym for Simple Object Access Protocol.REST is acronym for REpresentational State Transfer.
SOAP uses WSDL to expose supported methods and technical details.REST exposes methods through URIs, there are no technical details.
SOAP web services and client programs are bind with WSDL contractREST doesn’t have any contract defined between server and client
SOAP web services and client are tightly coupled with contract.REST web services are loosely coupled.
SOAP learning curve is hard, requires us to learn about WSDL generation, client stubs creation etc.REST learning curve is simple, POJO classes can be generated easily and works on simple HTTP methods.
SOAP supports XML data format onlyREST supports any data type such as XML, JSON, image etc.
SOAP web services are hard to maintain, any change in WSDL contract requires us to create client stubs again and then make changes to client code.REST web services are easy to maintain when compared to SOAP, a new method can be added without any change at client side for existing resources.
SOAP web services can be tested through programs or software such as Soap UI.REST can be easily tested through CURL command, Browsers and extensions such as Chrome Postman.

What are different types of Web Services?

There are two types of web services:
  1. SOAP Web Services: Runs on SOAP protocol and uses XML technology for sending data.
  2. Restful Web Services: It’s an architectural style and runs on HTTP/HTTPS protocol almost all the time. REST is a stateless client-server architecture where web services are resources and can be identified by their URIs. Client applications can use HTTP GET/POST methods to invoke Restful web services.


Here i am explain you very few question those i am face during my Interview.
I take reference from here for more reading you can follow same link.

Thank you.

1 comment: