I've been struggling to send data to a SOAP API but have hit a roadblock. I've attempted various methods but continue to encounter errors when making the API call.
The API URL is -
and it requires data in XML format like
<?xml version="1.0" encoding="utf-8"?>
<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>
<UserRegistration xmlns="http://Service/">
<Usercreditional>string</Usercreditional>
</UserRegistration>
</soap:Body>
</soap:Envelope>
Methods I've tried -
1> Using $http.post
var soapData = '<?xml version="1.0" encoding="utf-8"?>'+
'<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>'+
'<UserRegistration xmlns="http://Service/">'+
'<Usercreditional>[{ \'DeviceUUID\': \'' + data.DeviceUUID + '\', ' +
"\"DevicePushID\":\"" + data.DevicePushID + "\"}]" +
'</Usercreditional></UserRegistration></soap:Body></soap:Envelope>';
return $http({
method: 'POST',
url: ' http://xyz.asmx?op=UserRegistration',
data : soapData,
headers : { "Content-Type" : 'application/xml'}
});
This results in the error message "unable to process request. ---> Root element is missing"
2> Using SOAPClient
var deferred = $q.defer();
var soapParams = new SOAPClientParameters();
var userCredentials = [{"DeviceUUID": data.DeviceUUID, "DevicePushID": data.DevicePushID}];
for (var param in userCredentials )
{
soapParams.add(param, soapParams[param]);
}
var soapCallback = function (e) {
if (e.constructor.toString().indexOf("function Error()") != -1) {
deferred.reject(e);
} else {
deferred.resolve(e);
}
};
SOAPClient.invoke(' http://xyz.asmx', 'UserRegistration', soapParams, true, soapCallback);
return deferred.promise;
This is throwing an error stating "Cannot read property 'getElementsByTagName' of null"
Can someone please assist me with this issue? I've exhausted all options without success. Thank you in advance