目录

(五)soapUI创建SOAP项目

创建 SOAP 项目


打开 soapUI 工具。创建一个SOAP项目。

http://img.testclass.net/soapui_main_window.png

在窗口左侧导航栏,右键 Projects –> New SOAP Project

添加SOAP接口


以国内手机号码归属地查询接口为例:

Project Name:MobileCodeWS为项目名称。

Initial WSDL:http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl 为接口URL。

http://img.testclass.net/soapui_new_soap_project.png

点击 OK 按钮,创建项目完成。

依次展开:MobileCodeWS–>MobileCodeWSSoap–>getMobileCodeInfo/,双击 Request 1,填写接口查询的手机号。如下图。

http://img.testclass.net/soapui_soap_if_data.png

请求接口详细配置如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getMobileCodeInfo>
         <!--Optional:-->
         <web:mobileCode>186xxxxxxxx</web:mobileCode>
         <!--Optional:-->
         <web:userID></web:userID>
      </web:getMobileCodeInfo>
   </soapenv:Body>
</soapenv:Envelope>

注:将 xxxxxxxx 替换为手机号。

运行测试


点击 Request 1 窗口左上角的绿色 运行 按钮,发送 SOAP 请求。右侧窗口将会显示接口返回结果。

http://img.testclass.net/soapui_soap_if_request.png

一个简单的 SOAP 接口测试完成了。

原始封面

https://images.unsplash.com/photo-1491929007750-dce8ba76e610?w=300