Skip to main content

Web Service Testing (Introduction)



What is Webservice?

In today's world, there is huge number of applications which are built on different programming languages. For example, there could be a web application designed in Java, another in .Net and another in PHP.Exchanging data between applications is crucial in today's networked world. But data exchange between these heterogeneous applications would be complex.
Here is where web services provide a common platform that allows multiple applications built on various programming languages to have the ability to communicate with each other.Web service is a standardized medium to propagate communication between the client and server applications on the World Wide Web. Web services are subset of API’s.An API or Application Programming Interface is a set of programming instructions for accessing a web-based software application.
In other words, a set of commands used by an individual program to communicate with one another directly and use each other's functions to get information.For example, a Google website can have API for various functions like search, translations, calendars, etc.

A web service is a software module which is designed to perform a certain set of tasks.A web service has the following key features
        # It is built using the XML programming language. Almost all modern day technologies such as .Net and Java have corresponding commands that have the ability to work with XML. Hence, XML was taken as the most appropriate language for building web services.
       # Web services communicate over HTTP. HTTP is a protocol used by all web-based applications. Hence, it just made sense to ensure that Web services also had the ability to work over the HTTP protocol.

Types of Web Service

There are mainly two types of web services.
1.SOAP(Simple Object Access Protocol) web services.
2.RESTful(Representational state transfer) web services.

SOAP(Simple Object Access Protocol)

SOAP is a protocol which is used to interchange data between applications which are built on different programming languages.SOAP is based on transferring XML data as SOAP Messages.
A SOAP message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element, contained in <Body>, is used for reporting errors.
The SOAP envelope
<Envelope> is the root element in every SOAP message, and contains two child elements, an optional <Header> element, and a mandatory <Body> element.
The SOAP header
<Header> is an optional subelement of the SOAP envelope, and is used to pass application-related information that is to be processed by SOAP nodes along the message path.
The SOAP body
<Body> is a mandatory subelement of the SOAP envelope, which contains information intended for the ultimate recipient of the message.
The SOAP fault
<Fault> is a subelement of the SOAP body, which is used for reporting errors.

What is WSDL?
WSDL is an XML-based file which basically tells the client application what the web service does. It is known as the Web Services Description Language(WSDL). From WSDL file we can know all operations that particular web services is supporting.
WSDL document is used to describe a web service. This description is required, so that client applications are able to understand what the web service actually does.It gives the client all the information required to connect to the web service and use all the functionality provided by the web service.The WSDL file contains the location of the web service and the methods which are exposed by the web service.The WSDL file itself can look very complex to any user, but it contains all the necessary information that any client application would require to use the relevant web service.
One key thing to note here is that definition of messages, which is what is passed by the SOAP protocol is actually defined in the WSDL document.
The WSDL document actually tells a client application what are the types of SOAP messages which are sent and accepted by the Web service.

Why WSDL?
The WSDL file is written in plain old XML. The reason that it is in XML is so that the file can be read by any programming language.So if the client application was written in .Net, it would understand the XML file. Similarly, if the client application was written in the Java programming language then also it would be able to interpret the WSDL file.
Difference between WSDL and soap protocol:
The words SOAP and WSDL are acronyms, with SOAP standing for Simple Object Access Protocol and WSDL being a short form of Web Service Description Language.
     #WSDL is a descriptive language that explains services that are offered in a web service.This provides a description of the service naming, the specifications that are needed and the response pattern that is given back, that can easily be read and interpreted by a machine.
     #Soap is an protocol used to sending and receiving messages between web services.

RESTful(Representational state transfer)

REST stands for REpresentational State Transfer.RESTful Web Services are basically REST Architecture based Web Services. In REST Architecture everything is a resource. RESTful web services are light weight, highly scalable and maintainable and are very commonly used to create APIs for web-based applications. In REST architecture, a REST Server simply provides access to resources and the REST client accesses and presents the resources. Here each resource is identified by a URI (Uniform Resource Identifier), which is a service that provides resource representation such as JSON and a set of HTTP Methods. JSON is now the most popular format being used in Web Services.
HTTP Methods:The following HTTP methods are most commonly used in a REST based architecture.
GET − Provides a read only access to a resource.
PUT − Used to create a new resource.
DELETE − Used to remove a resource.
POST − Used to update an existing resource or create a new resource.

