web services testing

39
WEB SERVICES Testing SOAPUI

Upload: rammikn

Post on 18-Dec-2014

69 views

Category:

Software


2 download

DESCRIPTION

Web services testing

TRANSCRIPT

Page 1: Web services testing

WEB SERVICES Testing

SOAPUI

Page 2: Web services testing

WEBSERVICE

Web service can be defined as an application, which does not have any GUI. Web service have engine, this engine takes input in the form of XML, process the data and provide output again in the form of XML

Page 3: Web services testing

XML(Extendible Markup Language)

• XML can be used as a data source to hold some data.

• XML can be used to communicate data between systems.

•In XML we can define our own tags ultimately, we are defining our own

protocol to transfer data between systems

<PersonalData> <FirstName> Amit </FirstName> <MiddleName> Singh </MiddleName> <LastName> Rathi </LastName></PersonalData>

Page 4: Web services testing

WEBSERVICES

Page 5: Web services testing

WSDL(Web Service Definition Language)

* When we are working on web service, we don’t have idea, what is the format of input xml that web service take

* What is the format of output xml generated by web services.

* What are the different services is exposed by my web service

All these information is mentioned in XML formatted document is called WSDLWe use this wsdl while testing web services

Page 6: Web services testing

TYPES OF WEBSERVICES

SOAP

REST

SOAP(Simple Object Access Protocol) is an XML based protocol for accessing Web Services.

Page 7: Web services testing

->Xpath

->Groovy (Java)

Skills Needed

Page 8: Web services testing

SoapUI

• Automation tool for web services function and load testing

• Generate XML on behalf of our input data and send it web service engine.

• Receive data coming from web service and validate data

• Generate basic reports as well

Page 9: Web services testing

bestpowerpointtemplates.com

Workflow of SoapUI

CREATE SOAPUI PROJECT

Create Test Suite

Create Test Cases

Create Test Steps

Page 10: Web services testing

SoapUI TrainingInduction course2014-23-09

Page 11: Web services testing

•What is SoapUI

• SoapUI Features

• SOAP and WSDL

• Functional Testing

• Service Mocking

Agenda

11

Page 12: Web services testing

What is SoapUI

• Free and open source cross-platform Functional Testing solution.

• Creating even the most advanced test scenarios is very simple.

• SoapUI is a complete and automated testing solution.

• Testing for everyone.

• Streamlined service simulation.

• Advanced functionality comes standard.

Page 13: Web services testing

SoapUI Features

• Functional Testing.

• Service Simulation.

• Security Testing.

• Load Testing.

• Technology Support.

• Automation.

• Analytics.

• Recording.

• Ecosystem.

Page 14: Web services testing

What is a Web Service

• A web service is a method of communication between two electronic devices over the World Wide Web. A

web service is a software function provided at a network address over the web or the cloud, it is a service that

is "always on“.

• The Web Services Description Language is an XML-based interface description language that is used for

describing the functionality offered by a web service. A WSDL description of a web service (also referred to as

a WSDL file) provides a machine-readable description of how the service can be called, what parameters it

expects, and what data structures it returns.

Page 15: Web services testing

SOAP and WSDL

• XML-based protocol to let applications exchange

information over HTTP.

• SOAP stands for Simple Object Access Protocol

• SOAP is a communication protocol

• SOAP is a format for sending messages

• SOAP is platform independent

• SOAP is language independent

• XML-based language for describing Web services

and how to access them.

• WSDL stands for Web Services Description

Language

• WSDL is an XML document

• WSDL is also used to locate Web services.

SOAP Definition WSDL Definition

Page 16: Web services testing

SOAP and WSDL

• A SOAP message is an ordinary XML document containing the following elements:

• An Envelope element that identifies the XML document as a SOAP message.

• A Header element that contains header information.

• A Body element that contains call and response information.

• A Fault element containing errors and status information.

SOAP Syntax

Page 17: Web services testing

SOAP and WSDL

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

<soap:Header>

...

</soap:Header>

<soap:Body>

...

<soap:Fault>

...

</soap:Fault>

</soap:Body>

</soap:Envelope>

SOAP Syntax Example

Page 18: Web services testing

SOAP and WSDL

• A WSDL document describes a web service using these major elements:

• A container for data type definitions used by the web service.

• A typed definition of the data being communicated.

• A set of operations supported by one or more endpoints.

