Postman、SoapUI测试WebService接口

一、使用Postman测试WebService接口

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

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

image

1、打开Postman界面如下:

设置请求方式为”POST”

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

image

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

注意引用变量{{pw}}

image

说明:

  • (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为参数;

设置脚本和登录令牌

image

//生成令牌
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;
}

请求结果如下:

image

二、用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窗口,如下图

image

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

image

猜你喜欢

转载自www.cnblogs.com/springsnow/p/12533224.html