0% found this document useful (0 votes)
101 views44 pages

WebServicesUpdated2017 Madhu

Web services use a client-server model to expose methods over a network through URLs. RESTful web services use the HTTP protocol to access resources on a server through standard methods like GET, PUT, POST. Resources are represented in common formats like JSON, XML, and addressed through URIs. Statelessness means that each client request is independent and the server does not maintain session data. Caching allows responses to be stored and reused to improve performance.

Uploaded by

Sakamuri Suman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views44 pages

WebServicesUpdated2017 Madhu

Web services use a client-server model to expose methods over a network through URLs. RESTful web services use the HTTP protocol to access resources on a server through standard methods like GET, PUT, POST. Resources are represented in common formats like JSON, XML, and addressed through URIs. Statelessness means that each client request is independent and the server does not maintain session data. Caching allows responses to be stored and reused to improve performance.

Uploaded by

Sakamuri Suman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

WEB SERVICES INTERVIEW QUESTIONS

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 java, shell script or any other
different technologies.

Web services are stateless and doesn’t maintain user session like web applications.

What are RESTful web services?

Just like SOAP (Simple Object Access Protocol), which is used to develop web services by
XML method, RESTful web services use web protocol i.e. HTTP protocol method. They
have the feature like scalability, maintainability, help multiple application communication
built on various programming languages etc.

RESTful web service implementation defines the method of accessing various resources
which are required by the client and he has sent the request to the server through the web
browser. The important aspects of this implementation include:

 Resources
 Request Headers
 Request Body
 Response Body
 Status codes

Name the protocol which is used by RESTful web services.

RESTful web services use a famous web protocol i.e. HTTP protocol. This serves as a
medium of data communication between client and server. HTTP standard methods are used
to access resources in RESTful web service architecture.

Explain the term ‘Addressing’ with respect to RESTful WEB service.

Just like we require address with postal code to reach any person, in the same way,
‘Addressing’ locates resources that are present on the server for the purpose of hosting web
services. This is usually done with URI i.e. Unified Resource Identifier.

Enlist features of RESTful web services.

Every RESTful web services should have following features and characteristics that are
enlisted below:

Based on the Client Server representation.

Use of HTTP protocol for performing functions like fetching data from the web service,
retrieving resources, execution of any query, etc.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

The communication between the server and client is performed through the medium known
as ‘messaging’.

Addressing of resources available on the server through URIs.

Based on the concept of statelessness where every client request and the response is
independent of the other with complete assurance of providing required information.

Uses the concept of caching.

Works on Uniform interface.

Explain messaging technique.

Messages are the mode of exchanging data for any type of communication to take place. In
the same way, HTTP protocol plays the role of message communication between the client
and server through HTTP Request and Response methods. HTTP request is sent by the client
who contains information about the data and in turn, receives HTTP Response from the
server.

Messages are the collection of information about the data i.e. Metadata.

What are the core components of HTTP request and HTTP response?

The core components that come under HTTP Request are:

Verb: Includes methods like GET, PUT, POST, etc.

 Uniform Resource Identifier for identifying the resources available on the server.
 HTTP Version for specifying the HTTP version.
 HTTP Request header for containing the information about the data.
 HTTP Request body that contains the representation of the resources in use.

The core components that come under HTTP Response are:

Request Code: This contains various codes which determine the status of the server response.

 HTTP Version for specifying the HTTP version.


 HTTP Response header for containing the information about the data.
 HTTP Response body that contains the representation of the resources in use.

Explain the term ‘Statelessness’ with respect to RESTful WEB service.

In REST, ST itself defines State Transfer and Statelessness means complete isolation. This
means, the state of the client’s application is never stored on the server and is passed on. In
this process, the clients send all the information that is required for the server to fulfill the
HTTP request that has been sent. Thus every client request and the response is independent of
the other with complete assurance of providing required information.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Every client passes a ‘session identifier’ which also acts as an identifier for each session.

Enlist advantages and disadvantages of ‘Statelessness’.

In the above question, we have understood the meaning of statelessness with respect to the
client-server communication. Now, let us see some of its advantages and disadvantages.

Advantages:

 Every method required for communication is identified as an independent method i.e.


there are no dependencies to other methods.
 Any previous communication with the client and server is not maintained and thus the
whole process is very much simplified.
 If any information or metadata used earlier in required in another method, then the
client sends again that information with HTTP request.
 HTTP protocol and REST web service, both shares the feature of statelessness.

Disadvantages:

 In every HTTP request from the client, the availability of some information regarding
the client state is required by the web service.

Enlist some important constraints for RESTful web services.

Every constraint has positive as well as negative impacts and to produce an overall
architecture, there should be the balance between both of them. Below mentioned are some
important constraints for RESTful web service:

 There should be separate concerns for each server and client which will help to
maintain the modularity within the application. This will also reduce the complexity
and increase the scalability.
 The client-server communication should be stateless, which means no previous
information is used and the complete execution is done in isolation. In cases of
failure, it also helps the client to recover.
 In client-server communication, the HTTP response should be cacheable so that when
required cached copy can be used which in turn enhances the scalability and
performance of the server.
 The fourth constraint is the uniform interface which allows client-server interaction to
be easily understood. This constraint is further divided into four sub-constraints as:

Resource Identification

Resource manipulation

Each message is easily understood and is self-descriptive.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Hypermedia, which is defined as the text with hyperlinks and when clicked it moves to
another application state.

Client-server communication should be done on a layered system and thus the client should
only have knowledge about the intermediate level with which communication is being done.

What is a ‘Resource’?

Just like the ‘Object’ instance, we have learned in object orient programming Language, in
the same way, ‘Resource’ is defined as an object of a type which can be an image, HTML
file, text data, and any type of dynamic data. There are varieties of representation formats
available in order to represent a resource.

Some most common are enlisted below:

 JSON
 YAML
 XML
 HTML

Why proper representation of Resource is required?

Representation is very important because it determines the easy identification of resources.


With proper representations of resource in the proper format, allows the client to easily
understand the format.

Enlist some important points that should be kept in mind while designing Resources
representation for RESTful web services.

As there are no restrictions on the format in which the resource representation is done but just
that the main requirement is the format of the representation should be as per the client
requirement. A good resource representation is designed by considering the following main
points:

The resource representation format should be easily understood by the client and server.

The representation should be complete regardless of its format structure, which may be
complex or simple.

In the case of the link of the resources to other resources, such cases should also be
considered and handled.

What is Caching?

Caching is the process in which server response is stored so that a cached copy can be used
when required and there is no need of generating the same response again. This process not
only reduces the server load but in turn increase the scalability and performance of the server.
Only the client is able to cache the response and that too for a limited period of time.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Mentioned below are the header of the resources and their brief description so that they can
be identified for the caching process:

Time and Date of resource creation

Time and date of resource modification that usually stores the last detail.

Cache control header

Time and date at which the cached resource will expire.

The age which determines the time from when the resource has been fetched.

Explain Cache-control header.

A standard Cache control header can help in attaining cache ability. Enlisted below is the
brief description of various cache control header:

 Public: Resources that are marked as the public can be cached by any intermediate
components between the client and server.
 Private: Resources that are marked as private can only be cached by the client.

No cache means that particular resource cannot be cached and thus the whole process is
stopped.

What are the best practices that are to be followed while designing RESTful web
services?