SOAP VS REST
SOAP is definitely the heavyweight choice for Web service access. It provides the following advantages when compared to REST:
REST
1.RESTful web services are stateless. You can test this condition by restarting the server and checking if interactions survive.
2.For most servers, RESTful web services provide a good caching infrastructure over an HTTP GET method. This can improve the performance if the information the service returns is not altered frequently and is not dynamic.
3.Service producers and consumers must understand the context and content being passed along as there is no standard set of rules to describe the REST web services interface.
4.REST is useful for restricted-profile devices, such as mobile, for which the overhead of additional parameters are less (e.g., headers).
5.REST services are easy to integrate with existing websites and are exposed with XML so the HTML pages can consume the same with ease. There is little need to refactor the existing site architecture. As such, developers are more productive because they don't need to rewrite everything from scratch; instead, they just need to add on the existing functionality.
6.A REST-based implementation is simple compared to SOAP.
SOAP
1.The Web Services Description Language (WSDL) describes a common set of rules to define the messages, bindings, operations and location of the service. WSDL is akin to a contract to define the interface that the service offers.
2.SOAP requires less plumbing code than REST services design (e.g., transactions, security, coordination, addressing and trust). Most real-world applications are not simple and support complex operations, which require conversational state and contextual information to be maintained. With the SOAP approach, developers don't need to write plumbing code into the application layer.
3.SOAP web services, are useful for asynchronous processing and invocation.
4.SOAP supports several protocols and technologies, including WSDL, XSDs and WS-Addressing.

REST or SOAP: Which is best ?
When choosing between REST and SOAP, two of the key topics to factor into the decision are:
1.The types of clients that will be supported. For example, REST services offer an effective way for interacting with lightweight clients, such as smartphones.
2.How varying degrees of flexibility and standardization will be either rebuffed or accepted by the organization’s corporate culture










Comments

Popular posts from this blog

JIRA OverView

What is JIRA? JIRA is a project management tool used for issues and bugs tracking system for all types of testing.The JIRA dashboard consists of many useful functions and features which make handling of issues easy. The following points explain some interesting details of JIRA. • JIRA is an incident management tool. • JIRA is not an acronym, the name 'JIRA' comes from the Japanese word 'Gojira' • JIRA is developed by Australian Company Atlassian • JIRA is a platform independent tool; it can be used with any OS. • JIRA is multi-lingual tool − English, French, German, Japanese, Spanish, etc. • JIRA can be integrated with many other tools like GitHub, Team Foundation Software and many more. • JIRA is a commercial tool and available as a Trial version for a limited time. • To utilize JIRA services, a license is required. Features: JIRA is one the best product management tool which includes: Issue tracking & management: A software application that allows to...

Generating Extent Reports in C#

In software test automation after completion of the test suite execution we need to have a report for the execution status and it is one way of evidence for the pass and fail status of the tests. Extent reports are very rich HTML reports for the selenium webdriver.. By using these reports we can provide lots of information to the reports. Some advantages of Extent Reports: 1.Status will be shown in the form of PIE chart. 2.Can give the our own name to the test method (i.e can change the test method name in the report). 3.Can generate stepwise log information in the report. 4.Can segregate the tests using Test Categories. 5.Can give test author name to display in the report. 6.Can show the screenshots in the report wherever we need. 7.Can add our own information in the report (i.e. version of selenium used, Environment information where the test suite executed). 8.It will give the System information in the report (i.e. HostName and OS used to execute the t...

Demo Project (Specflow Setup)

Installation and Setup Steps-->     1.Install SpecFlow for Visual Studio (Open Extensions and Updates) 2. Install SpecFlow NuGet Packages     3. Add Feature File    My Demo Project    Here, I have worked on following story    Story: Discounts on online shopping cart price for loyalty card customers    In order to increase the reward for loyal customers    I want to add 5-10% discounts on the final shopping cart price.    Scenario 1: 5% discount for loyalty card customer    Given a loyalty card customer in online checkout page    When the shopping card total is less than $100    Then 5% discount should be applied to the final shopping cart price.     Create Scenarios    In the feature file, I described what the feature needs to do Every scenario represents a different       ...