Web Service

Send SOAP Request using JMeter (2)

Hola Testers,

Today I would like to show another method for send SOAP request. In my previous post I showed with “HTTP Request”. Today, I’m going to do the same request using “SOAP/XML-RPC Request”.

1. First, add a Thread Group
2. Then add a “SOAP/XML-RPC Request” by right click on the Thread Group > Add > Sampler > SOAP/XML-RPC Request
Screen Shot 2016-04-24 at 9.09.21 PM.png

3. The SOAP/XML-RPC Request allows you to add following variables,
-URL of the WSDL
-SOAP Action
-And SOAP data
I’ve add request XML, WSDL URL and SOAP Action as below. (It depends with your SOAP request)
Screen Shot 2016-04-24 at 9.10.08 PM.png

4. Then, add a listener, save the project and run it.
You’ll be able to see the response in listener (I added “View Results Tree” listener and I can see the response in “Response data” tab of the listener)
Screen Shot 2016-04-24 at 9.10.36 PM.png

Send SOAP Request Using JMeter

SOAP (Simple Object Access Protocol) is a protocol specification for exchanging structured information the implementation of web services using XML. But how we implement this on jmeter? Yes, there are some solutions. Today I’ll show one simple way to do it.

1. Open JMeter > Add a Thread Group
2. Add a HTTP Request for the Thread Group
Screen Shot 2016-04-17 at 10.04.29 AM.png

3. Fill host, port, method and path according to your WSDL name
For example I’m using http://www.webservicex.net/country.asmx?WSDL file
My variables will be,
Host: webservicex.net
Port:
Method: POST
Path:/country.asmx?WSDL
Screen Shot 2016-04-19 at 10.41.57 AM

4. Select “Body Data” tab of the HTTP Request and add request URL with parameter
Screen Shot 2016-04-19 at 10.42.10 AM

5. Add a HTTP Header Manager to the Thread Group and add needed Header requests
Screen Shot 2016-04-19 at 10.42.24 AM

6. Add a Listener to get the results. I used “View Results Tree”
7. Save and Run the test. You can see response xml on “Response data” tab of the Listener
Screen Shot 2016-04-19 at 10.42.40 AM.png

Getting Start with SoapUI

Hola Testors!

I thought to getting start of SoapUI with some example scenario rather than introducing the interface first. So shall we do a little exercise today? Previously I told we mainly we use two kind of web protocols to test (SOAP and REST). Today I’m gonna use SOAP service to test. Let’s begin:

Download and configure SoapUI

First, you need to download and install SoapUIto your computer.
Go to soapui official page and download a version which match with your computer (I’m using Mac OS X installer (64-bit) version)
SoapUI official site: http://www.soapui.org/.

Screen Shot 2015-08-16 at 1.10.06 PM

After the download happens, you can install it as a normal application. In Mac it will installed to your /Application directory by default. In windows > Program Files

Create a workspace

After the installation you can use SoapUI. First of all open the application. Then create a workspace by

File> New Workspace

Screen Shot 2015-08-16 at 1.20.26 PM

Create a SOAP Project

Now you have a workspace to work. As I mentioned earlier we’re gonna create a SOAP project. How to do it

File> New SOAP Project

Screen Shot 2015-08-16 at 1.24.58 PM

Screen Shot 2015-08-16 at 1.26.41 PM

  1. Project Name: Currency Converter
  2. Initial WSDL: http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
  3. Keep checked for “Create Request”
  4. Click “OK”

It will create two version of services (CurrencyConvertorSoap and CurrencyConvertorSoap12). First one follows older standards of SOAP.

Screen Shot 2015-08-16 at 1.52.36 PM

Remove CurrencyConvertorSoap12 version since no use of it.

Expand CurrencyConvertorSoap version, there you can see a “ConversionRate” method.By expanding that method you’ll be able to see “Request1” request.

So let’s make it useful, Right click on it and rename to “GBP To LKR”

Screen Shot 2015-08-16 at 1.40.41 PM

Double click on the Request, it will display you a simple xml request

Screen Shot 2015-08-16 at 1.57.11 PM


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
  <soapenv:Header/>
  <soapenv:Body>
     <web:ConversionRate>
        <web:FromCurrency>?</web:FromCurrency>
        <web:ToCurrency>?</web:ToCurrency>
     </web:ConversionRate>
  </soapenv:Body>
</soapenv:Envelope>

In the request xml you can see “?” marks for “FromCurrency” and “ToCurrency”.

You can test the request by replacing question mark of “FromCurrency” parameter by “GBP” and “ToCurrency” parameter by “LKR”.


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
  <soapenv:Header/>
  <soapenv:Body>
     <web:ConversionRate>
        <web:FromCurrency>GBP</web:FromCurrency>
        <web:ToCurrency>LKR</web:ToCurrency>
     </web:ConversionRate>
  </soapenv:Body>
</soapenv:Envelope>

By clicking “Submit request” button of request window (upper left corner) you’ll be able to get the response xml with GBP to LKR exchange rate.


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
     <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
        <ConversionRateResult>207.3026</ConversionRateResult>
     </ConversionRateResponse>
  </soap:Body>
