Web Service Interview Questions

1. What is a Web Service?
Ans: 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 java, shell script or any other different technology.

2. What are advantages of REST web services?
Ans:
 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.

3. Could you name the core components of the HTTP request and HTTP response?
Ans:
 Core components of HTTP requests are:

  • HTTP Version – Indicates version
  • Request Body – Represents message content
  • Request Header – Contains metadata, such as cache settings and client type, for the HTTP request message
  • URI – Identifies the resource on the server
  • Verb – Indicates HTTP methods such as GET, POST, and PUT
  • HTTP response has the following core components:HTTP Version – Indicates the present version of HTTP
  • Response Body – Represents the response message content
  • Response Header – Consists of metadata, like content length and server length, for the HTTP response message
  • Status/Response Code – Indicates the server status for the requested resource.

4. Name important annotations used in JAX-WS API?

Ans:Some of the important annotations used in JAX-WS API are:

  • WebService
  • SOAPBinding
  • WebMethod.

5. When designing a secure RESTful web service, what points should be followed?
Ans:
 Execute DELETE, GET, POST, PUT, etc. methods with proper restrictions

  • Invoke the HTTP generic message whenever and wherever required
  • Pass sensitive data, like username and session token password, via the POST method. Never use it through the URL
  • Perform user session based authentication each time a request is made
  • Validate all inputs on the server from SQL injection attacks.

6. Could you explain the various advantages of using Web services?
Ans:
 There are several advantages of using web services, the most notable of which are described as follows:

Assists in exposing the extant functionalities over the network so that other applications can use them

  • Easy to deploy, integrate and reuse
  • Facilitates simple integration thanks to the loose coupling
  • Low communication cost thanks to the use of SOAP over HTTP protocol
  • Provides some kind of required functionality to client applications
  • Supports interoperability, allowing applications to effortlessly communicate and share data as well as services with each other
  • Uses the standardized web service protocol stack for communication.

7. What are the advantages of SOAP web services?
Ans:
 These are some of the important advantages of SOAP web services:

  • WS Security – SOAP defines its security known as WS Security.
  • Language Independent – Its web services can be written in any programming language
  • Platform Independent – Its web services can be executed on any platform.
  • More details.

8. What is difference between Top Down and Bottom Up approach in SOAP Web Services?
Ans:
 In Top Down approach first WSDL document is created to establish the contract between web service and client and then code is written, it’s also termed as contract first approach. This is hard to implement because classes need to be written to confirm the contract established in WSDL. Benefit of this approach is that both client and server code can be written in parallel.

 9. What is JAX-WS?
Ans:
 JAX-WS (Java API for XML Web Services) is a set of APIs for creating web services in XML format.

10. What are the features of web services?
Ans: Following are the features of Web service:

  • It is available over the Internet or private (intranet) networks.
  • It uses a standardized XML messaging system.
  • It is not tied to any one operating system or programming language.
  • It is self-describing via a common XML grammar.
  • It is discoverable via a simple find mechanism.

11. What is Synchronicity?
Ans
: Synchronicity refers to the binding of the client to the execution of the service. In synchronous invocations, the client blocks and waits for the service to complete its operation before continuing. Asynchronous operations allow a client to invoke a service and then execute other functions.

12. What is the purpose of Service Provider in Web Service architecture?
Ans:
 This is the provider of the web service. The service provider implements the service and makes it available on the Internet.

13. Do you know your web service clients beforehand? If Yes, then you can define a contract before ?
Ans:
 implementation and SOAP seems better choice. But if you don’t then REST seems better choice because you can provide sample request/response and test cases easily for client applications to use later on.

14. What is wsimport utility?
Ans:
 We can use wsimport utility to generate the client stubs. This utility comes with standard installation of JDK. Below image shows an example execution of this utility for one of JAX-WS project.

15. What are the benefits of having XML based WEB services?
Ans:
 Using XML eliminates any networking, operating system, or platform binding. So Web Services based applications are highly interoperable application at their core level.

