2
I have an Ajax function doing a POST for a SOAP webservice and I need to insert values into the request XML elements based on what the page user inserts into an input text. How can I do that?
My script looks like this:
var soapMessage = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://teste.transaction.service">\
<SOAP-ENV:Header>\
<ns1:testeHeader>\
<channel>Portal</channel>\
</ns1:testeHeader>\
</SOAP-ENV:Header>\
<SOAP-ENV:Body>\
<teste:VC>\
<teste:VCRequestHeader>\
<PIN>1234</PIN>\
</teste:VCRequestHeader >\
</teste:VC_WSLOGIN>\
</SOAP-ENV:Body>\
</SOAP-ENV:Envelope>';
$.ajax({
type: "POST",
dataType: "xml",
url: wsUrl,
data: soapMessage,
crossDomain: true,
success: function(data) {
console.log(data);
},
error: function(error) {
console.log(error);
}
});
Thanks in advance for your attention.
has tried to parser?
var parser = new DOMParser();
var soapMsg = parser.parseFromString(soapMessage, "text/xml");
– Tobias Mesquita