I have written a basic HTML page consisting of submit button , on button press a SOAP request will be send to my application URL. Below is the code i have written , i have face a 401-error.How can i over come this error???
i am unable to figure out the mistake ,request you to help me out. The same Soap body works when i try through SOA client
<html>
<head>
<title>SOAP JavaScript Client Test</title>
<b>Creating a SOAP body by passing url and crdentials</b>
<script type="text/javascript">
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'http:// URL?wsdl', true,'username','password');
// build SOAP request
var sr = '<soapenv:Envelope'+
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"' +
'xmlns:v1="http:// url/user/v1_1"' +
'xmlns:user="http:// url/user">' +
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
'<soapenv:Header/>' +
'<soapenv:Body >' +
'<v1:LogInRequest>' +
'<username xsi:type="xsd:string">username</username>' +
'<password xsi:type="xsd:string">password</password>' +
'</v1:LogInRequest>' +
'</soapenv:Body>' +
'</soapenv:Envelope>'
xmlhttp.onreadystatechange = function () {
//alert("HI");
if (xmlhttp.readyState == 4) {
// if (xmlhttp.status == 200) {
alert(xmlhttp.readyState);
alert(xmlhttp.status);
//}
//alert(xmlhttp.responseText);
}
}
// Send the POST request
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
}
</script>
</head>
<body> //
<form name="Demo" action="" method="post">
<div>
<input type="button" value="Soap" onclick="soap();" />
</div>
</form>
</body>
<html>