• A protocol and data format specification for a particular port type.

WSDL Document Structure

Page 19: Web services testing

SOAP and WSDL

<definitions>

<types>

data type definitions........

</types>

<message>

definition of the data being communicated....

</message>

<portType>

set of operations......

</portType>

<binding>

protocol and data format specification....

</binding>

</definitions>

WSDL Example

Page 20: Web services testing

Functional Testing

• Create a SoapUI Project

• Right click on the project node and select New SoapUI Project.

Page 21: Web services testing

Functional Testing

• In the New SoapUI Project dialog enter a project name (i.e. Country_info) and click OK.

• Right click on the project node and select Add WSDL.

Page 22: Web services testing

Functional Testing

• The Add WSDL dialog is now open

• Enter http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL.

• Click OK.

Page 23: Web services testing

Functional Testing

• Now see that the WSDL was successfully added to the

project by seeing the operations in the Web Service in

the navigatorEnter

Page 24: Web services testing

Functional Testing

• Create a request from your WSDL

• Click on the plus sign next to the web service in the navigator to expand.

• Double click on the request.

• You now have to enter your data manually in the code editor as shown below. Replace “?” with “RO” (without quotes)

Page 25: Web services testing

Functional Testing

• Run a request to the Web Service

• Click on the green arrow head sign to submit the request.

Page 26: Web services testing

Functional Testing

• Receive response

• On the right side of the window the response will be displayed.

Page 27: Web services testing

Functional Testing

• Run an invalid request to the Web Service.

• Introduce a wrong country code (like “ZZ”).

• Click on the green arrow head sign to submit the request.

• The response of the Web Service will indicate that the country was not found.

• After seeing the result, correct the input data.

Page 28: Web services testing

Functional Testing

• Create a Test Case from a request.

• In the request editor, select Add This Request to TestCase.

Page 29: Web services testing

Functional Testing

• Next step:

• Adding a request to a TestCase will open the Create TestSuite dialog box. Enter a name for your TestSuite and

click OK.

• After clicking OK, you will be asked to create a TestCase. In the Create TestCase dialog, enter a name for your

TestCase and click OK.

Page 30: Web services testing

Functional Testing

• Next step:

• The dialog box Add Request to TestCase will appear. Click OK.

Page 31: Web services testing

Functional Testing

• Final step:

• SoapUI will now generate a TestSuite and TestCase for you while the request will be added as a TestRequest.

Below is a copy of the request that appears in the interface. A TestCase editor will also open with your new

TestRequest.

• The next step is to validate the response in your test by adding an Assertion.

Page 32: Web services testing

Functional Testing

• Add an Assertion to the test:

• Now that we've created and run our first test, we are going to add a validation of the response. In SoapUI,

this is called adding an assertion.

• Examples of assertions that is possible in SoapUI are:

• Schema Compliance

• Simple Contains

• Simple Not Contains

• SOAP Faults

• Response SLA

• XPath Match

• XQuery Match

• WS Security Status

• WS-Addressing Request/Response Assertion

• Script Assertion

Page 33: Web services testing

Functional Testing

• Close all windows you have open in SoapUI before starting:

• Double Click on your Test Request as shown below. This will open the request editor.

• After clicking OK, you will be asked to create a TestCase. In the Create TestCase dialog, enter a name for your

TestCase and click OK.

Page 34: Web services testing

Functional Testing

• Next step:

• Select Response SLA from the Add Assertion menu.

• In the Configure Response SLA Assertion dialog box, write 500 and click OK. This will validate that the

response of the SLA is under 500.

Page 35: Web services testing

Functional Testing

• Next step:

• Now that you've added the assertion, you are going to run the request to validate the response. If all

assertions are successful, the SOAP icon should turn green in three places as shown below.

Page 36: Web services testing

Functional Testing

• Validate response with XPath Match:

• Select XPath Match from the Add Assertion menu.

Page 37: Web services testing

Functional Testing

• Validate response with XPath Match:

• In the XPath Match Configuration press Declare button and write below “//m:CapitalCityResult”

• Click “Select from current” and you should see the word Bucharest appearing in the Expected Results field.

• Click Save

Page 38: Web services testing

Functional Testing

• Final step:

• Now that you've added a new assertion, you are going to run the test again. If all assertions are successful,

the SOAP icon should turn green in three places as shown below.

Page 39: Web services testing

THANK YOU