我試圖將數據發佈到soap api,但無法這樣做。 我已經嘗試了所有可能的方法,但仍然在調用API時出錯。將數據發佈到角度爲js的SOAP api
我的API是 - http://xyz.asmx?op=UserRegistration
,並以XML格式節選數據,如
<?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>
的事情,我已經嘗試 -
1> $ 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'}
});
這給出錯誤「無法處理請求。 --- >缺少根元素」
2>的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;
這是給錯誤無法讀取空的特性‘的getElementsByTagName’
任何人都可以請幫我在這一個?試過幾乎所有的東西仍然沒有運氣。在此先感謝