To design a secure RESTful web service, there are some best practices or say points that
should be considered. These are explained as follows:

 Every input on the server should be validated.


 Input should be well formed.
 Never pass any sensitive data through URL.
 For any session, the user should be authenticated.
 Only HTTP error messages should be used for indicating any fault.
 Use message format that is easily understood and is required by the client.
 Unified Resource Identifier should be descriptive and easily understood.

What is Payload?

The request data which is present in the body part of every HTTP message is referred as
‘Payload’. In Restful web service, the payload can only be passed to the recipient through
POST method.

There is no limit of sending data as payload through POST method but the only concern is
that more data with consuming more time and bandwidth. This may consume much of user’s
time also.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Enlist some of the HTTP methods with description.

Mentioned below is the list of HTTP methods with their descriptions:

GET: This is a read only operation which fetches the list of users on the server.

PUT: This operation is used for the creation of any new resource on the server.

POST: This operation is used for updating an old resource or for creating a new resource.

DELETE: As the name suggests, this operation is used for deleting any resource on the
server.

OPTIONS: This operation fetches the list of any supported options of resources that are
available on the server.

What is the difference between PUT method and POST method?

The major difference between the PUT and POST method is that the result generated with
PUT method is always same no matter how many times the operation is performed. On the
other hand, the result generated by POST operation is always different every time.
What is your understanding about JAX-RS?

JAX-RS is defined as the Java API for RESTful web service. Among multiple libraries and
framework, this is considered as the most suitable Java programming language based API
which supports RESTful web service.

Some of the implementations of JAX-RS are:

 Jersey
 RESTEasy
 Apache CFX
 Play
 Among these, Jersey is the most popular framework.

What are HTTP status codes? Enlist few with meaning.

HTTP status codes basically are the representation of the status of the task that has been
performed on the server, with the mode of some codes. Every code has their own meaning.

Some of the HTTP status codes with their meaning are as follows:

 Code 200: This indicates success.


 Code 201: This indicates resource has been successfully created.
 Code 204: This indicates that there is no content in the response body.
 Code 404: This indicates that there is no method available.

There are few more such codes that indicate the status.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

What is a REST Web Service?

There are a set of architectural constraints (we will discuss them shortly) called Rest Style
Constraints. Any service which satisfies these constraints is called RESTful Web Service.

There are a lot of misconceptions about REST Web Services : They are over HTTP , based
on JSON etc. Yes : More than 90% of RESTful Web Services are JSON over HTTP. But
these are not necessary constraints. We can have RESTful Web Services which are not using
JSON and which are not over HTTP.

What are important constraints for a RESTful Web Service?

The five important constraints for RESTful Web Service are

 Client - Server : There should be a service producer and a service consumer.


 The interface (URL) is uniform and exposing resources. Interface uses nouns (not
actions)
 The service is stateless. Even if the service is called 10 times, the result must be the
same.
 The service result should be Cacheable. HTTP cache, for example.
 Service should assume a Layered architecture. Client should not assume direct
connection to server - it might be getting info from a middle layer - cache.

What is Richardson Maturity Model?

Richardson Maturity Model defines the maturity level of a Restful Web Service. Following
are the different levels and their characteristics.

