Articles

Loading

jMeter - Webservice Test Plan

Java Testing
Author
master15
Date
2017-02-16 15:47
Views
59027791

In this chapter, we will learn how to create a Test Plan to test a WebService. For our test purpose, we have created a simple webservice project and deployed it on the Tomcat server locally.

Create Webservice Project

To create a webservice project we have used Eclipse IDE. First write the Service Endpoint InterfaceHelloWorld under the package com.tutorialspoint.ws. The contents of the HelloWorld.java are as below:

package com.tutorialspoint.ws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

//Service Endpoint Interface
@WebService
@SOAPBinding(style = Style.RPC)
public interface HelloWorld{

@WebMethod String getHelloWorldMessage(String string);

}

This service has a method getHelloWorldMessage which takes String paramater.

Next create the implementation class HelloWorldImpl.java under the package com.tutorialspoint.ws.

package com.tutorialspoint.ws;

import javax.jws.WebService;

@WebService(endpointInterface="com.tutorialspoint.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
@Override
public String getHelloWorldMessage(String myName){
return("Hello "+myName+" to JAX WS world");
}

}

As a next step let's publish this web service locally by creating the Endpoint publisher and expose the service on the server.

The publish method takes two parameters:

  • Endpoint URL String.

  • Implementor object, in this case the HelloWorld implementation class, which is exposed as a Web service at the endpoint identified by the URL mentioned in the parameter above.

The contents of HelloWorldPublisher.java is a follows :

package com.tutorialspoint.endpoint;

import javax.xml.ws.Endpoint;

import com.tutorialspoint.ws.HelloWorldImpl;

public class HelloWorldPublisher {

public static void main(String[] args){
Endpoint.publish("http://localhost:9000/ws/hello", new HelloWorldImpl());
}
}

Next modify the web.xml as below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, 
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">

<web-app>
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
</web-app>

To deploy this application as webservice we would need another configuration file sun-jaxws.xml, the contents of this file are as below:

<?xml version="1.0" encoding="UTF-8"?>
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="HelloWorld"
implementation="com.tutorialspoint.ws.HelloWorldImpl"
url-pattern="/hello"/>
</endpoints>

Now that all the files are ready the directory structure would look like as in the image below:

Webservice Dir structure

Now create a WAR file of this application. Choose the project > right click > Export > WAR file. Save this as hello.war file under the webapps folder of Tomcat server. Now start the Tomcat server. Once the server is started, you should be able to access the webservice with the following URL:

http://localhost:8080/hello/hello

Create JMeter Test plan

Now let's create a test plan to test the above webservice.

RENAME TEST PLAN

Start the JMeter window by clicking on /home/manisha/apache-jmeter-2.9/bin/jmeter.sh. Click on the Test Plan node. Rename this Test Plan node as WebserviceTest.

WS Test Plan

ADD THREAD GROUP

Add one Thread Group, which is placeholder for all other elements like Samplers, Controllers, Listeners. Right click on WebserviceTest(our Test Plan) > Add > Threads(Users) > Thread Group. Thread Group will get added under the Test Plan (WebserviceTest) node.

Next let us modify the default properties of the Thread Group to suit our testing. Following properties are changed:

Name: webservice user

Number of Threads (Users): 2

Ramp-Up Period: leave the the default value of 0 seconds.

Loop Count:2

WS Test Users

ADD SAMPLER-SOAP/XML -RPC REQUEST

Now that we have defined our users, it is time to define the tasks that they will be performing. We will add SOAP/XML-RPC Request element. Click your right mouse button to get the Add menu, and then select Add > Sampler > SOAP/XML-RPC Request. Then, select the SOAP/XML-RPC Request element in the tree and edit the following properties as in the image below:

The following details are entered in the this element:

Name: SOAP/XML-RPC Request

URL: http://localhost:8080/hello/hello?wsdl

Soap/XML-RPC Data: Enter the below contents

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://ws.tutorialspoint.com/">
   <soapenv:Header/>
<soapenv:Body>
<web:getHelloWorldMessage>
<arg0>Manisha</arg0>

</web:getHelloWorldMessage>
</soapenv:Body>
</soapenv:Envelope>
WS Test request

ADD LISTENER

The final element you need to add to your Test Plan is a Listener. This element is responsible for storing all of the results of your HTTP requests in a file and presenting a visual model of the data.

Select the webservice user element and add a View Results Tree listener (Add > Listener > View Results Tree).

WS Test request

RUN THE TEST PLAN

