SOAP API call using HTTP native in Ionic V5

Is there a way to call SOAP API using the HTTP ionic native(@ionic-native/http/ngx)?

I am able to call the SOAP API using the old school like this, but I am getting the CORS error but I cannot do anything about the endpoint since I do not control it, so I am trying to consume the API using the HTTP Native call to by-pass the CORS error:

soapAPIOld() {

// tslint:disable-next-line:prefer-const

let xmlhttp = new XMLHttpRequest();

xmlhttp.open(‘POST’, ‘https://some.com.ph/?wsdl’, true);

// tslint:disable-next-line:max-line-length

const request =

`<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:rem=“http://endPointAPI”>

<soapenv:Header/>

  <soapenv:Body>

    <rem:apiRequest>

    </rem:apiRequest>

  </soapenv:Body>

</soapenv:Envelope>`;

xmlhttp.onreadystatechange = () => {

  if (xmlhttp.readyState === 4) {

    if (xmlhttp.status === 200) {

      // tslint:disable-next-line:prefer-const

      let xml = xmlhttp.responseXML;

      alert(xmlhttp.responseText);

  } else {

    alert('XML response ' + xmlhttp.responseXML);

    alert(xmlhttp.status);

  }

  }

};

// Send the POST request

xmlhttp.setRequestHeader(‘Content-Type’, ‘text/xml’);

xmlhttp.responseType = ‘document’;

xmlhttp.send(request);

}

HTTP native call code snippet, I am getting the error response always but when I try it in SOAP UI or Postman, the API call succeeds:

soapAPINative() {

console.log(‘SOAP call’);

// tslint:disable-next-line:max-line-length

const body =

`<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:rem=“http://endPointAPI”>

<soapenv:Header/>

  <soapenv:Body>

    <rem:apiRequest>

    </rem:apiRequest>

  </soapenv:Body>

</soapenv:Envelope>`;

// tslint:disable-next-line:max-line-length

this.http.get(‘https://some.com.ph/?wsdl’, body, {})

.then(data => {

console.log('SUCESS ' + data.status);

console.log('SUCESS ' + data.data);

console.log('SUCESS ' + data.headers);

})

.catch(error => {

console.log('ERROR ' + error.status);

console.log('ERROR ' + error.error);

console.log('ERROR ' + error.headers);

});

}

Any help would be appreciated!