Level 0 : Expose SOAP web services in REST style. Expose action based services
(http://server/getPosts, http://server/deletePosts, http://server/doThis, http://server/doThat etc)
using REST.

Level 1 : Expose Resources with proper URI’s (using nouns). Ex: http://server/accounts,
http://server/accounts/10. However, HTTP Methods are not used.

Level 2 : Resources use proper URI's + HTTP Methods. For example, to update an account,
you do a PUT to . The create an account, you do a POST to . Uri’s look like
posts/1/comments/5 and accounts/1/friends/1.

Level 3 : HATEOAS (Hypermedia as the engine of application state). You will tell not only
about the information being requested but also about the next possible actions that the service
consumer can do. When requesting information about a facebook user, a REST service can
return user details along with information about how to get his recent posts, how to get his
recent comments and how to retrieve his friend’s list.

What are the best practices in designing RESTful APIs?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 While designing any API, the most important thing is to think about the api consumer
i.e. the client who is going to use the service. What are his needs? Does the service uri
make sense to him? Does the request, response format make sense to him?
 In Rest, we think Nouns (resources) and NOT Verbs (NOT actions). So, URI’s should
represent resources. URI’s should be hierarchical and as self descriptive as possible.
Prefer plurals.
 Always use HTTP Methods. Best practices with respect to each HTTP method is
described in the next question.

What are the best practices in using HTTP methods with Restful Web Services?

 GET : Should not update anything. Should be idempotent (same result in multiple
calls). Possible Return Codes 200 (OK) + 404 (NOT FOUND) +400 (BAD
REQUEST)
 POST : Should create new resource. Ideally return JSON with link to newly created
resource. Same return codes as get possible. In addition : Return code 201
(CREATED) is possible.
 PUT : Update a known resource. ex: update client details. Possible Return Codes :
200(OK)
 DELETE : Used to delete a resource.

Can you explain a little bit about JAX-RS?

JAX-RS is the JEE Specification for Restful web services implemented by all JEE compliant
web servers (and application servers).

Important Annotations:

 @ApplicationPath("/"). @Path("users") : used on class and methods to define the url


path.
 @GET @POST : Used to define the HTTP method that invokes the method.
 @Produces(MediaType.APPLICATION_JSON) : Defines the output format of
Restful service.
 @Path("/{id}") on method (and) @PathParam("id") on method parameter : This helps
in defining a dynamic parameter in Rest URL.
@Path("{user_id}/followers/{follower_id}") is a more complicated example.
 @QueryParam("page") : To define a method parameter ex: /users?page=10.

Useful methods:

 Response.OK(jsonBuilder.build()).build() returns json response with status code.


 Json.createObjectBuilder(). add("id",user.getId()); creates a user object.

What are the advantages of Restful web services?

Lightweight : Easy to consume from mobile devices also.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Easy to expose : Little or no restrictions on output format and communication protocol.

Most Restful services use HTTP protocol : Entire web is based on HTTP and is built for
efficiency of HTTP. Things like HTTP caching enable Restful services to be effective.

High Performance : Less xml & soap overhead and More caching enable Restful services to
be highly performant.

What is the difference between REST and SOAP Based Services?

First of all, REST is a set of architectural principles defining how a RESTful service should
look look like. SOAP is a message exchange format. SOAP defines the structure of message
to exchanged. How should the header be? How should the request content be? So, there is no
real comparison between REST and SOAP.

Restful Sample Implementation : JSON over HTTP

SOAP Sample Implementation : XML over SOAP over HTTP

All comparison is between the Sample Restful and SOAP implementations described above.

 REST is built over simple HTTP protocol. SOAP services are more complex to
implement and more complex to consume.
 REST has better performance and scalability. REST reads can be cached, SOAP
based reads cannot be cached.
 REST permits many different data formats (JSON is the most popular choice) where
as SOAP only permits XML.
 SOAP services have well defined structure and interface (WSDL).
 SOAP is based on well defined standards (WS-Security, WS-AtomicTransaction and
WS-ReliableMessaging).

Mention what is the difference between PUT and POST?

“PUT” puts a file or resource at a particular URI and exactly at that URI. If there is already a
file or resource at that URI, PUT changes that file or resource. If there is no resource or file
there, PUT makes one

POST sends data to a particular URI and expects the resource at that URI to deal with the
request. The web server at this point can decide what to do with the data in the context of
specified resource

PUT is idempotent meaning, invoking it any number of times will not have an impact on
resources.

However, POST is not idempotent, meaning if you invoke POST multiple times it keeps
creating more resources

Mention which markup language can be used in restful web api?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

JSON and XML are the two markup language that can be used in restful web api

Mention what is the difference between RPC or document style web services? How you
determine to which one to choose?

In document style web services, we can transport an XML message as part of SOAP request
which is not possible in RPC style web service. Document style web service is most
appropriate in some application where XML message behaves as document and content of
that document can alter and intention of web service does not rely on the content of XML
message.

Mention what is JAX-WS and JAX-RS?

Both JAX-WS and JAX-RS are libraries (APIs) for doing communication in various ways in
Java. JAX-WS is a library that can be used to do SOAP communication in JAVA, and JAX-
RS lets you do the REST communication in JAVA.

List out the tools or API for developing or testing web api?

Testing tools for web services for REST APIs includes

Spring REST web service using MVC

 Jersey API
 CFX
 Axis
 Restlet

Explain the architectural style for creating web API?

The architectural style for creating web api are

 HTTP for client server communication


 XML/JSON as formatting language
 Simple URI as the address for the services
 Stateless communication

Mention what are the HTTP methods supported by REST?

HTTP methods supported by REST are:

 GET: It requests a resource at the request URL. It should not contain a request body
as it will be discarded. Maybe it can be cached locally or on the server.
 POST: It submits information to the service for processing; it should typically return
the modified or new resource
 PUT: At the request URL it update the resource
 DELETE: At the request URL it removes the resource
 OPTIONS: It indicates which techniques are supported

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 HEAD: About the request URL it returns meta information

Mention whether you can use GET request instead of PUT to create a resource?

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

Mention what are resources in a REST architecture?

Resources are identified by logical URLs; it is the key element of a RESTful design. Unlike,
SOAP web services in REST, you view the product data as a resource and this resource
should contain all the required information.

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 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.

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 difference between Restlets and Jersey ?

This REST web service interview questions is open for you all, post you answer in comment
section.

What is RESTEasy ?

RESTEasy is another REST framework introduced in JBoss Application Server.

What are the tools used for creating RESTFull web services ?

You can use AJAX(Asynchronous JavaScript with XAML) and Direct Web Removing to
consume web serives in web application. Both Eclipse and NetBeans also supported
development of RESTFul services.

How to display custom error pages using RestFull web services ?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

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".

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.

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 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 are the advantages of Web Services?

Some of the advantages of web services are:

 Interoperability: Web services are accessible over network and runs on HTTP/SOAP
protocol and uses XML/JSON to transport data, hence it can be developed in any
programming language. Web service can be written in java programming and client
can be PHP and vice versa.
 Reusability: One web service can be used by many client applications at the same
time.
 Loose Coupling: Web services client code is totally independent with server code, so
we have achieved loose coupling in our application.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 Easy to deploy and integrate, just like web applications.


 Multiple service versions can be running at same time.

What are different types of Web Services?

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.

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 are advantages of SOAP Web Services?

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.

What are web services?

Web services are ways of communication between two application over network. It allows
you to expose business logic using API.

For example:

Lets say you are java developer, you can create web service and expose API over internet and
any other developer (lets say .net developer ) can access it.

What are features of web services?

 Interoperability
 Reuse already developed(old) functionality into new software:
 Loosely Coupled

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 Extensibility

What are different types of web services?

 SOAP
 Restful web services

What is SOAP?

SOAP stands for Simple object access protocol. It is protocol to exchange information using
request and response in XML format over transport protocol such as HTTP, SMTP etc.

Mention what is SOAP?

SOAP means Simple Object Access Protocol is a type of communication protocol, a way to
structure data prior to transmitting it and is based on XML standard. It is developed to enable
communication between applications of different platforms and programming language via
internet. It can use the range of protocols such as FTP, HTTP, SMTP, Post office protocol
3(POP3) to carry documents. In other words, it is an XML based protocol to transfer between
computers.

What are the elements of SOAP message structure?

It is an ordinary XML document that contains the elements as a SOAP message

 Envelope: It defines the start and end of the message


 Header: It is an optional element. Contains information about the message being sent
 Body: It contains the XML data comprising the message being sent
 Fault: It provides the information about errors occurred while processing the message.

Mention what is the difference between JSON and SOAP?

JSON is standard to represent human readable data. SOAP is a protocol requirement for
transmitting information and calling web-services using XML.

Mention what is the major obstacle faced by the users using SOAP?

The major obstacle faced by the users using SOAP is a firewall security mechanism. This
lock all the ports leaving few like HTTP port 80 and the HTTP port used by SOAP that
bypasses the firewall. The technical complaints against SOAP is that it mixes the
specification for message transport with the specification for message structure.

Mention what is the message format used in SOAP?

Message format is written by using the XML language. The message format is standard, and
it is widely used. The message format is like

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

POST/InStock HTTP/1.1

Host: localhost (www.xyz.org)

Content Type: application/soap+xml; charset=utf-8

Content length: 300

SOAPAction:http://www.guru99.org/2003/05/soap-envelop>

<?xml version= “1.0”?>

<soap:Envelop xmlns:soap= http://www.guru99.org/2003/05/soap-envelop>

<soap:Header>

</soap:Header>

<soap:Body>

<m:CareerName>Guru99</m:CareerName>

</soap:Body>

</soap:Envelope>

Mention what is the response format for SOAP response?

SOAP response would be like

HTTP/1.0 200 OK

Content Type: text/xml; charset=utf-8

Content-Length: nnn

<?xml version= “1.0”?>

<SOAP-ENV:Envelop

xmlns: SOAP-ENV= http://www.guru99.org/2003/05/soap-envelope”

SOAP-ENV: encoding style= http://www.guru99.org/2003/05/soap-encoding>

<SOAP-ENV: Body xmlns:m=http://www.xyz.org/quotation”>

<m:GetQuotationResponse>

<m:Quotation > Here is the Quotation</m:Quotation>

</m:QuotationRequest>

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

</SOAP-ENV:Body>

</SOAP-ENV: Envelope>

Mention what is SOAP HTTP Binding?

HTTP works over TCP/IP. The HTTP client links to an HTTP server using TCP. SOAP
HTTP is a method that conforms with the SOAP encoding rules.

HTTP + XML = SOAP

A SOAP request could be an – HTTP GET request or HTTP POST

The HTTP POST request mentions atleast two HTTP headers: Content-Type and Content-
Length

Mention what are the syntax rules for SOAP message?

 SOAP message must use encoded XML


 A SOAP envelope namespace must be used
 A SOAP encoding namespace must be used
 A SOAP message must not consist of a DTD reference
 A SOAP message must not have XML processing instruction

Mention the advantages of SOAP?

 It is a platform independent and language independent


 SOAP de-couples the encoding and communications protocol from the runtime
environment
 Web service can obtain or receive a SOAP payload from a remote service, and the
platform information of the source are entirely unrelated
 Anything can generate an XML, from Perl scripts to C++ code to J2EE app servers
 To send and receive messages it uses XML
 It uses standard internet HTTP protocol
 SOAP runs over HTTP; it eradicates firewall problems. When using protocol HTTP
as the protocol binding, an RPC call maps automatically to an HTTP request and an
RPC response maps to an HTTP response
 Compared to RMI, CORBA and DCOM SOAP is very simple
 A protocol for moving information in a distributed and decentralized environment
 SOAP is the transport protocol independent and can be availed in co-ordination with a
variety of protocols
 It is the vendor neutral

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Explain how user use the facilities that are provided by SOAP?

PutAddress(): It is used to enter an address in the webpage. It carries address instance on


the SOAP call

PutListing(): It is used to enable the insertion of a complete XML document into the
webpage. It receives the XML file as an argument and transport the XML file to XML parser
liason, which reads it and puts it as a parameter in the SOAP call

GetAddress(): It is used to determine a query name and retrieves the result that is best
matched with a query. In the form of text string, the name is sent to the SOAP call

GetAllListing(): It is used to return the complete list in an XML format.

Mention what is the transport method in SOAP?

Application layer and transport layers of a network are used by SOAP. HTTP and SMTP are
the valid application layer protocol used as transport for SOAP. HTTP is more preferable as
it works well with current internet infrastructure especially with firewalls.

The SOAP requests can be sent via an HTTP GET method while the specification includes
details on HTTP POST only.

Mention what is the end point in web services?

IP address of the server where the web services are running is the end point in web services.

Explain what is SOAP envelop element?

A SOAP envelop indicates the start and end of the message, so that the receiver knows when
an entire message has been received. In other words, a SOAP envelop is a packaging
mechanism.

List out important characteristics of a SOAP envelop element?

The characteristic of SOAP element is

 SOAP message has a root Envelope element


 Envelope is a mandatory part of SOAP message
 If an Envelope contains a header element, it should not contain more than one. Also, it
should appear as the first child of the Envelope
 When SOAP version changes envelop version also changes
 SOAP envelope is specified by prefix ENV and Envelope element
 The optional SOAP encoding is also specified using a namespace and the optional
encodingstyle element

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Mention what is the difference between a web service and SOA?

SOA is a software design principle and an architectural pattern for implementing loosely
coupled, reusable and coarse grained services. Using any protocols such as HTTP, HTTPS,
JMS, SMTP, etc. you can implement SOA. The message can be in Data Transfer Objects or
in XML.

What are important components for SOAP?

 Simple access object protocol (SOAP)


 Web Services Description Language (WSDL)
 Universal Description, Discovery and Integration(UDDI)

What is WSDL?

WSDL stands for Web Service Description Language. It is an XML file that describes the
technical details of how to implement a web service, more specifically the URI, port, method
names, arguments, and data types. You can understand following details using WSDL

 Port / Endpoint – URL of the web service


 Input message format
 Output message format
 Security protocol that needs to be followed

What is UDDI?

UDDI stands for Universal Description, Discovery and Integration.It is a directory service.
Web service provider can register themselves with a UDDI and make themselves available
through it for discovery.

What is JAX-WS?

JAX-WS stands for Java API for XML Web Services. JAX-WS is standard XML based Java
API which is used to create SOAP web services.

Report Ad

What are some important annotations for JAX-WS?

 @WebService
 @WebMethod
 @SOAPBinding

What do you mean by end point in terms of SOAP?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

End point is nothing but URL which other application can use to access it.

for example:

end point:http://localhost:8080/WS/HelloWorld

How can you access WSDL for web service?

You just need to put ?wsdl at the end of end point URL.

for example:

end point:http://localhost:8080/WS/HelloWorld

WSDL url: http://localhost:8080/WS/HelloWorld?wsdl

What is wsimport?

wsimport is utility which generates java classes from WSDL. It is part of JDK 6.

What is sun-jaxws.xml file?

This file provides endpoint details about JAX-WS web service which is deployed on
tomcat.It is available at WEB-INF directory.

For example:

<?xml version="1.0" encoding="UTF-8"?>

<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">

<endpoint

name="HelloWorldWS"

implementation="org.arpit.javapostsforlearning.webservice.HelloWorldImpl"

url-pattern="/HelloWorldWS"/>

</endpoints>

<?xml version="1.0" encoding="UTF-8"?>

<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">

<endpoint

name="HelloWorldWS"

implementation="org.arpit.javapostsforlearning.webservice.HelloWorldImpl"

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

url-pattern="/HelloWorldWS"/>

</endpoints>

What is JAX-RS?

Java API for RESTful Web Services (JAX-RS), is a set if APIs to create web service which
supports REST architecture. JAX-RS is part of the Java EE6, and help developers to create
REST web application easily.

What are some important annotations which you use to create Restful web services?

Some of important annotations which are used for creating web services are:

@Path : This is used to set path for URI at class level or method level

@GET,@POST,@PUT,@DELETE : There are annotations corresponds to HTTP methods

@Produces(MediaType.TEXT_XML [, more-types ]): @Produces defines which MIME type


is delivered by a method

@PathParam: Used to inject values from the URL into a method parameter.

@Consumes(MediaType.TEXT_XML) : @Cosumes defines which MIME type will be


consumed by the method .

What are ways to test SOAP web services?

For testing SOAP :

SOAPUI

For testing Restful web services:

Postman for chrome browser

poster for firefox

What are disadvantages of SOAP Web Services?

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.
 Can’t be tested easily in browser

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

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 UDDI?

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.

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:

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 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.

Can we maintain user session in web services?

Web services are stateless so we can’t maintain user sessions in web services.

What is the difference between SOA and a web service?

 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 to consumers.

What is SOAP?

SOAP (Simple Object Access Protocol) is a transport protocol for sending and receiving
requests and responses on XML format, which can be used on top of transport protocols such
as HTTP, SMTP, UDP, etc.

How to decide which one of web service to use REST or SOAP?

“REST vs SOAP” we can rephrased to "Simplicity vs Standard". Of course, "Simplicity" with


REST at most cases wins, it wins in performance, scalability and support for multiple data
formats, but SOAP is favored where service requires comprehensive support for security
(WS-security) and transactional safety (ACID).

What is WSDL?

WSDL (Web Services Description Language) is an XML format for describing web services
and how to access them.

What is JAX-WS?

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

What is JAXB?

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.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Can we send soap messages with attachments?

Yes, we can send different formats such as PDF document, image or other binary file with
soap messages as an attachment. Messages send using the binary data. SOAP messages is
attached with MIME extensions that come in multipart/related.

An example:

MIME-Version: 1.0

Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml;

start="<claim061400a.xml@ javahungry.com>"

Content-Description: This is the optional message description.

<?xml version='1.0' ?>

<SOAP-ENV:Envelope

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

<SOAP-ENV:Body>

..

<theSignedForm href="cid:[email protected]"/>

..

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

--MIME_boundary

Content-Type: image/tiff

Content-Transfer-Encoding: binary

Content-ID: <[email protected]>

...binary TIFF image...

--MIME_boundary—

What is MTOM?

MTOM (Message Transmission Optimization Mechanism) is a mechanism for transmitting


large binary attachments with SOAP messages as raw bytes, allowing for smaller messages.

What is XOP?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

XOP (XML-binary Optimized Packaging) is a mechanism defined for the serialization of


XML Information Sets that contain binary data, as well as deserialization back into the XML
Information Set.

What is a SOAP envelope element?

SOAP envelop element is the root element of a SOAP message which defines the XML
document as a SOAP message.

An example:

<?xml version="1.0"?>

<soap:Envelope

xmlns:soap="http://www.w3.org/2001/12/soap-envelope"

soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

...

Message information

...

</soap:Envelope>

What does a SOAP namespace defines?

SOAP namespace defines the Envelope as a SOAP Envelope.

An example:

xmlns:soap=http://www.w3.org/2001/12/soap-envelope

What is the SOAP encoding?

SOAP encoding is a method for structuring the request which is suggested within the SOAP
specification, known as the SOAP serialization.

What does SOAP encodingStyle attribute defines?

SOAP encodingStyle defines the serialization rules used in a SOAP message. This attribute
may appear on any element, and is scoped to that element's contents and all child elements
not themselves containing such an attribute. There is no default encoding defined for a SOAP
message.

An example:

SOAP-ENV:encodingStyle="http://www.w3.org/2001/12/soap-encoding"

What are 2 styles web service’s endpoint by using JAX-WS?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

RPC (remote procedure call) style web service in JAX-WS;

document style web service in JAX-WS.

What is encoding rules for header entries?

a header entry is identified by its fully qualified element name, which consists of the
namespace URI and the local name. All immediate child elements of the SOAP Header
element must be namespace-qualified.

the SOAP encodingStyle attribute may be used to indicate the encoding style used for the
header entries.

the SOAP mustUnderstand attribute and SOAP actor attribute may be used to indicate how to
process the entry and by whom.

What is the wsimport tool?

The wsimport tool is used to parse an existing Web Services Description Language (WSDL)
file and generate required files (JAX-WS portable artifacts) for web service client to access
the published web services:
https://docs.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html

What is the wsgen tool?

The wsgen tool is used to parse an existing web service implementation class and generates
required files (JAX-WS portable artifacts) for web service deployment:
http://docs.oracle.com/javase/6/docs/technotes/tools/share/wsgen.html

Whether can use GET request instead of POST to create a resource?

It is not possibly, because GET can’t change a resource.

What is the difference between PUT and POST?

Need to use PUT when can update a resource completely through a specific resource. For
example, if know that an article resides at http://javahungry.blogspot.com/article/123, can
PUT a new resource representation of this article through a PUT on this URL. If do not know
the actual resource location for instance, when add a new article, can use POST.

PUT is idempotent, while POST is not. It means if use PUT an object twice, it has no effect.

What is WADL?

WADL (Web Application Description Language) is a XML description of a deployed


RESTful web application.

What are frameworks available to implement REST web services?

Jersey, Restlet, EasyRest, etc.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

What is the Restlet framework?

Restlet is a lightweight, comprehensive, open source RESTful web API framework for the
Java platform.

It has advantages such as

 websocket and server-sent events support;


 HTTP/2 support;
 transparent HTTP PATCH support;
 client cache service;
 fluent APIs.

What is the Jersey framework?

Jersey is open source framework for developing RESTful Web Services in Java that provides
support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference
Implementation. It has advantages such as

contains support for Web Application Description Language (WADL);

contains Jersey Test Framework which lets run and test Jersey REST services inside JUnit;

supports for the REST MVC pattern, which would allow to return a View from Jersey
services rather than just data.

What is the RESTeasy framework?

 RESTeasy is a JBoss project, which implements of the JAX-RS specification. It has


benefits such as
 fully certified JAX-RS implementation; supports HTTP 1.1 caching semantics
including cache revalidation;
 JAXB marshalling into XML, JSON, Jackson, Fastinfoset, and Atom as well as
wrappers for maps, arrays, lists, and sets of JAXB Objects;
 OAuth2 and Distributed SSO with JBoss AS7;
 rich set of providers for: XML, JSON, YAML, Fastinfoset, Multipart, XOP, Atom,
etc.

What is the difference between AJAX and REST?

 in Ajax, the request are sent to the server by using XMLHttpRequest objects; REST
have a URL structure and a request/response pattern the revolve around the use of
resources;
 Ajax eliminates the interaction between the customer and server asynchronously;
REST requires the interaction between the customer and server;

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 Ajax is a set of technology; REST is a type of software architecture and a method for
users to request data or information from servers.

What does a @Path annotation do?

@Path annotation binds URI pattern to a Java method.

What does a @PathParam do?

@PathParam annotation injects the value of URI parameter that defined in @Path expression.

What does a @QueryParam do?

@QueryParam annotation injects URI query parameter into Java method.

What does a @MatrixParam do?

@MatrixParam are a set of “name=value” in URI path.

What does a @FormParam do?

@FormParam bind HTML form parameters value to a Java method.

How to get HTTP request header in JAX-RS (2 ways)?

inject directly with @HeaderParam;

pragmatically via @Context.

How to download file in JAX-RS?

put @Produces(“?”) on service method, with a Response return type. Instead “?” write a type
text/plain, image/png, etc.

set “Content-Disposition” in Response header to tell browser pop up a download box for user
to download.

What is difference between SOA and Web Services?

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.

What is the use of Accept and Content-Type Headers in HTTP Request?

These are important headers in Restful web services. Accept headers tells web service what
kind of response client is accepting, so if a web service is capable of sending response in
XML and JSON format and client sends Accept header as “application/xml” then XML

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

response will be sent. For Accept header “application/json”, server will send the JSON
response.

Content-Type header is used to tell server what is the format of data being sent in the request.
If Content-Type header is “application/xml” then server will try to parse it as XML data. This
header is useful in HTTP Post and Put requests.

How would you choose between SOAP and REST web services?

Web Services work on client-server model and when it comes to choose between SOAP and
REST, it all depends on project requirements. Let’s look at some of the conditions affecting
our choice:

What is JAX-WS API?

JAX-WS stands for Java API for XML Web Services. JAX-WS is XML based Java API to
build web services server and client application. It’s part of standard Java API, so we don’t
need to include anything else which working with it. Refer to JAX-WS Tutorial for a
complete example.

Name some frameworks in Java to implement SOAP web services?

We can create SOAP web services using JAX-WS API, however some of the other
frameworks that can be used are Apache Axis and Apache CXF. Note that they are not
implementations of JAX-WS API, they are totally different framework that work on Servlet
model to expose your business logic classes as SOAP web services. Read more at Java SOAP
Web Service Eclipse example.

Name important annotations used in JAX-WS API?

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

 @WebService
 @SOAPBinding
 @WebMethod

What is use of javax.xml.ws.Endpoint class?

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 server.

How to get WSDL file of a SOAP web service?

WSDL document can be accessed by appending ?wsdl to the SOAP endoint URL. In above
example, we can access it at http://localhost:8888/testWS?wsdl location.

What is sun-jaxws.xml file?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

This file is used to provide endpoints details when JAX-WS web services are deployed in
servlet container such as Tomcat. This file is present in WEB-INF directory and contains
endpoint name, implementation class and URL pattern.

What is JAX-RS API?

Java API for RESTful Web Services (JAX-RS) is the Java API for creating REST web
services. JAX-RS uses annotations to simplify the development and deployment of web
services. JAX-RS is part of JDK, so you don’t need to include anything to use it’s
annotations.

Name some implementations of JAX-RS API?

There are two major implementations of JAX-RS API.

Jersey: Jersey is the reference implementation provided by Sun. For using Jersey as our
JAX-RS implementation, all we need to configure its servlet in web.xml and add required
dependencies. Note that JAX-RS API is part of JDK not Jersey, so we have to add its
dependency jars in our application.

RESTEasy: RESTEasy is the JBoss project that provides JAX-RS implementation.

What is wsimport utility?

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.

Name important annotations used in JAX-RS API?

Some of the important JAX-RS annotations are:

 @Path: used to specify the relative path of class and methods. We can get the URI of
a webservice by scanning the Path annotation value.
 @GET, @PUT, @POST, @DELETE and @HEAD: used to specify the HTTP
request type for a method.
 @Produces, @Consumes: used to specify the request and response types.
 @PathParam: used to bind the method parameter to path value by parsing it.

What is the use of @XmlRootElement annotation?

XmlRootElement annotation is used by JAXB to transform java object to XML and vice
versa. So we have to annotate model classes with this annotation.

What is WSDL?

WSDL stands for Web Services Description Language. It is a xml document containing
information about web services such as method name, method parameter etc. More details...

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

What is UDDI?

UDDI stands for Universal Description, Discovery and Integration. It is a XML based
framework for describing, discovering and integrating web services. It contains a list of
available web services. WSDL is the part of UDDI. More details...

What is Interoperability in Web services?

Web services facilitate various applications to communicate with each other and share data
and services among themselves. Other applications can also use the web services. For
example, a VB or .NET application can communicate with a Java web services and vice
versa. Web services are used to make the application platform and technology independent.

Explain the loosely coupled architecture of web services.

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.

What are the advantages of having XML based Web services?

Using XML eliminates any networking, operating system, or platform binding. So Web
Services based applications are highly interoperable application at their core level.

What do you mean by synchronicity?

Synchronicity is used to bind 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. On the other hand, synchronous operations facilitate a client to invoke a service
and then execute other functions.

What is the usage of Service Transport Layer in Web service protocol stack?

The Service Transport Layer is used to transport messages between applications.

This layer includes Hyper Text Transport Protocol (HTTP), Simple Mail Transfer Protocol
(SMTP), File Transfer Protocol (FTP), and newer protocols like Blocks Extensible Exchange
Protocol (BEEP).

What is the usage of Service Description layer in Web Service Protocol Stack?

The Service Description layer is used to describe the public interface to a specific web
service. Currently, service description is handled via the Web Service Description Language
(WSDL).

What is the usage of Service Discovery layer in Web Service Protocol Stack?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

The Service Discovery layer is used for centralizing services into a common registry and
providing easy publish/find functionality.

Currently, service discovery is handled via Universal Description, Discovery, and Integration
(UDDI).

How to set different status code in HTTP response?

For setting HTTP status code other than 200, we have to use javax.ws.rs.core.Response class
for response. Below are some of the sample return statements showing it’s usage.

return Response.status(422).entity(exception).build();

return Response.ok(response).build(); //200

Explain different HTTP methods supported by RESTful web services?

Enlisted below are some common HTTP methods along with their functions that are
supported by RESTful web services

GET: Read-only access to the resource.

PUT: Creation of new resource.

DELETE: Removal of a resource.

POST: Update of an existing resource.

OPTIONS: Get supported operations on the resource.

HEAD: Returns HTTP header only, nobody.

What is a resource in RESTful web service and how it is represented?

Resource is said to be a fundamental concept having a type and relationship with other
resources. In REST architecture, each content is considered as the resource and they are
identified by their URIs.

Resources are represented with the help of XML, JSON, text etc in RESTful architecture.

What are the core components of HTTP request and HTTP response?

HTTP request has following 5 major components

HTTP Requests Meaning/work

Verb Indicate HTTP methods like GET, PUT, POST, etc

URI Identifies the resource on server

HTTP Version Indicates version.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Request Header Contains metadata like client type, cache settings, message body
format, etc for HTTP request message.

Request Body Represents content of the message.

HTTP response has following 4 major components

HTTP Response Meaning/work

Status/Response code Indicates the status of the server for requested resource.

HTTP version Represents HTTP version.

Response Header Consists of metadata like content length, content type, server length,
etc for HTTP response message.

Response Body Represents response message content.

What is the purpose and format of URI in REST architecture?

Purpose of URI is to locate resources on the server that are hosting web services.

What are safe REST operations?

Safe REST operations are HTTP methods that do not modify resources. For example, using
GET or HEAD on a resource URL, should NEVER change the resource. But it is still
possible, that safe operations do change things on a server or resource. For example: GET
http://localhost:8080/api/employees/1111/delete HTTP/1.1 but it is incorrect, this would
actually delete the employee i.e. Safe methods are methods that can be cached, prefetched
without any repercussions to the resource.

What are idempotent operations? Why is idempotency important?

Idempotent operations are those HTTP methods that can be called repetitively many times
without different outcomes. It would not matter if the method is called only once, or many
times over. The result should be the same. Again, this only applies to the result, not the
resource itself.

Is REST scalable and/or interoperable?

Yes, REST is scalable and interoperable.

What is the RestTemplate and It’s advantages?

In Spring REST client, The RestTemplate is the core class for client-side access to Spring
RESTful web services. It communicates HTTP server using RESTful constraints. It is very
similar to other template classes in the Spring like JdbcTemplate and HibernateTemplate etc.
In Spring, RestTemplate provides higher level implementation of corresponding HTTP
methods such as GET, POST, PUT, DELETE, HEAD etc. It provides the methods to

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

communicate by using these HTTP methods with URI template, URI params, request object
and response type as arguments. Read More about RestTemplate.

Which HTTP methods does REST use?

RestTemplate provides higher level implementation of corresponding HTTP methods such as


GET, POST, PUT, DELETE, HEAD etc.

What is an HttpMessageConverter?

HttpMessageConverter is a strategy interface that specifies a converter that can convert from
and to HTTP requests and responses. Internally Spring MVC uses it to convert the Http
request to an object representation and back. Message converters are used to marshall and
unmarshall Java Objects to and from JSON, XML, etc – over HTTP. Read More about
HttpMessageConverter in Spring.

Is REST normally stateless?

Yes.

What does @RequestMapping do?

@RequestMapping can be applied to the controller class as well as methods. This annotation
for mapping web requests onto specific handler classes and/or handler methods. Read more
about @RequestMapping annotation.

Is @Controller a stereotype? Is @RestController a stereotype?

Yes.

What is the difference between @Controller and @RestController?

The key difference between a traditional Spring MVC @Controller and the RESTful web
service @RestController is the way the HTTP response body is created. While the traditional
MVC controller relies on the View technology, the RESTful web service controller simply
returns the object and the object data is written directly to the HTTP response as JSON/XML
by registered HttpMessageConverters.

When do you need @ResponseBody?

When you use the @ResponseBody annotation on a method, Spring converts the return value
and writes it to the http response automatically. Each method in the Controller class must be
annotated with @ResponseBody.

What does @PathVariable do?

@PathVariable is used to pass parameter along with the url, sometimes we need to pass
parameters along with the url to get the data. Spring MVC provides support for customizing

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

the URL in order to get data. To achieving this purpose @PathVariable annotation is used in
Spring mvc framework.

What is the HTTP status return code for a successful DELETE statement?

Either we can return HTTP status 204 (NO CONTENT) with no response body or return
HTTP status 200 (OK) along with a response body with representation of the deleted item.

What does CRUD mean?

In Spring REST, the primary or most-commonly-used HTTP verbs are POST, GET, PUT,
PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD)
operations, respectively.

