欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

vue使用axios请求soap

程序员文章站 2022-06-24 12:44:29
下载x2js并全局引用(为了解析SOAP返回的xml数据)1、yarn add x2js2、在main.js页面引入import x2js from ‘x2js’ //xml数据处理插件Vue.prototype.$x2js = new x2js() //创建x2js对象,挂到vue原型上let xmlHeader = '

下载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

相关标签: js vue