I am trying to send data in soap api but cannot do this. I tried all possible methods, but still get an error when calling api.
my api is http: //xyz.asmx? op = UserRegistration
and it excludes xml data 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>
Things I tried -
1> From $ 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 gives the error "cannot process the request. ---> Root element is missing"
2> With 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 gives an error Unable to read the getElementsByTagName property from null
Can someone help me with this? tried almost everything still out of luck. thanks in advance
javascript angularjs soap web-services ionic-framework
Vikas
source share