Is REST secure? What can you do to secure it?

REST is nothing but it architectural desgin or paradigms to design restful web service. So
REST does not provide any security constraints by default but we can implement it in the
RESTful web services by using security layers like transport layer security (TLS), auth token
security.

Where do you need @EnableWebMVC?

@EnableWebMvc- It used for enabling spring mvc behavior i.e. it is responsible for
registering Spring MVC required Bean Post Processors in the application as like
Jackson2JsonMessageConverter etc.

Name some common http response codes. When do you need @ResponseStatus?

 2xx Success
 200 OK
 201 Created
 204 No Content
 3xx Redirection
 304 Not Modified
 4xx Client Error
 400 Bad Request
 401 Unauthorized
 403 Forbidden
 404 Not Found
 409 Conflict
 5xx Server Error
 500 Internal Server Error
 503 Service Unavailable

@ResponseStatus annotation available on custom exceptions and to map these exceptions to


HTTP status codes.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Does REST work with transport layer security (TLS)?

Yes. Transport Layer Security can encrypt the communication to a RESTful Webservice and
authenticate the server to a client.

Do you need Spring MVC in your classpath for Spring REST?

Yes, Spring REST uses the Spring MVC annotations like @RestController, @RequestBody
and @ResponseBody etc.

Format of URI

