Reputation: 20130
I am trying to make a SOAP Request using Javascript but it does not seem to be working. Please find codes below that have been used.
URL="http://footballpool.dataaccess.eu/data/info.wso";
xmlStr="<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AllDefenders xmlns="http://footballpool.dataaccess.eu"> <sCountryName>string</sCountryName></AllDefenders></soap:Body></soap:Envelope>";
jQuery.ajax({
type: "POST",
url: URL,
dataType: "xml",
processData: false,
data: xmlStr,
beforeSend: function(req) {
req.setRequestHeader("Method", "POST");
req.setRequestHeader("Content-Type", "text/xml" + "; charset=\"" + "UTF-8" + "\"");
}
});
Response:
Object
OPTIONS http://footballpool.dataaccess.eu/data/info.wso 400 (Bad Request)
jquery.js:4 XMLHttpRequest cannot load http://footballpool.dataaccess.eu/data/info.wso. Origin http://www.know7.com is not allowed by Access-Control-Allow-Origin.
I am trying to get a Response from http://footballpool.dataaccess.eu/data/info.wso?op=AllDefenders
Thank you..
Upvotes: 0
Views: 2205
Reputation: 75063
You can't just call a url from other domain like that, or we would be all in really bad hands! You always need a proxy for what you're doing, either PHP, .NET, etc, that you would call that endpoint and receive the call and bypass to your javascript call.
You get the Cross Domain error:
Origin http://www.know7.com is not allowed by Access-Control-Allow-Origin.
That will tell you everything...
If you own this domain, you can open it up, by creating a cross-domain.xml
file, as well add a Html header allowing the cross domain call.
They offer you a way to get JSON back, but they are not sending it wrapped in a function, so you will always get an error:
http://jsbin.com/ivobun/1/edit
So, except for a Proxy, there is nothing you can do.
Upvotes: 1
Reputation: 13078
In addition to Endy
's answer you might want to check out this article on Mozilla DevNet about cross domain access of resources, and related check the HTTP headers of the server response. Specifically what the content of the Access-Control-Allow-Origin
header is as that will tell you which domains the server admins are allowing access to the specified resource.
https://developer.mozilla.org/en-US/docs/HTTP_access_control
Upvotes: 1
Reputation: 696
It seems as if you are trying to perform your request cross-domain. This is not allowed, only JSONP is.
Upvotes: 0