16. What are advantages of SOAP Web Services?
Ans:
 SOAP web services have all the advantages that web services has, some of the additional advantages are:

  • WSDL document provides contract and technical details of the web services for client applications without exposing the underlying implementation technologies.
  • SOAP uses XML data for payload as well as contract, so it can be easily read by any technology.
  • SOAP protocol is universally accepted, so it’s an industry standard approach with many easily available open source implementations.

17. What are different types of Web Services?
Ans:
 There are two types of web services:

SOAP Web Services: Runs on SOAP protocol and uses XML technology for sending data.

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.

18. Can we maintain user session in web services?
Ans:
 Web services are stateless so we can’t maintain user sessions in web services.

19. Explain BEEP?
Ans:
 The BEEP stands for Blocks Extensible Exchange Protocol. BEEP is an alternative to HTTP and FTP. BEEP is determined as building new protocols for the variety of applications such as instant messaging, network management, file transfer. It is termed as new Internet Engineering Task Force (IETF) which is layered directly over TCP.

20. Can be written in any programming language Capable of being easily tested over web browsers?
Ans:
 Fast and lightweight protocol, consumes less bandwidth and resources

  • Has loosely coupled implementation
  • Platform independent
  • Provides support for an array of data formats, such as JSON and plain text, and technologies.

21. What do you understand by WSDL?
Ans:
 WSDL or Web Service Description Language is a simple XML document present in the Service Description layer of the web service protocol stack. It describes the technical details or locates the UI to the web service. 

  • Header information
  • Method name
  • Method parameters
  • Origin
  • Port types
  • Service endpoint

22. What is REST Web Services?
Ans:
 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.

23. What is difference between SOA and Web Services?
Ans:
 Service Oriented Architecture (SOA) is an architectural pattern where applications are designed in terms of services that can be accessed through communication protocol over network. SOA is a design pattern and doesn’t go into implementation.

Web Services can be thought of as Services in SOAP architecture and providing means to implement SOA pattern.

24. Could you explain the term Interoperability in the context of Web services?
Ans:
 Generally, the term interoperability refers to the ability of two or more products or systems to work in tandem without any special requirements. In the context of web services, the term interoperability means communication and sharing data and services amongst applications.

25. Do you know what the XML-RPC protocol is? Explain its features?
Ans:
 The XML-RPC is a remote procedure call responsible for calling a function or procedure available on a remote computer. In other words, the XML-RPC is a simple protocol capable of performing RPCs by means of XML messaging.

In addition to establishing connections among a variety of computers, the XML-RPC serves as an excellent tool for connecting distinct environments. Following are the various features of the XML-RPC protocol.

26. Is it possible to bind SOAP and WSDL?
Ans:
 Binding SOAP and WSDL is possible. It can be done using the following two attributes:

Name: Defines the name of the binding

Type: Defines the port for the binding

27. What is the purpose of SOAP in a web service?
Ans:
 A web service takes the help of SOAP to transfer a message.

28. What is the benefit of a Web services being loosely coupled?
Ans:
 The web service interface can change over time without compromising the client’s ability to interact with the service. A tightly coupled system implies that the client and server logic are closely tied to one another, implying that if one interface changes, the other must be updated. Adopting a loosely coupled architecture tends to make software systems more manageable and allows simpler integration between different systems.

29. What are the benefits of Web Services?
Ans:
 Following are the benefits of using web services :

exposing the Existing Function on the network − Web services allows you to expose the functionality of your existing code over the network. Once it is exposed on the network, other application can use the functionality of your program.

Interoperability :Web services allow various applications to talk to each other and share data and services among themselves.

Standardized Protocol : Web services use standardized industry standard protocol for the communication. All the four layers (Service Transport, XML Messaging, Service Description, and Service Discovery layers) use well-defined protocols in the web services protocol stack.

Low Cost of Communication : Web services use SOAP over HTTP protocol, so you can use your existing low-cost internet for implementing web services.

30. Enumerate the various primary security issues of Web services.

Ans:  Here you will get the primary security issues: Authentication – Performed to verify the identity of a user and checking whether the user has the right to access the web service or not. It is also done with the intent of tracking user activity.

Following options can be considered for authenticating:                                  Confidentiality – Any individual web service might have several applications. Their service path typically contains a potential weak link at its nodes. Hence, whenever messages or XML requests are sent by the client together with the service path to the server, the same must be encrypted.

