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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM