一、使用Postman测试WebService接口

Postman:适用RESTful接口(HTTP/HTTPS协议)的功能测试

通过浏览器访问 http://oa.tmt.tcl.com/ekp/sys/webservice/scbcWebserviceEntrance?wsdl可以看到如下信息:

使用Postman和SoapUI工具测试WebService接口_程序员

打开Postman界面如下:

设置请求方式为”POST”

设置Content-Type为text/xml;charset=UTF-8

使用Postman和SoapUI工具测试WebService接口_测试工具_02

设置body请求调用的方法excute及对应的参数param

注意引用变量{{pw}}

使用Postman和SoapUI工具测试WebService接口_接口测试_03

说明:

  • (1) xmlns:ser="http://service.util.odm.kmss.landray.com/"里面地址http://service.util.odm.kmss.landray.com/"需要和WebService地址保持一致;
  • (2)xmlns:ser的命名空间web需要和上面方法 <ser:execute>里面的web保持一致;
  • (3)execute为方法名;
  • (4)arg0为参数;
设置脚本和登录令牌

使用Postman和SoapUI工具测试WebService接口_接口测试_04

//生成令牌
var pw = "scbcsmes"+getMyDate(new Date());


console.log("pw:==",pw);
var md5Str =CryptoJS.MD5(pw);
postman.setGlobalVariable("pw", md5Str.toString(CryptoJS.enc.Hex).toUpperCase());
 
 
function getMyDate(str) {
if (str == null || str == "") {
return '';
}
var oDate = new Date(str),
oYear = oDate.getFullYear(),
oMonth = oDate.getMonth() + 1,
oDay = oDate.getDate(),
oHour = oDate.getHours(),
oMin = oDate.getMinutes(),
oTime = oYear + '' + getzf(oMonth) + '' + getzf(oDay) + '' + getzf(oHour) + '' + getzf(oMin) ;//最后拼接时间
return oTime;
};
function getzf(num) {
if (parseInt(num) < 10) {
num = '0' + num;
}
return num;
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
请求结果如下:

使用Postman和SoapUI工具测试WebService接口_程序员_05

二、用SoapUI测试WebService接口

SoapUI:适用WebService接口(SOAP协议)的测试

1、菜单栏File -> New SOAP Project -> 打开窗口 ->Initial WSDL 输入 http://oa.tmt.tcl.com/ekp/sys/webservice/scbcWebserviceEntrance?wsdl-> OK,SoapUI会自动把所有方法把列出来了。
-> 双击节点execute下面的Request,自动打开Request 1窗口,如下图

使用Postman和SoapUI工具测试WebService接口_postman_06

2、现在只需在 <arg0>?</arg0>中输入参数值, 点击窗口的三角块,返回结果如下图:

使用Postman和SoapUI工具测试WebService接口_测试工具_07