SoapUI、Postman测试WebService

以前装了SoapUI,最近装了Postman,分别用它们测试了WebService,下面为用法。web

测试的在线WebService(数据来源于中国气象局)
Endpoint: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
WSDL: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl 测试

1、用SoapUI测试
一、菜单栏File -> New SOAP Project -> 打开窗口 ->
Initial WSDL 输入http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl
-> OK,SoapUI会自动把全部方法把列出来了。
-> 双击节点getSupportCity下面的Request,自动打开Request 1窗口,以下图spa

 

二、如今只需在 <web:byProvinceName>?</web:byProvinceName>中输入参数值,如:广东,
点击窗口的三角块,返回结果以下图:code

 


2、用Postman测试
一、点击中部的加号,出现Get Untitled Request标签页,以下图xml

 

二、把Get改为POST,后面输入WebService地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl
点击下面的Headers,设置Key为Content-Type,Value为text/xml;charset=UTF-8
点击Body,点击raw,在下面输入窗口中,输入SoapUI窗口的请求串:blog

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getSupportCity>
         <!--Optional:-->
         <web:byProvinceName>广东</web:byProvinceName>
      </web:getSupportCity>
   </soapenv:Body>
</soapenv:Envelope>

说明:get

(1) xmlns:web="http://WebXml.com.cn/" 里面地址http://WebXml.com.cn须要和WebService地址保持一致;
(2)xmlns:web的命名空间web须要和下面方法<web:getSupportCity>里面的web保持一致;
(3)getSupportCity为方法名;
(4)byProvinceName为参数;
点击上面的Send按钮,返回结果以下图it

 

总结:io

在测试WebService方面,用SoapUI很是方便,不单把全部方法把列出来,测试方法时也只须要输入参数值。
Postman测试过程很繁琐,好多地方都须要手动输入。asm

相关文章
相关标签/搜索