<protocol>://<service-name>/<ResourceType>/<ResourceID>

Explain the term statelessness in terms of RESTful web services?

In REST architecture, there is a restriction where a REST web service is not allowed to keep
a client state on the server. Such condition is known as ‘Statelessness’. In such situation, the
client passes its context to the server and in turn, the server stores the context in order to
process client’s further requests.

Enlist advantages and disadvantages of statelessness?

The advantages of statelessness include

 Each and every method requests are treated independently.


 Application design is simplified as it does not maintain client’s previous interaction.
 Works with HTTP protocol as it shares the feature of being statelessness.

The disadvantage of statelessness includes

 Every time client interaction takes place, web services are to be provided with extra
information about each request so that they can interpret the client’s state.

For designing a secure RESTful web service, what are the best factors that should be
followed?

 As HTTP URL paths are used as a part of RESTful web service, so they need to be
secured. Some of the best practices include the following
 Perform validation of all inputs on the server from SQL injection attacks.
 Perform user’s session based authentication whenever a request is made.
 Never use sensitive data like username, session token password, etc through URL.
These should be passed via POST method.
 Methods like GET, POST, PUT, DELETE, etc should be executed with proper
restrictions.
 HTTP generic error message should be invoked wherever required.
 SOAPUI Web Services

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

