I have created a soap web service in JDeveloper and installed it on my SOA server and then created an OSB proxy service for it. I can call this proxy successfully from SOAP UI, from a .net client application and from a classic asp web page. I have a developer in another dept. that wants to use my web service from javascript - using AJAX. I must admit I'm not very familiar with AJAX. He sent me his code and I have been searching and trying various ways to call my service from AJAX but they all fail with a 500 error - in the SOA log, I am seeing the error 'Unexpected EOF in prolog' everytime I try to call the service.
Here is the code that is calling the service (you can see many commented out attempts - and I have tried more than this - the webserver this code is running on is in the same domain as my SOA servers).
Any pointers or ideas would be greatly appreciated. I could upload a working call to the service in classic asp if that would help - for comparison. Thanks.
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.10.1.min.js"></script
<script src="http://code.jquery.com/jquery-ui-1.10.2.custom.min.js"></script>
<script type="text/javascript">
var webServiceURL = 'http://xxx.xxx.xxx.xxx/Address/GetNBPlaces/GetNBPlacesProxy';
// var soapMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:get="http://getnbplaces/"><soap:Header/><soap:Body><get:GetNBPlaceList/></soap:Body></soap:Envelope>';
// 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><GetNBPlaceList xmlns:ns1="http://getnbplaces/" /></soap12:Body></soap12:Envelope>';
var soapMessage =
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://getnbplaces/">' +
'<soapenv:Header/>' +
'<soapenv:Body>' +
'<ns1:GetNBPlaceList></ns1:GetNBPlaceList>'
'</soapenv:Body>' +
'</soapenv:Envelope>';
//var soapMessage = '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">' +
//'<env:Header />' +
//'<env:Body>' +
//'<GetNBPlaceList xmlns="http://getnbplaces/" />' +
//'</env:Body>' +
//'</env:Envelope>';
function CallService()
{
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
contentType: "text/xml; charset=\"utf-8\"",
headers: {
SOAPAction: "http://xxx.xxx.xxx.xxx/Address/GetNBPlaces/GetNBPlacesProxy/GetNBPlaceList"
},
//processData: false,
//crossDomain: true,
data: soapMessage,
success: OnSuccess,
error: OnError
});
return false;
}
function OnSuccess(data, status)
{
alert(data.d);
}
function OnError(request, status, error)
{
alert('error' + ' status = ' + status + ' error desc = ' + error );
}
//$(document).ready(function() {
//jQuery.support.cors = true;
//})