ps:这两个都是在开发模式下执行通过,在正式发布听说会有https校验?没有测试过
第一种方式:这是调用不带参数的,带参数的待解决。
WebSvcAccess:function()
{
var wsdlurl = "http://xxxx/xxx.asmx/HelloWorld";//填入自己的接口
var tmpData= '<?xml version="1.0" encoding="utf-8"?>';
tmpData+= '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
tmpData+= '<soap:Body>';
tmpData+= '<HelloWorld xmlns="http://tempuri.org/" />';
// tmpData+= '<desid>2021</desid>'; //带参数,失败了。。。
tmpData+='</HelloWorld>';
tmpData+= '</soap:Body>';
tmpData+= '</soap:Envelope>';
wx.request({
url: wsdlurl,
data: tmpData,
method: 'POST',
header: {
'content-type':'text/xml; charset=utf-8',
'SOAPAction': "http://tempuri.org/HelloWorld",
},
success:
function (res) {
console.log(res);
},
fail:function(){
console.log("请求失败");
},
complete:function(){
console.log("请求完成");
}
})
},
第二种方式:
WebSvcAccess:function()
{
var wsdlurl = "http://xxxx/xxx.asmx/GetAllStudentScore";//填入自己的接口
wx.request({
url: wsdlurl,
data: {
'name':'value',//传入参数和值
},
method: 'POST',
header: {
'Content-Type':'application/x-www-form-urlencoded'
},
success:
function (res) {
console.log(res);
},
fail:function(){
console.log("请求失败");
},
complete:function(){
console.log("请求完成");
}
})
},