What are the various approaches available for developing SOAP based web services?

There are basically 2 different approaches available for developing SOAP-based web
services. These are explained as follows

Contract-first approach: In this approach, the contract is defined first by XML and WSDL
and then java classes are derived from the contract.

Contract-last approach: In this approach, java classes are defined first and then the contract
is generated which is usually the WSDL file from the java class.

“Contract-first” method is the most preferred approach.

Explain the major obstacle faced by SOAP users?

One of the major hindrance observed by users of SOAP is the ‘Firewall security mechanism’.
In this case, all the HTTP ports except those which bypass firewall are locked. In some cases,
a technical issue of mixing specification of message transport with message structure is also
observed.

What are the elements of a SOAP message?

SOAP is just like other XML document and has following elements

 Envelope: This element is defined as the mandatory root element. It translates the
XML document and determines the start and end of the SOAP message.
 Header: This element contains the optional header attributes of the message that
contains specific information of the application. This element can occur multiple
times and are intended to add new features and functionalities.
 Body: This element is mandatory and contains the call and response messages. It is
also defined as the child element of the envelope containing all the application
derived XML data that has been exchanged as a part of SOAP message.
 Fault element: Errors that occur during processing of the messages are handled by the
fault element. If the error is present, then this element appears as a child element of
the body. However, there can only be one fault block.

