Make request to SOAP endpoint using axios

前端 未结 2 1721
梦毁少年i
梦毁少年i 2020-12-05 05:28

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 respo

相关标签:
2条回答
  • 2020-12-05 06:10
    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)});
    

    This code help to make soap request

    0 讨论(0)
  • 2020-12-05 06:17

    I used the answer of @Anuragh KP but with a SOAPAction header

    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)
      })
    
    0 讨论(0)
提交回复
热议问题