Network Security – Very important security issue necessitating tools for filtering web service traffic

31. What is JAXB?
Ans:
 JAXB (Java Architecture for XML Binding) is a Java standard that defines how Java objects are converted from and to XML. It makes reading and writing of XML via Java relatively easy.

32. What is the difference between SOA and a web service?
Ans:
 SOA (Service-Oriented Architecture) is an architectural pattern that makes possible for:

services to interact with one another independently.

Web Services is a realization of SOA concept, that leverages XML, JSON, etc. and common Internet protocols such as HTTP(S), SMTP, etc.

SOA is a system-level architectural style that tries to expose business. WOA is an interface-level architectural style that focuses on the means by which these service capabilities are exposed.

33. What are the various elements of WSDL documents?
Ans:
 Binding Defines as well as determines the protocol as well as the data format for each port type:

  • Message :Defines the data elements for each individual operation. It could be the entire document or an argument yet to be mapped
  • Operations : Defines the operations to be performed for processing a message
  • Port Type :Defines the collection of operations which can be performed for binding
  • Types : Defines the message data types, in the form of XML schema, used by the web services.

34. What are the various elements of a SOAP message?
Ans:
 Body : Contains the call and response messages. Also defined as child element of the envelope that contains entire application derived XML data, which has been exchanged as a part of the SOAP message.

  • Envelope: The mandatory root element. Translates the XML document and determines the start and end of the SOAP message.
  • Fault Element : Handles the errors occurring during the processing of the messages. Appears as a child element of the body if the error is present.
  • Header : Contains optional message header attributes containing specific application information. Intended to add new features and functionalities, this element can occur several times in a single SOAP message.

35.  Please draw a comparison between SOAP and REST?
Ans:
 coupling– Web services and clients are tightly coupled in SOAP. Furthermore, it defines some standards meant to be followed strictly. Contrarily, REST doesn’t follow too many standards in addition to offering loose coupling

  • Data Format and Preference – REST is preferred here and allows several data formats, like HTML and JSON. SOAP supports only the XML data format
  • Intent – While SOAP serves as a standard protocol for creating web services, REST is an architectural style of building web services
  • Java API – Java API for RESTful Web Services is JAX-RS while JAX-WS is the Java API for SOAP Web Services
  • Requirement – REST demands less bandwidth and resources and uses URI for exposing business logic. SOAP, on the other end, requires more bandwidth and resources and uses service interfaces for exposing business logic
  • Security – REST neither have a defined binding contract nor its own security methods. SOAP, however, uses WSDL contract for binding client programs and web services and has its own defined security methods.
  • Testing – SOAP web services are tested using SOAPUI. On the other hand, web browsers and extensions, such as Chrome postman, are available for testing RESTful web services

36. Can you explain the term UDDI and its features? What language does it use?
Ans:
 UDDI or Universal Description, Discovery, and Integration is an XML-based standard in the service discovery layer of the web service protocol stack. It uses Web Service Description Language (WSDL).

  • As the UDDI acts like a directory, it is used for finding and publishing web services over the web. Major features of UDDI are:
  • Acts as a database containing all WSDL files
  • Helps businesses discover and interact with each other over the Internet
  • Open framework
  • Platform-independent
  • Uses COBRA, Java RMI, and SOAP protocols for establishing communication.
  • Uses COBRA, Java RMI, and SOAP protocols for establishing communication

37. What do you mean by RESTful Web Services? What are the various advantages of the same?
Ans:
 REST is a contraction for Representational State Transfer. It is the stateless client-server architectural style for developing applications accessible over the Web. Web services using HTTP methods for implementing the REST architecture are called RESTful Web Services.

Data and functionality serve as resources accessed by the URI in the REST architectural style. RESTful Web Services have desirable properties like Modifiability, Performance, and Scalability. Following are the important advantages of using RESTful Web Services.

38. Which language does UDDI use?
Ans:
The UDDI uses the language known as WSDL (Web Service Description Language).

39. What is XML-RPC?
Ans:
The RPC is Remote Procedure Call. It is the method used for calling a procedure or function available on any remote computer on the web.

