Dear All,
i am trying to call WFS service in arcgis javascript and its giving me following error
XMLHttpRequest cannot load http://192.168.100.47:7001/SpatialWS-SpatialWS-context-root/xmlwfsservlet?&service=WFS&request=GetCa.... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8083' is therefore not allowed access.
here is my javascript
$(document).delegate('#wfsksaregions', 'change', function () {
if (this.checked) {
var opts = {
"url": "http://192.168.100.47:7001/SpatialWS-SpatialWS-context-root/xmlwfsservlet?",
"version": "1.0.0",
"nsLayerName": "mvdemons:wfsKsaRegions",
"wkid": 8307,
"mode": "SNAPSHOT",
"maxFeatures": 100,
"showDetails": true,
"infoTemplate": new InfoTemplate()
};
_public._kabopt = opts;
// esriConfig.defaults.io.proxyUrl = "localhost:8083";
esriConfig.defaults.io.alwaysUseProxy = false;
esri.config.defaults.io.corsEnabledServers.push("192.168.100.47:7001","192.168.100.47:8083");
var wfslayer = new WFSLayer(opts);
_public._kabwfslayer=wfslayer;
alert ("hellooooooooo i am here adding WFS layer111");
_public._kablayer = wfslayer;
map.addLayer(wfslayer);
//_public._kabwaterbodies.show()
}
else{
alert ("hellooooooooo i am here removing WFS layer111");
//_public._kabwaterbodies.hide()
}
});
please somebody reply me as soon as possible
Thanks
Kabeer
Is the following line pointing to your proxy file in some way?
esriConfig.defaults.io.proxyUrl = "localhost:8083";
What type of proxy are you using (PHP, JSP, DotNet)?
Thank u very much
I am using eclipse IDE
Yes if I keep this code esri.config.defaults.io.proxyUrl = ""; then its giving following error
esri.config.defaults.io.proxyUrl is not set. If making a request to a CORS enabled server, please push the domain into esri.config.defaults.io.corsEnabledServers.
WFSLayer.js:20 WFSLayer: Error: esri.config.defaults.io.proxyUrl is not set. If making a request to a CORS enabled server, please push the domain into esri.config.defaults.io.corsEnabledServers.
What I should I do to get rid of this error
Thanks
Kabeer
Most browsers does not support localhost for CORS requests due to same-origin policy. In order to get CORS to work in your browser for development purpose, you can set the Access-Control-Allow-Origin,Access-Control-Allow-Headers, and Access-Control-Allow-Methods values to * in your web server.
You can aslo use a domain like lvh.me (which basically points to localhost) to fool your browser as if you are requesting from a remote server.