使用 axios 向 SOAP 端点发出请求

编程入门 行业动态 更新时间:2024-10-26 17:23:16
本文介绍了使用 axios 向 SOAP 端点发出请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在我的 React 应用程序中使用 axios 向 SOAP 端点发出请求.因此,我需要在请求中传递 xml 数据并在响应中接收 xml 数据.

I need to make request to SOAP endpoint using axios in my React application. Hence I need to pass xml data in request and receive xml data in response.

我已经将 axios 帖子与 json 数据一起使用,但是如何将相同的内容用于 xml?PFB 我正在使用的代码相同,但它不起作用.

I have used the axios post with json data but how do I use the same for xml? PFB the code I am using for the same, but it does not work.

JSON 发布请求:

var xmlData = <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> var config = { headers: {'Content-Type': 'text/xml'} }; axios.post('/save', xmlData, config);

如果您对此有任何经验,请分享,TIA.

Please share if you have any experience with this, TIA.

推荐答案

let xmls='<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap/soap/envelope/" xmlns:web="www.webserviceX.NET/"> <soapenv:Header/> <soapenv:Body> <web:ConversionRate> <web:FromCurrency>INR</web:FromCurrency> <web:ToCurrency>USD</web:ToCurrency> </web:ConversionRate> </soapenv:Body> </soapenv:Envelope>'; axios.post('www.webservicex/CurrencyConvertor.asmx?wsdl', xmls, {headers: {'Content-Type': 'text/xml'} }).then(res=>{ console.log(res); }).catch(err=>{console.log(err)});

此代码有助于发出soap请求

更多推荐

使用 axios 向 SOAP 端点发出请求

本文发布于:2023-10-09 18:48:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:axios   SOAP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!