Я настоятельно рекомендую ОТДЫХ! Это намного более легкий вес
Я пользователь jQuery в этом примере
На вашей html странице
<script id="soap-template" type="application/soap-template"> <?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><ns0:getSOAP xmlns:ns0="http://localhost:8080/soap"> <search>${id}</search></ns0:getSOAP ></soap:Body></soap:Envelope></script>
JS:
var soapBody = $("#soap-template").html().replace(
new RegExp( "\\$\\{[^}]+\\}", "i" ),
search
);
soapBody = $.trim( soapBody );
$.ajax({
type: "post",
url: "http://localhost:8080/soap",
contentType: "text/xml",
data: soapBody,
dataType: "xml",
processData: false,
beforeSend: function( xhr ){
// Pass the target URL onto the proxy.
xhr.setRequestHeader(
"SOAPTarget",
"http://localhost:8080/soap"
);
// Pass the action onto the proxy.
xhr.setRequestHeader(
"SOAPAction",
"http://localhost:8080/soap/getSOAP"
);
},
success: function( response ){
// Get a jQuery-ized version of the response.
var xml = $( response );
//handle your result
},
error: function(){
alert("error");
console.log( "ERROR", arguments );
}
});