jmeter achieve webservice interface test

In fact, the test can be carried out webservice jmeter two kinds sampler:

1, SOAP / XML-RPC Request (but jmeter3.2 later version has been canceled this sampler)

2, HTTP requests

The following describes two ways

First, we first need to use the information soupUI Tool crawl webservice interface part needed.

1, the new project

2, the new success of the project information below:

3, select the interface you want to test, right-new request

4, edit the message content, click the top left corner of the green triangle button to perform the right window to view the results of interface requests

5, can copy packets under transmission format

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/">
<soap:Header/>
<soap:Body>
<web:getSupportCity>
<!--Optional:-->
<web:byProvinceName>?</web:byProvinceName>
</web:getSupportCity>
</soap:Body>
</soap:Envelope>

Second, the use of SOAP / XML-RPC Request (but jmeter3.2 later version has been canceled this sampler) in the form of testing, the following casually put a picture, because I use the jmeter version 3.3, you have a SOAP / XML -RPC Request sampler, but mainly with the second test form.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getTVstationString>
         <web:theAreaID>12</web:theAreaID>
      </web:getTVstationString>
   </soapenv:Body>
</soapenv:Envelope>

  soapaction的地址:为第1行数据和第4行接口的相叠加的内容

1   web="http://WebXml.com.cn/"  

4  <web:getTVstationString>
形成地址:http://WebXml.com.cn/getTVstationString
对于公共的webservice接口,可以使用soapUI进行抓取,或者是其他工具去抓取发送报文的格式

三、使用HTTP请求sampler来测试webservice接口
1、建立HTTP请求,如图,请求内容写在BODY DATA里,选择方法为post
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getSupportCity xmlns="http://WebXml.com.cn/">
      <byProvinceName>河南</byProvinceName>
    </getSupportCity>
  </soap:Body>
</soap:Envelope>

 

 

2、建立HTTP头信息,如下

Soapaction地址和第一种方法一致

3、接着建立下一个接口请求,方式同上

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getWeatherbyCityName xmlns="http://WebXml.com.cn/">
      <theCityName>${b1}</theCityName>
    </getWeatherbyCityName>
  </soap:Body>
</soap:Envelope>

4、最终执行的请求结果如下图:

 

 

 



Guess you like

Origin www.cnblogs.com/evachen/p/11373832.html