What are the important characteristics of SOAP envelope element?

We have seen the basic work of a SOAP envelope element in the previous answer, now let us
see some of its characteristics

 SOAP envelope is a packaging mechanism.


 Every Soap message has a mandatory root envelope message.
 Only one body element is allowed for each envelope element.
 As the SOAP version changes, envelope changes.
 If the header element is present, it should appear as the first child.
 Prefix ENV and envelope element is used for specification.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 A namespace and an optional encoding style are used in case of optional SOAP
encoding.

Enlist few syntax rules applicable for SOAP message?

Enlisted below are some important syntax rules that are applicable for SOAP message

 A SOAP message
 Must be encoded using XML.
 Must use the SOAP envelope namespace.
 Must use the SOAP encoding namespace.
 Must not contain the DTD reference.
 Must not contain XML processing instructions.

Define SOA?

A Service Oriented Architecture (SOA) is basically defined as an architectural pattern


consisting of services. Here application components provide services to the other components
using communication protocol over the network. This communication involves data
exchanging or some coordination activity between services.

Some of the key principles on which SOA is based are mentioned below

 The service contract should be standardized containing all the description of the
services.
 There is loose coupling defining the less dependency between the web services and
the client.
 It should follow Service Abstraction rule, which says the service should not expose
the way functionality has been executed to the client application.
 Services should be reusable in order to work with various application types.
 Services should be stateless having the feature of discoverability.
 Services break big problems into little problems and allow diverse subscribers to use
the services.

What is difference between Restlets and Jersey ?

This REST web service interview questions is open for you all, post you answer in comment
section.

What is RESTEasy ?

RESTEasy is another REST framework introduced in JBoss Application Server. This was
rather easy REST interview questions. you can answer in detail only if you have used this or
working in JBoss.

What are the tools used for creating RESTFull web services ?

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

You can use AJAX(Asynchronous JavaScript with XAML) and Direct Web Removing to
consume web serives in web application. Both Eclipse and NetBeans also supported
development of RESTFul services.

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".

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.

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.

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.

Explain the actions performed by SOAPUI?

SOAPUI is an open-source, free and cross-platform functional testing solution. Mentioned


below are some actions performed by SOAPUI

 It can help create functional, security and load testing test suites.
 Data driven testing and scenario based testing is also performed.
 It has the ability to impersonate web services as well as has got built-in reporting
abilities.
 Web Services Security

What are the primary security issues of web service?

To ensure reliable transactions and secure confidential information, web services requires
very high level of security which can be only achieved through Entrust Secure Transaction

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Platform. Security issues for web services are broadly divided into three sections as described
below

1) Confidentiality: A single web service can have multiple applications and their service
path contains a potential weak link at its nodes. Whenever messages or say XML requests are
sent by the client along with the service path to the server, they must be encrypted. Thus,
maintaining the confidentiality of the communication is a must.

2) Authentication: Authentication is basically performed to verify the identity of the users as


well as ensuring that the user using the web service has the right to use or not? Authentication
is also done to track user’s activity. There are several options that can be considered for this
purpose

Application level authentication

HTTP digest and HTTP basic authentication

Client certificates

3) Network Security: This is a serious issue which requires tools to filter web service traffic.

What do you know about foundation security services?

Foundation security services consist of the following

 Integration
 Authentication
 Authorization
 Digital Signatures
 Encryption processes

What is Entrust Identification Service?

