I've had success when calling REST APIs when using axios
However, I need to call a SOAP web service from an old system
Is this possible using axios?
See sample code of my failed try:
callSoap() {
let xmls =
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\
<soap:Body>\
<mtdGetTestNumber xmlns="http://test.com/services">\
<AccountNumber>string</AccountNumber>\
<RequestType>string</RequestType>\
</mtdGetTestNumber>\
</soap:Body>\
</soap:Envelope>';
let xmls2 =
'<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">\
<soap12:Body>\
<mtdGetTestNumber xmlns="http://test.com/services">\
<AccountNumber>string</AccountNumber>\
<RequestType>string</RequestType>\
</mtdGetTestNumber>\
</soap12:Body>\
</soap12:Envelope>';
return axios.post(
"http://192.254.1.2:8083/Service.asmx?op=mtdTestNumber",
xmls,
{
headers: { "Content-Type": "text/xml" },
}
);
}
This does not show any error when I return the error response.
Can someone enlighten me if this is possible?
Or should I create an API in backend (in my case its Spring Boot) to call the SOAP API then convert the xml response from SOAP to JSON and use that JSON to response to web?
TIA