Vis*_*ati 8 xml post soap reactjs axios
我需要axios在我的React应用程序中使用SOAP端点请求.因此,我需要在请求中传递xml数据并接收响应中的xml数据.
我已经使用了带有json数据的axios post但是如何在xml中使用相同的?PFB我使用的代码相同,但它不起作用.
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);
Run Code Online (Sandbox Code Playgroud)
如果您对TIA有任何经验,请分享.
Chr*_*iki 11
我使用了@Anuragh KP 的答案,但带有 SOAPAction 标头
axios.post('https://wscredhomosocinalparceria.facilinformatica.com.br/WCF/Soap/Emprestimo.svc?wsdl',
xmls,
{headers:
{
'Content-Type': 'text/xml',
SOAPAction: 'http://schemas.facilinformatica.com.br/Facil.Credito.WsCred/IEmprestimo/CalcularPrevisaoDeParcelas'}
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err.response.data)
})
Run Code Online (Sandbox Code Playgroud)
let xmls='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\
xmlns:web="http://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('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl',
xmls,
{headers:
{'Content-Type': 'text/xml'}
}).then(res=>{
console.log(res);
}).catch(err=>{console.log(err)});
Run Code Online (Sandbox Code Playgroud)
此代码有助于制作肥皂请求
| 归档时间: |
|
| 查看次数: |
13824 次 |
| 最近记录: |