by Davide83 » 7 September 2016, 15:12
per me basterebbe un semplice esempio per una soap request.
io ho utilizzato il seguente codice
<title>SOAP JavaScript Client Test</title>
<script type="text/javascript">
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'https://miourl.asmx', true);
// build SOAP request
var sr =
'<?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>'+
'<Login xmlns="http://mioindirizzo">'+
'<username>prova</username>'+
'<password>prova</password>'+
'</Login>'+
'</soap:Body>'+
'</soap:Envelope>';
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
//xmlhttp.setRequestHeader('Access-Control-Allow-Origin: *');
xmlhttp.send(sr);
// send request
// ...
}
</script>
</head>
<body>
<form name="Demo" action="" method="post">
<div>
<input type="button" value="Soap" onclick="soap();" />
</div>
</form>
</body>
questo codice funziona su chrome ma copiandolo in inde cloud da errore, non trova XMLHttpRequest