XML-RPC refers to a simple protocol used to perform RPCs by using XML messaging. It is an excellent tool for connecting different environments and also establishing connections between wide varieties of computers.

40. What are the steps involved in accessing a web service?
Ans:
 These are the steps involved in accessing a web service:

  • Client application bundled the information and into a SOAP message.
  • SOAP message sends to the server as a body of Hyper-Text markup language using POST method.
  • Web service unpacks the SOAP message and converts it into a command understandable by the application.
  • Application processes the information and in turn bundled the info and send it back to the client as a SOAP message.
  • A Client then unpacks the SOAP message to obtain the results.

41. What are different components of WSDL?
Ans:
 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.

42. What are disadvantages of SOAP Web Services?
Ans:
 Some of the disadvantages of SOAP protocol are:

  • Only XML can be used, JSON and other lightweight formats are not supported.
  • SOAP is based on the contract, so there is a tight coupling between client and server applications.
  • SOAP is slow because payload is large for a simple string message, since it uses XML format.
  • Anytime there is change in the server side contract, client stub classes need to be generated again.

43. What is WSDL?
Ans:
 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.

44. What is UDDI?
Ans:
 UDDI is acronym for Universal Description, Discovery and Integration. UDDI is a directory of web services where client applications can lookup for web services. Web Services can register to the UDDI server and make them available to client applications.

45. What are disadvantages of REST web services?
Ans:
 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.

46. What are different HTTP Methods supported in Restful Web Services?
Ans:
 Restful web services supported HTTP methods are – GET, POST, PUT, DELETE and HEAD.

47. What are different ways to test web services?
Ans:
 SOAP web services can be tested programmatically by generating client stubs from WSDL or through software such as Soap UI.

REST web services can be tested easily with program, curl commands and through browser extensions. Resources supporting GET method can be tested with browser itself, without any program.

48. What is use of javax.xml.ws.Endpoint class?
Ans:
 Endpoint class provides useful methods to create endpoint and publish existing implementation as web service. This comes handy in testing web services before making further changes to deploy it on actual serve.

49. how to get WSDL file of a SOAP web service?
Ans:
 WSDL document can be accessed by appending wsdl to the SOAP endpoint URL.

50. What tools are used to test web services?
Ans:
 The tools used to test web services are:

SoapUI tool for testing SOAP and RESTful web services

Poster for firefox browser

Postman extension for Chrome

51. Explain the loosely coupled architecture of web services?
Ans:
 A consumer of a web service is not tied to that web service directly. The web service interface can change over time without compromising the client’s ability to interact with the service. A tightly coupled system implies that the client and server logic are closely tied to one another, implying that if one interface changes, the other must be updated. Adopting a loosely coupled architecture tends to make software systems more manageable and facilitates simpler integration between different systems.

52. What is the usage of Service Discovery layer in Web Service Protocol Stack?
Ans:
 The Service Discovery layer is used for centralizing services into a universal registry and providing easy publish/find functionality.

53. Explain web service protocol stack and its layers?
Ans:
The web services consist of four layers, as mentioned below:

Service transport: This layer is the first layer in the web services protocol stack used in transporting XML files between various clients applications. Protocols used in the layer is as follows:

  • HTTP (Hypertext transfer protocol)
  • SMTP (Simple Mail Transfer Protocol)
  • FTP (File Transfer Protocol)
  • BEEP (Block Extensible Exchange Protocol)

XML Messaging: This layer is the second layer in the web services protocol stack based on XML model where messages are encoded in common XML format which can be understandable to other client applications. This layer includes the following protocols:

XML – RPC

SOAP (Simple Object Access Protocol)

Service Description: This layer provides the service description to the public interface like the location of web service, Available functions, And the data types for XML messaging. This layer only includes one language:

WSDL: WSDL stands for Web Service Description Language.

Service Discovery: This layer in the Web Services protocol stack is used to publish or finding web services over the web. This layer includes:

UDDI (Universal Description, Discovery, and integration).

Note: Browse latest Amazon Web Services Interview Questions and Amazon Web Services tutorials. Here you can check AWS Online Training details and AWS Training Videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

Scroll to Top