WebService() {
let url = '';
let targetNamespace = '';
let targetMethod = '';
let xmlData = '' //请求的xml数据
wx.request({
url: url,
data: xmlData,
method: 'POST',
header: {
// 'token': getApp().globalData.token,
'content-type': 'text/xml; charset=utf-8',
// 注意:在SOAP 1.2规范中,SOAPAction header这个属性被"action"所取代,但其作用和工作原理都没有变化。
'SOAPAction': targetNamespace + targetMethod
},
success: response => {
let res = response.data
console.log(res)
},
fail() {},
complete() {}
})
}
2021-09-20 微信小程序WebService调用接口
最新推荐文章于 2024-04-20 00:09:24 发布
本文介绍了一种通过微信小程序利用WebService发送POST请求的方法。具体实现包括设置请求URL、指定目标命名空间与方法、构造XML数据并定义合适的头部信息。文中还提到了SOAPAction的作用及在SOAP1.2规范中的变化。
2万+

被折叠的 条评论
为什么被折叠?



