vue使用axios请求soap

2022-07-26,,,

下载x2js并全局引用(为了解析SOAP返回的xml数据)
1、yarn add x2js
2、在main.js页面引入
import x2js from ‘x2js’ //xml数据处理插件
Vue.prototype.$x2js = new x2js() //创建x2js对象,挂到vue原型上

let xmlHeader = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sdtRMService"><soapenv:Header/>';
let xmlBody = '<soapenv:Body><urn:requestPullStream soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><szInfo xsi:type="xsd:string">{ "userId": '+ uid +', "requestType": '+ type +' }</szInfo></urn:requestPullStream></soapenv:Body>';
let xmlFooter = '</soapenv:Envelope>'; 
let xml = xmlHeader + xmlBody + xmlFooter;
requestPullStream(xml).then((res)=>{
	let soapXml = that.$x2js.xml2js(res);
	let data = JSON.parse(soapXml.Envelope.Body.requestPullStreamResponse.szResult);
})

本文地址:https://blog.csdn.net/Hai_Lan123/article/details/110519496

《vue使用axios请求soap.doc》

下载本文的Word格式文档,以方便收藏与打印。