Entrust Identification Service is categorized under Entrust Secure Transaction Platform which
provides essential security capabilities to ensure secure transactions. This usually allows
companies to fully control the identities that are trusted to perform web service transactions.

What is Entrust Entitlements Service?

Entrust Entitlement service is those whose task is to verify the services that are attempting to
access the web services. It basically ensures security in business operations as well as some
authentication services.

What is Entrust Privacy Service?

As the name suggests, Entrust Privacy Service perform encryption of the data so that only
concerned parties are able to access the data. It basically deals with two factors

Confidentiality

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Security

Explain WSDL?

WSDL stands for Web service Description Language. It is a simple XML document which
comes under the Service Description layer of Web Service Protocol Stock and describes the
technical details or locates the user interface to web service. Few of the important
information present in WSDL document are

 Method name
 Port types
 Service end point
 Method parameters
 Header information
 Origin, etc

What are the different elements of WSDL documents?

The different elements of WSDL document along with brief description is enlisted below

Types: This defines the message data types, which are in the form of XML schema, used by
the web services.

Message: This defines the data elements for each operation where messages could be the
entire document or an argument that is to be mapped.

Port Type: There are multiple services present in WSDL. Port type defines the collection of
operations that can be performed for binding.

Binding: Determines and defines the protocol and data format for each port type.

Operations: This defines the operations performed for a message to process the message.

Explain the message element in WSDL?

Message element describes the data that has been exchanged between the consumer and the
web service providers. Every web service consists of two messages and each message has
zero or more <part> parameters. The two messages are

Input: Describes the parameter for the web service

Output: Describes the return data from the web service.

Enlist the operation types response used in WSDL?

WSDL basically defines 4 types of Operation type responses. These are enlisted below

One-way: Receives a message but does not return response.

Request-Response: Receives a request and return a response.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

Solicit-Response: Sends a request and wait for a response.

Notification: Sends a message but does not wait for a response.

Among these, Request-Response is the most common operation type.

Is binding between SOAP and WSDL possible?

Yes, it is possible to bind WSDL to SOAP. The binding is possible by basically two
attributes

Name: Defines the name of the binding.

Type: Defines the port for the binding.

For SOAP binding, two attributes need to be declared

Transport: Defines the SOAP protocol to be used i.e. HTTP.

Style: This attribute can be ‘rpc’ or ‘document’.

Explain <definition> element?

Definition element is described as the root of WSDL document which defines the name of the
web service as well as act as a container for all the other elements.

What are the two attributes of <Port> element in WSDL?

Every port element is related to a specific binding by defining an individual endpoint. The
port element has following two attributes

Name: This attribute provides the unique name within the WSDL document.

Binding: This attribute refers to the process of binding which has to be performed as per the
linking rules defined by WSDL.

What are the points that should be considered by ports while binding?

WSDL allows extensibility elements which are used to specify binding information. Below
are few important points that should be kept in consideration while binding.

A port must not

 Specify more than one address.


 Specify any binding information other than address information.

Define web service protocol stack and its layers?

Web service protocol stack consists of 4 layers. This can be described as follows

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

1) Service transport: This is the first layer which helps in transporting XML messages
between various client applications. This layer commonly uses the below-mentioned
protocols:

HTTP(Hypertext Transport Protocol)

SMTP(Simple Mail Transport Protocol)

FTP(File Transfer Protocol)

BEEP(Block Extensible Exchange Protocol)

2) XML messaging: This layer is based on the XML model where messages are encoded in
common XML format which is easily understood by others. This layer includes

XML-RPC

SOAP(Simple Object Access Protocol)

3) Service description: This layer contains description like location, available functions, and
data types for XML messaging which describes the public interface to a specific web service.
This layer includes:

WSDL(Web Service Description Language)

4) Service discovery: This layer is responsible for providing a way to publish and find web
services over the web. This layer includes:

UDDI(Universal Description, Discovery, and Integration)

Explain web service architecture?

Web service framework consists of an architecture which consists of three different layers.
The roles of these layers are defined as below

Service Provider: As the name denotes, service provider role is to create the web service and
makes it accessible to the client applications over the internet for their usage.

Service Requestor: Service requestor is basically any consumer of web service like any
client application. Client applications are written in any language contact web service for any
type of functionality by sending XML request over the available network connection.

Service Registry: Service registry is the centralized directory which helps locate web
services for client applications. Here we can find the existing web services, as well as
developers, can also create the new one.

The Service Provider uses the ‘Publish’ interface of Service Registry to make the existing
web services available to client applications. With all the information provided by the service
registry, service requestor is able to bind or invoke services.

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

What do you understand by XML-RPC?

RPC is Remote Procedure Call and as the name suggests, it is the method of calling a
procedure or function available on any remote computer.

XML stands for Extensible Markup Language. Thus XML-RPC represents a simple protocol
that performs RPCs by using XML messaging. This has been considered as an excellent tool
for connecting different environments and also establishing connections between wide
varieties of computers.

Explain features of XML-RPC?

The major features of XML-RPC are enlisted below

 RPCs are performed using simple XML language.


 XML encoded Requests are sent via HTTP POST.
 XML Response is embedded in HTTP response.
 It is considered as platform-independent.
 It allows communication between diverse applications.
 It uses HTTP protocol for passing information between client and server computers.
 It has small XML vocabulary for describing request and response’s nature.

Enlist few advantages of web services?

 We have already discussed web services, its architecture, components. Now, let us see
some its advantages
 Every application is now on the internet and it the web service which provides some
sort of required functionality to the client applications.
 Web services help in exposing the existing functionalities over the network to help
other applications to use in their programs.
 It has features like ‘Interoperability’ which determines the communication between
various applications, sharing of data as well as services among themselves.
 Web services use the standardized web service protocol stack for communication
which consists of 4 layers namely, Service Transport, XML messaging, Service
description and Service discovery.
 It has the feature of the low cost of communication because of the usage of SOAP
(Simple Object Access Protocol) over HTTP protocol.
 Easy to deploy, integrate and is reusable.
 Allows simple integration between different feature as a part of loose coupling
feature.

Explain the term UDDI with its features?

UDDI is an XML-based standard in the service discovery layer of web service protocol stack.
It is used for publishing and finding web services over the web as it acts like a directory.
Some of the features of UDDI are explained below

[email protected] 09441281686
WEB SERVICES INTERVIEW QUESTIONS

 It is an open framework and is platform independent.


 SOAP, COBRA, and Java RMI protocols are used for communication.
 It helps businesses to discover each other and enable interaction between them over
the internet.
 It acts as a database containing all WSDL files.

Which language is used by UDDI?

UDDI uses the language known as WSDL (Web Service Description Language)

Explain BEEP?

BEEP stands for Blocks Extensible Exchange Protocol. BEEP is determined as building new
protocols for the variety of applications such as instant messaging, network management, file
transfer etc. It is termed as new Internet Engineering Task Force (IETF) which is layered
directly over TCP. It has some built-in features like

 Authentication
 Security
 Error handling
 Handshake Protocol

Enlist few tools used to test web services?

To test Web services, below-mentioned tools are used

SoapUI

REST client

JMeter

Do we require any special application to access web service?

The only requirement for accessing web services from any application is that it must support
XML-based request and response. There is no need or say the requirement of installing any
application for accessing web services.

[email protected] 09441281686

You might also like