What is the simplest SOAP example using Javascript?
To be as useful as possible, the answer should:
Angularjs $http wrap base on XMLHttpRequest. As long as at the header content set following code will do.
"Content-Type": "text/xml; charset=utf-8"
For example:
function callSoap(){
var url = "http://www.webservicex.com/stockquote.asmx";
var soapXml = " "+
" "+
" "+
" "+
" "+
" "+
" "+
" ";
return $http({
url: url,
method: "POST",
data: soapXml,
headers: {
"Content-Type": "text/xml; charset=utf-8"
}
})
.then(callSoapComplete)
.catch(function(message){
return message;
});
function callSoapComplete(data, status, headers, config) {
// Convert to JSON Ojbect from xml
// var x2js = new X2JS();
// var str2json = x2js.xml_str2json(data.data);
// return str2json;
return data.data;
}
}