</soap:Envelope>

Create a Test Suite/ Test Case

My request is working correctly. hope your one too. Now we have to test this service for GBP to LKR conversion. So we’re are gonna create a test case.

Right click on “GBP To LKR” request > Select “Add to TestCase”

Screen Shot 2015-08-16 at 1.58.57 PM

Oh, It is saying we don’t have a test suite to add the test case :O Okay we’ll create a test suite first.

Screen Shot 2015-08-16 at 1.59.57 PM

Then we create a test case

Screen Shot 2015-08-16 at 2.00.16 PM

Screen Shot 2015-08-16 at 2.00.23 PM

Screen Shot 2015-08-16 at 2.00.42 PM

Your test case will display in the tree as below

Workspace> Project> Test Suite > Test Case

There you can see Test Step, Load Test and Security Test. We’re gonna do a functional test. So our section is “Test Steps”. By default SoapUI creates a test step for us. Lets see what is inside there.

Screen Shot 2015-08-16 at 2.10.40 PM

Ahh it is same like the request XML! We change the xml to testable format that what we need. Change web:FromCurrency to GBP and web:ToCurrency to LKR as below


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>GBP</web:FromCurrency>
         <web:ToCurrency>LKR</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>

Shall we check whether we get a correct output.

Click on the submit request button on top left corner. (Refer below screenshot)

It will generate an response xml

Screen Shot 2015-08-16 at 2.41.21 PM


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>210.6568</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>

You can see the results in between ConversionRateResult tags it is 210.6568 now.

Add Assertions

Our test step is done now. But how we can verify whether this s correct out put or not while we’re running on this test? To do that we need assertions

Click on the Assertion tab on the bottom

Screen Shot 2015-08-16 at 2.48.17 PM

It will expand the assertion pane . Then click on the “Adds an assertion on item” button (shows in following screenshot)

Screen Shot 2015-08-16 at 2.48.32 PM

It opens Add Assertion window and you can add Assertions by selecting assertions in there.

Screen Shot 2015-08-16 at 2.48.52 PM

We will see how to use assertions and how to test a test case/ test suite on next posts. 🙂


If you have any comment/ suggestions please comment below. We need to be improve with your ideas and suggestions. See you soon folks 🙂

Introduction to Web Services

Hola Testors!

I think to start my first blog post with web services testing which I’m currently doing 😉

So first we need to understand what is a web service. Ya In today most of developers are using this web services or APIs to build web applications. For mobile they use mobile SDKs. It is actually like a library which we can use their methods.

Today when you are developing an application you do not need to build it from the scratch. There are lots of ready made services available which you can directly plug in to your application and deal with those values. For example think you need to build an application which use to display currency exchange rate from one currency to another one. You can use a web service to get the exchange value. And some organizations builds their own APIs for the applications. Some organizations allows to public (developers) to use their APIs (eg: google map).

So if you wants to memorize what is web service;

Web Services is the mechanism or the medium of communication through which two applications / machines will exchange the data irrespective of their underline architecture and the technology.

Web service can implement in different ways, but there are two popular ways among other methods. Those are;

  1. SOAP (Simple Object Access Protocol)
  2. REST (REpresentational State Transfer architecture)

 

SOAP

SOAP is the standard protocol defined by W3C standard for sending and receiving web service request and response. SOAP uses the XML format to send and receive the request and hence the data is platform independent data. SOAP messages are exchanged between the provider applications and receiving application within the SOAP envelops. And it uses HTTP protocol.

 

REST

REST  is an architecture that generally runs over HTTP. REST is an alternative to SOAP and instead of using XML for request REST uses simple URL in some cases. Unlike SOAP, RESTFUL applications uses HTTP build in headers to carry meta-information. All API request parameters and method parameters can be sent via either POST or GET variables.

REST API supports both XML and JSON format. It is usually preferred for mobile and web apps as it makes app work faster and smoother. REST returns some HTTP code values to user to understand the nature of response.

HTTP Code Meaning Description
1xx Informational Request received and continuing process
2xx Success Action was success
3xx Redirection Further actions must be taken in order to complete the request
4xx Client Error Request contain bad syntax/ cannot fulfill the request
5xx Server Error Server unable to fulfill the request

 

WSDL

WSDL (Web Services Description Language) is an XML based language which will be used to describe the services offered by a web service. WSDL describes all the operations offered by the particular web service in the XML format. It also defines how the services can be called.

 

Web Service Testing

In order to do a web service testing for a particular web service you need to know 5 things

  • Understanding of the WSDL file
  • Understanding the operation that particular web service do
  • Understanding of the request XML format
  • Understanding of the response XML format
  • Using an appropriate tool for test

For the last point we can use SoapUI which we will discuss about in near future 😉


 

I hope by reading this post you will get some understand about what is web service and why we are using it. In next couple of posts I hope to explain about how to do a web service test with SoapUI with example. Please if you have any comments or suggestions please throw to me. I like to improve it with your suggestions and ideas. See you soon!