Web services are application components that communicates through open protocols. It is self contained, self describing and can be used by other applications. A Web service is designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (WSDL). Other systems interact with the Web service by its description using SOAP messages, using HTTP with an XML serialization in conjunction with other Web-standards.
Web services describes a way of integrating web based applications using XML, SOAP, WSDL and UDDI open standards over an internet protocol. XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available. Web services distributed computing model allows application-to-application communication.
The purpose of a Web service is to provide some functionality on behalf of a person or an organization. Web service implemented by agent. An agent is a program that works on your behalf. The provider entity provides a provider agent that implements a particular service and interacts with requester entity which make use of provider web services and exchange messages.
Message is a data sent from one agent to another which is a simple XML document. It has got the following:
- message sender
A message sender delivers message to message recepient.
- one or more recipient
Message receiver is an agent that receive messages. It is considered as final recipient and responsible for completing the processing of message.
- message body
A message body is the structure that represents the primary application-specific content that the message sender intends to deliver to the message recipient.
- message headers
A message header is the part of the message that contains information about a specific feature of the message.
- message envelope
A message envelope contains message body and message header.
- message transport system
A message is delivered by message transport system. This mechanism deliver a message based on the information in the envelope.
- message delivery policy
Message delivery policy is related to delivery of messages.
An address is that information required by a message transport mechanism in order to deliver a message appropriately.
Webservice can be used in different ways:
SOAP(Simple Object Access Protocol)
SOAP 1.2 provides a standard framework for packaging and exchanging XML messages. Its a processing model and can be carried by a variety of network protocols such as HTTP, SMTP, FTP.
When one part of a program calls on another part to do some work, the action is called a procedure call. RPC is a set of tools that allow you to write a program whose different parts are on different computers, without having to worry about how the communication happens.
Remote Procedure Calls (RPC) is a concept of client/server system, RPCs have traditionally been procedures called in a program on one machine that go over the network to some RPC server that actually implements the called procedure. The RPC server bundles up the results of the procedure and sends those results back to the caller. The calling program then continues executing.
XML (eXtensible Markup Language) is a well known standard for storing, carrying, and exchanging data.
XML-RPC works by encoding the RPC requests into XML and sending them over a standard HTTP connection to a server or listener piece. The listener decodes the XML, executes the requested procedure, and then packages up the results in XML and sends them back over the wire to the client. The client decodes the XML, converts the results into standard language datatypes, and continues executing.
Representational State Transfer
Its an architecture for distributed system. Its is based on client server concept. Clients initiate requests to servers; servers process requests and return appropriate responses. Requests and responses are built around the transfer of representations of resources. A resource can be any meaningful concept that may be addressed.
I have created one simple webservice and used SOAP as webservice and done load testing with Jmeter.
$stringData1='<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.example.org/documenttype_example_1/">
$myFile = "./camptest/soap_$i.xml";
$fh = fopen($myFile, ‘w’) or die("can’t open file");
$stringData = $stringData1.$campaignName.$i.$stringData2.$description.$i.$stringData3;
echo "<br>Write to Campaign jtest–$i";
echo "<br>Not Write to Campaign jtest–$i";
 => CampaignServicesResponse CampaignServices(CampaignServicesRequest $CampaignServicesRequest)
C Name 1C Description
[Campaign] => stdClass Object
[name] => C Name 1
[description] => C DescriptionC Name 1
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.example.org/documenttype_example_1/"><SOAP-ENV:Body><ns1:CampaignServicesRequest><Campaign><name>C Name 1</name><description>C Description</description></Campaign></ns1:CampaignServicesRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
SOAP act as envelope for sending Web Services messages over the Internet.
The SOAP envelope contains two parts:
- An optional header providing information on authentication, encoding of data, or how a recipient of a SOAP message should process the message.
- The body that contains the message. These messages can be defined using the WSDL specification.
SOAP commonly uses HTTP, but other protocols such as Simple Mail Transfer Protocol (SMTP) may by used. SOAP can be used to exchange complete documents.
JMeter was originally developed by Stefano Mazzocchi of the Apache Software Foundation. He wrote it primarily to test the performance of Apache JServ (a project that has since been replaced by the Apache Tomcat project). Since then the tool was enhanced with a more robust GUI and redesigned to add functional-testing capabilities.)It is indeed a very robust and flexible tool.
The first step in making Web services test case, is to set up a test plan, which is a series of steps JMeter will execute when run. A complete test plan will consist of one or more Thread Groups, logic controllers, sample generating controllers, listeners, timers, assertions, and configuration elements.
Before running the file we have to save the test plan.Save the file name with extension .jmx.
Configuration for Soap Request:-
1. If the WSDL file loaded correctly, the “Web Methods” drop down should be populated.
(WSDL describes Web services starting with the messages that are exchanged between the requester and provider agents.)
2. If the drop down remains blank, it means there is a problem getting the WSDL.
3. Select the web method and click “Configure”. The sampler should populate the “URL” and “SOAP Action” text fields.
4. If we do not want JMeter to read the response from the SOAP Webservice, uncheck “Read SoapResponses”.If the test plan is intended to stress test a webservice, the box should be unchecked.
While running there should be a small green square in the upper right hand corner.Number of active threads vs total threads.
First Execute the testplan with different conditions and keep on changing thread and ramp up period
Thread group is the starting point of Test plan.All controllers and samplers comes under the thread group.This element controls the number of thread.
Ramp up period:-
It keeps a delay between starting each user.
The determination of a good ramp-up time is governed by the following two rules:
- The first sampler’s hit rate should be close to the average hit rate of other samplers, thereby preventing a small ramp-up period
- The first thread that finishes does indeed finish after the last thread starts, preferably as far apart as possible, thereby preventing a large ramp-up period.
The best policy is to make your ramp up period long enough to avoid large workload as the test begins,but short enough to allow the last one to start running before finishing the first one.
Before execution we have to add Sampler Webservice(Soap Request).
Sampler do the actual work in jmeter and interacts with the server we are loading. Samplers tell JMeter to send requests to a server and wait for a response.Listeners(Distributed Graph,Aggregate Graph,Statistical Aggregate graph,Spline Visualizer,View result tree) help to view the results of the samplers in the form of tables graphs and trees or simple text in some log files.As i have already explained about the details of the graph.
Executed test plan for 500 users with filecounter 1000 and ramp up-100
Statistical Aggregate Graph
Execute the same test plan with different number of thread , ramp up period and loop count to compare the result and to know the performance of the server in better way.
Execution of test plan with 100 users with filecounter 500 and ramp up period 10
Here as we can see the wrong graph result because value assigned for ramp up period is not correct.
Deviation is with large value and median is very close to average . As i have explained in my earlier article standard deviation should be small and your graph should be fairly flat
Standard deviation starts out small but keeps getting higher as time passes (perhaps there are memory leaks). So as we increase the number of threads ramp up period should be increased.
Memory used by Jmeter
The memory remains pretty constant . The CPU however ramps steadily up until both CPUs are just over 50%, whereas locally it remains pretty static and significantly lower. In my experience if we execute the testplan with 10K users we will get out of memory issues. To handle that distribute the number of users and create different thread under a test plan also have to tune the JVM heap memory parameters downward in bin/jmeter (or jmeter.bat).We have to increase the heap parameter in bat file where (Xms – sets initial java heap size ),( Xmx – sets maximum java heap size) .Also we need to tune NEW parameter down proportionally if you reduce the HEAP values (NEW=”-XX: NewSize=128m -XX:MaxNewSize=128m”).There are default thread stack space allocations for different 32-bit JVMs.
Java 1.4 – 256 KB
Java 1.5 – 1 MB
Java 1.6 – 312 KB
The size of the Java heap for a particular application can never exceed or even reach the maximum virtual address space of the process data model. For a 32-bit process model, the maximum virtual address size of the process is typically 4 GB, though some operating systems limit this to 2 GB or 3 GB. The maximum heap size is typically -Xmx3800m (1600m) for 2 GB limits), though the actual limitation is application dependent. For 64-bit process models, the maximum is essentially unlimited.
512MB System Memory: -heapsize 262144
1GB System Memory: -heapsize 524288
2GB System Memory: -heapsize 1048576
3GB System Memory: -heapsize 1572864
4GB System Memory: -heapsize 2097152
The amount of available RAM had to be greater than the address space of the largest application to be run; otherwise, the application would fail with an “out of memory” error.
The results and charts shown in this article gives a clear picture about the response time to web service requests.The most important thing is to get a better load test output comparative result have value and also help to understand server performance.Load testing helps to identify bottlenecks also control the traffic on our site and make sure that applications are ready for launch.Without testing we are taking a chance of experiencing issues in a live environment. It performs robust validation by saving money and provide best quality.