Now save the above test plan as test_webservice.jmx. Execute this test plan using Run > Start option.

VIEW OUTPUT

The following output can be seen in the listener.

WS Test ResultWS Test ResultWS Test Result

In the last image you can see the response message "Hello Manisha to JAX WS world".

Total 2

  • 2016-04-17 16:23

    Thank you


  • 2016-04-27 00:56

    Thanks. For information on dealing with RestFul web services it worth seeing Testing SOAP/REST Web Services Using JMeter guide. One more useful element available via plugins is JSONPath Extractor which makes JSON parsing easier and simplifies REST web services correlation. 


Total 20,613
Number Title Author Date Votes Views
20613
SileniusStor is specialized in reselling Cheap Aquafadas software online.
Softwareces | 2022.09.15 | Votes 0 | Views 56783753
Softwareces 2022.09.15 0 56783753
20612
CSStore is specialized in reselling Cheap Steinberg software online.
Softwareces | 2022.09.04 | Votes 0 | Views 56616974
Softwareces 2022.09.04 0 56616974
20611
Software Tester Community Website
ItSeTsQtBer | 2021.04.11 | Votes 0 | Views 57191491
ItSeTsQtBer 2021.04.11 0 57191491
20610
SoapUI Certification Course Content
Steveskok | 2021.02.08 | Votes 0 | Views 57903015
Steveskok 2021.02.08 0 57903015
20609
JavaScript Course Content
Steveskok | 2021.02.08 | Votes 0 | Views 57044877
Steveskok 2021.02.08 0 57044877
20608
Why most mobile testing is not continuous?
(TestExpert) | 2021.02.04 | Votes 0 | Views 57583869
(TestExpert) 2021.02.04 0 57583869
20607
8 Common Mistakes When Planning and Documenting Your Tests
(TestExpert) | 2021.02.04 | Votes 0 | Views 59179645
(TestExpert) 2021.02.04 0 59179645
20606
Types of Performance Testing
Jamessmith | 2021.01.17 | Votes 0 | Views 58250510
Jamessmith 2021.01.17 0 58250510
20605
How to Build E2E Test Cases (1)
tanthanh | 2020.05.28 | Votes 0 | Views 57953757
tanthanh 2020.05.28 0 57953757
20604
[White Paper] Delivering better software using Test Automation
tanthanh | 2020.05.28 | Votes 0 | Views 57547801
tanthanh 2020.05.28 0 57547801
20603
[Whitepaper] How to choose the right API Testing Solution
tanthanh | 2020.05.28 | Votes 0 | Views 57547868
tanthanh 2020.05.28 0 57547868
20602
[Whitepaper] How to choose the right API Testing Solution
tanthanh | 2020.05.28 | Votes 0 | Views 57260135
tanthanh 2020.05.28 0 57260135
20601
TestOps Introduction
VTB | 2020.03.23 | Votes 0 | Views 56653528
VTB 2020.03.23 0 56653528
20600
TestOps Implementation Case Study
VTB | 2020.03.23 | Votes 0 | Views 57708914
VTB 2020.03.23 0 57708914
20599
Selenium Automation Tester Certification Sample Exam Set 3
(TestExpert) | 2020.02.03 | Votes 0 | Views 58022657
(TestExpert) 2020.02.03 0 58022657
20598
Selenium Automation Tester Certification Sample Exam Set 2
(TestExpert) | 2020.02.03 | Votes 0 | Views 57896794
(TestExpert) 2020.02.03 0 57896794
20597
Selenium Automation Tester Certification : Sample Exam Set 1
(TestExpert) | 2020.02.03 | Votes 0 | Views 57394854
(TestExpert) 2020.02.03 0 57394854
20596
What is agile testing? why is agile testing? and what is the benefits? (20)
oishichip | 2019.12.26 | Votes 0 | Views 56509155
oishichip 2019.12.26 0 56509155
20595
Crowd Testing — Vantagens para testadores, plataformas e clientes [pt-br]
soikmd2 | 2019.12.14 | Votes 0 | Views 57011435
soikmd2 2019.12.14 0 57011435
20594
Software Testing Industry Report (Turkey) 2018-2019 (2)
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 57813980
ItSeTsQtB 2019.08.08 0 57813980
20593
How to bypass security in integration tests in ASP.Net Core
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 59059504
ItSeTsQtB 2019.08.08 0 59059504
20592
For agile testing, fail fast with test impact analysis
ItSeTsQtB | 2019.08.08 | Votes 0 | Views 57904416
ItSeTsQtB 2019.08.08 0 57904416
20591
Career Path in Software Testing
^Software^ | 2019.07.28 | Votes 0 | Views 57885707
^Software^ 2019.07.28 0 57885707
20590
Challenges in Big Data Testing
^Software^ | 2019.07.22 | Votes 0 | Views 58124336
^Software^ 2019.07.22 0 58124336
20589
Essential Necessities In Big Data Testing
^Software^ | 2019.07.22 | Votes 0 | Views 56425539
^Software^ 2019.07.22 0 56425539
20588
5 Test Data Generation Techniques
^Software^ | 2019.07.22 | Votes 0 | Views 57810156
^Software^ 2019.07.22 0 57810156
20587
CI and CD for ETL (Extract-Transform-Load) testing.
^Software^ | 2019.07.22 | Votes 0 | Views 57562868
^Software^ 2019.07.22 0 57562868
20586
Quest for Quality Conference : 5-6 Nov 2019 at Dublin, Ireland
VTB | 2019.07.08 | Votes 0 | Views 57262202
VTB 2019.07.08 0 57262202
20585
TestBash Essentials Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 57504158
VTB 2019.07.08 0 57504158
20584
UKSTAR Conference : 11-03-2019
VTB | 2019.07.08 | Votes 0 | Views 56806941
VTB 2019.07.08 0 56806941
20583
Testing in Context Conference Australia (TiCCA) 2019
VTB | 2019.07.08 | Votes 0 | Views 57137939
VTB 2019.07.08 0 57137939
20582
European Testing Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 57331478
VTB 2019.07.08 0 57331478
20581
Automation Guild Online Conference 2019
VTB | 2019.07.08 | Votes 0 | Views 58618120
VTB 2019.07.08 0 58618120
20580
Software Quality Days 2019 : 15 Jan 2019 (1)
VTB | 2019.07.08 | Votes 0 | Views 57691247
VTB 2019.07.08 0 57691247
20579
Skills required to become a Software Tester (1)
IT-Tester | 2019.07.08 | Votes 0 | Views 57905412
IT-Tester 2019.07.08 0 57905412
20578
Automated Unit Testing with Randoop, JWalk and µJava versus Manual JUnit Testing
IT-Tester | 2019.07.08 | Votes 0 | Views 56073469
IT-Tester 2019.07.08 0 56073469
20577
Scrum Testing Guide Book (2)
IT-Tester | 2019.06.26 | Votes 0 | Views 56862592
IT-Tester 2019.06.26 0 56862592
20576
Acceptance Testing Definition in Testing vs Scrum
IT-Tester | 2019.06.26 | Votes 0 | Views 57696435
IT-Tester 2019.06.26 0 57696435
20575
User Acceptance Testing Checklist
VTB | 2019.06.20 | Votes 0 | Views 57900035
VTB 2019.06.20 0 57900035
20574
Firewalls and Types (1)
VTB | 2018.11.14 | Votes 0 | Views 56524969
VTB 2018.11.14 0 56524969
20573
Senior Test Engineer (1)
VTB | 2018.11.05 | Votes 0 | Views 57765600
VTB 2018.11.05 0 57765600
20572
Junior Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 57682024
kornadian2 2018.11.04 0 57682024
20571
Senior Test Engineer
kornadian2 | 2018.11.04 | Votes 0 | Views 57178686
kornadian2 2018.11.04 0 57178686
20570
Programme Test Manager, 12m, Immed Start, $NEG
kornadian2 | 2018.11.04 | Votes 0 | Views 58904812
kornadian2 2018.11.04 0 58904812
20569
Junior Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 57594791
kornadian2 2018.11.04 0 57594791
20568
Dev & Test Manager
kornadian2 | 2018.11.04 | Votes 0 | Views 58336851
kornadian2 2018.11.04 0 58336851
20567
Senior Test Analyst (Performance Tester)
kornadian2 | 2018.11.04 | Votes 0 | Views 58411440
kornadian2 2018.11.04 0 58411440
20566
QA Automation Test Analyst
kornadian2 | 2018.11.04 | Votes 0 | Views 57377948
kornadian2 2018.11.04 0 57377948
20565
Software/Field Testing Engineer
kornadian2 | 2018.11.04 | Votes 0 | Views 57006490
kornadian2 2018.11.04 0 57006490
20564
Compliance Technician (Tester)
kornadian2 | 2018.11.04 | Votes 0 | Views 57304257
kornadian2 2018.11.04 0 57304257