1. 程式人生 > >【JMeter4.0學習(三)】之SoapUI創建WebService接口模擬服務端以及JMeter測試SOAP協議性能測試腳本開發

【JMeter4.0學習(三)】之SoapUI創建WebService接口模擬服務端以及JMeter測試SOAP協議性能測試腳本開發

test 點擊 下一步 download enc text div 接口模擬 wid

目錄:

  • 創建WebService接口模擬服務端
    • 下載SoapUI
    • 新建MathUtil.wsdl文件
    • 創建一個SOAP項目
    • 接口模擬服務端配置以及啟動

【闡述】:首先應該遇到了一個共同的問題,JMeter3.2之後就沒有WebService(SOAP) Request,後來經過查詢網上資料得知其實可以用HTTP請求來操作,結果是一樣的。

具體資料大家可以參照原文《Jmeter測試SOAP協議(Jmeter 3.3)》感謝作者:stone9159

【步驟】:

一、創建WebService接口模擬服務端

如果大家有接口地址是最好啦,不過本人因為沒有接口地址,所以就自己手動模擬創建WebService接口模擬服務端。

參考資料:《SoapUI5.0創建WebService接口模擬服務端》感謝作者:sean-zou

1、首先,需要下載SoapUI:官方下載地址:https://www.soapui.org/downloads/latest-release.html

下載後,一直點擊下一步進行安裝就可以啦,在此不必陳述。

2、使用SoapUI創建WebService接口模擬服務端需要接口描述文件

新建文件:MathUtil.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://sean.com"
xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://sean.com" xmlns:intf="http://sean.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <
wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://sean.com" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="add"> <complexType> <sequence> <element name="x" type="xsd:int"/> <element name="y" type="xsd:int"/> </sequence> </complexType> </element> <element name="addResponse"> <complexType> <sequence> <element name="addReturn" type="xsd:int"/> </sequence> </complexType> </element> </schema> </wsdl:types> <wsdl:message name="addResponse"> <wsdl:part element="impl:addResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="addRequest"> <wsdl:part element="impl:add" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="MathUtil"> <wsdl:operation name="add"> <wsdl:input message="impl:addRequest" name="addRequest"> </wsdl:input> <wsdl:output message="impl:addResponse" name="addResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="MathUtilSoapBinding" type="impl:MathUtil"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="add"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="addRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="addResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="MathUtilService"> <wsdl:port binding="impl:MathUtilSoapBinding" name="MathUtil"> <wsdlsoap:address location="http://localhost:8080/webservice_create/services/MathUtil"/> </wsdl:port> </wsdl:service> </wsdl:definitions>

3、打開SoapUI,通過MathUtil.wsdl文件在SoapUI中創建一個SOAP項目:

技術分享圖片

技術分享圖片

確認後,會在新建的SOAP項目下自動生成模擬客戶端

在模擬客戶端的基礎上創建一個接口模擬服務端(Mock Service):

技術分享圖片

技術分享圖片

確定後,雙擊【Response1】

技術分享圖片

返回值默認為"?",一定要進行修改,否則調用該接口時會報錯

技術分享圖片

技術分享圖片

4、接口模擬服務端配置以及啟動

雙擊創建的接口模擬服務端:

技術分享圖片

【JMeter4.0學習(三)】之SoapUI創建WebService接口模擬服務端以及JMeter測試SOAP協議性能測試腳本開發