Pressure test of WebService with JMeter

Source: Internet
Author: User

pressure test of WebService with JMeter
in the real world we used jmeter to stress test WebService, Apache JMeter is a Java-based stress testing tool developed by Apache. Used for stress testing of software.
the role of JMeter1. Be able to test the HTTP and FTP server for stress and performance, or perform the same test (through JDBC) for any database. 2. Full portability and 100% pure java. 3. Full Swing and lightweight components support (precompiled jar using javax.swing.*) package. 4. A fully multithreaded framework allows simultaneous sampling through multiple threads and the ability to simultaneously sample different functions through separate thread groups. 5. The careful GUI design allows for fast operation and more accurate timing. 6. Caching and offline analysis/playback of test results.

Second: The configuration of the relevant environment variables for JMeter is similar to the configuration of Java, refer to the information on the Internet

Three: JMeter The WebService Test instance for the HTTP protocol.
1: First create a new thread group in the test plan



The number of threads in thread properties and number of cycles indicates the number of times the actual run was performed at the time of the test, that is, the number of accesses to webservice.

2: Create a new HTTP request under the thread group (about the configuration of the provider's related address and some parameters) and the HTTP information manager (Public request header when sending the WebService service), and aggregate the report (test report).






Four: After you have configured everything, click Start to perform the test.
=============we Test WebService by HTTP head start===========
Name=clark
=============we Test WebService by HTTP head end===========

Note ==================================== The following configuration for WebService services is integrated into spring

Applicationcontext_webservice.xml
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs= "Http://cxf.apache.org/jaxrs"
xmlns:context= "Http://www.springframework.org/schema/context"
Xsi:schemalocation= "
Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
Http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd " >
<context:annotation-config/>
<import resource= "Classpath:meta-inf/cxf/cxf.xml"/>

<jaxrs:server id= "Restcontainer" address= "/" >
<jaxrs:serviceBeans><!--here to configure your WebService bean definition. Reference Org.iboxpay.payment.merchant.ws.MerchantWebService--
<!--<ref bean= "Orderwebservice"/> <ref bean= "Merchantwebservice"/>--
<ref bean= "Clearuserwebservice"/>
<ref bean= "Merchantwebservice"/>
<!--<ref bean= "Balancewebservice"/>--
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key= "JSON" value= "Application/json"/>
<entry key= "xml" value= "Application/xml"/>
</jaxrs:extensionMappings>
<jaxrs:providers>
<!--<ref bean= "Jsonexmapper"/>--
<ref bean= "Jaxbprovider"/>
<ref bean= "Jsonprovider"/>
</jaxrs:providers>

</jaxrs:server>
<bean id= "Jaxbprovider" class= "Org.apache.cxf.jaxrs.provider.JAXBElementProvider"/>
<!--******************** using Jackson as the serializer ***********************--
<bean id= "Jsonprovider" class= "Org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>

</beans>

The CXF plugin configuration in the Web. xml File WebService
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

Configuration of the Web service service in Java
Package com.iboxpay.clear.webservice;


Import Javax.annotation.Resource;
Import Javax.ws.rs.Consumes;
Import Javax.ws.rs.POST;
Import Javax.ws.rs.Path;
Import javax.ws.rs.Produces;
Import Javax.ws.rs.core.MediaType;

Import Org.springframework.stereotype.Service;

Import Com.iboxpay.clear.service.SysResourceService;

@Path ("/clearpro")
@Service ("Clearuserwebservice")
public class Clearwebservice {

@Resource
Private Sysresourceservice Sysresourceservice;

@Path ("/dispath")
@POST
@Produces ({mediatype.application_xml, Mediatype.application_json})
@Consumes ({mediatype.application_xml, Mediatype.application_json})
public string Dispath (string jsonstr) {
System.out.println ("=============we Test WebService by HTTP head start===========");
System.out.println (JSONSTR);
System.out.println ("=============we Test WebService by HTTP head end===========");
Return "Can You";
}

}

If you need to see the results returned in JMeter after performing the test, we need to create a new view result tree (right-click Thread Group > Add > Listener > View results tree) below the thread group, and in the Response data column you can see the results returned by the response

Pressure test of WebService with JMeter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.