I am new to JS and jquery. I want to access a SOAP web service to access GPS information of our commuter buses. I am able to do so using a .Net program on the sever side but I want to do the same on the client side.
I am not sure where I am going wrong.
Would all SOAP web service respond to Jquery? or is the issue with my code.
<html>
<head>
<title>SOAP JavaScript Client Test</title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function OnSuccess(data, status) {
alert(data.d);
}
$(document).ready(function() {
jQuery.support.cors = true;
});
function OnError(request, status, error)
{
alert(error.responseText + " " + status);
}
function signOn() {
// build SOAP request
var acct = ####;
var user = '#####';
var webServiceURL = 'http://wd.air-trak.com/ATAuthenticationWS/service.asmx?op=GetKey';
var soapMessage = '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
+' xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"'
+' <soap12:Body>'
+' <GetKey xmlns="http://www.air-trak.com/API/ATAuthenticationWS/"'
+' <pAccount>' + acct+ '</pAccount>'
+' <pUser>' +user+ '</pUser>'
+' </GetKey>'
+' </soap12:Body>'
+'</soap12:Envelope>';;
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
data: soapMessage,
processData: false,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
}
</script>
<form name="Demo" action="" method="post">
<div>
<input type="button" value="test" onclick="signOn();" />
</div>
</form>
</body>
<html>