Jmeter接口测试webservice

可以用jmeter两种sampler进行webservice的测试

webservice公共接口的发送报文格式的获取:(以SoapUI为例)

1、新建一个SOAP Project,在initial WSDL输入原始的WSDL地址:http://ws.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl

2、选择需要测试的接口

 

 

 3、找到测试的地址和发送的报文的格式

 

 

一、SOAP/XML-RPC Request(在jmeter3.2以后版本中已经取消了这个取样器)

1、新建线程组、SOAP/XML-PRC Request sampler 、响应断言、察看结果树

1 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
2    <soapenv:Header/>
3    <soapenv:Body>
4       <web:getTVstationString>
5          <web:theAreaID>12</web:theAreaID>
6       </web:getTVstationString>
7    </soapenv:Body>
8 </soapenv:Envelope>

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

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

4  <web:getTVstationString>

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


2、在响应断言中进行断言,是否响应内容是需要的内容,如下

 

3、察看结果树

 

 

 

 

二、HTTP请求进行Webservice接口测试

1、建立HTTP请求,如图,请求内容写在BODY DATA里,选择方法为post

 

2、建立HTTP头信息,如下

Soapaction地址和第一种方法一致

 SoapAction      http://WebXml.com.cn/getTVstationString

Content-Type   text/xml

 

 

posted @ 2017-07-13 11:20  来呀快活吧  阅读(10899)  评论(0编辑  收藏  举报
cs