Select to view content in your preferred language

GeometryServic Buffer Task & Access-Control-Allow-Origin

1681
6
03-01-2013 01:13 PM
AaronConnolly
Regular Contributor
Hi,

I've read alot about Access-Control-Allow-Origin issues with Chrome on this forum, already but I can't seem to find a solution to my problem. What is happening is this. A user searches for an address in my app and then my app takes the x,y of the address and attempts to have a buffer graphic created around that x,y and then I display the point and the circle buffer on the map. In all other browsers this works fine, but in Chrome the buffer task is killed by the browser:

XMLHttpRequest cannot load http://mapping.theomegagroup.com/ArcGIS/rest/info?f=json. Origin http://www.crimemapping.com is not allowed by Access-Control-Allow-Origin. 


In previous threads I have read that the Access-Control-Allow-Origin error can be safely ignored, but why does this same error break my buffer processing?

I'm not sure that adding this to my ArcGIS Server web.config is going to work because it opens it up for Cross Site scripting access, right? Though I've heard this would work.

    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>


Can anyone help me with this? I don't control the request that is sent out by the buffer task and so I can't specify JSONP types, etc... Is this a proxy page issue? Why does this work in other browsers and not Chrome?

Thanks,
-Aaron
0 Kudos
6 Replies
AaronConnolly
Regular Contributor
I've tried the solution presented here and now I don't get an Access-Control-Allow-Origin policy violation, however my buffer task doesn't return to the javascript. I don't get an error or a success response:

http://forums.arcgis.com/threads/65708-Access-Control-Allow-Origin?highlight=access-control-allow-or...

Looking at the web traffic the buffer task completes, but it seems that something within the API is failing because it doesn't fire a success/failure response.

Any help with this would be greatly appreciated. Has anyone else experienced this issue?
0 Kudos
KellyHutchins
Esri Notable Contributor
Is your server cors enabled?  If not check out enable-cors.org for details on how to enable this capability for your server.
0 Kudos
AaronConnolly
Regular Contributor
Kelly,

I'm working from Visual Studio's and temp web server when run the app through the IDE. I'm also attempting to run a buffer task and then a query task on a service running on a machine in my domain. I'm not sure exactly how to test this server on my domain with the CORS test.

I have the following in my app's web.config:

  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*"/>
      </customHeaders>
    </httpProtocol>
</system.WebServer>


I have also added this to the /rest/web.config and /services/web.config in my ArcGIS Server instance running on the machine that hosts it. None of this works consistently.

I've also tried updating from version 3.2 to 3.3 and have had some luck in that buffering seems to work, but now the queryTask is failing the same way the buffer failed previously. It runs and doesn't return a response. This happens in Firefox and Chrome.

What is going on? Why are these responses failing like this? What changed in the API or in Chrome to cause these issues? I'm really not sure what exactly is causing this issue and so I'm just guessing at the solution.

Thanks,
- Aaron
0 Kudos
AaronConnolly
Regular Contributor
Also, could this have anything to do with the settings in my proxy page?
0 Kudos
AaronConnolly
Regular Contributor
Is your server cors enabled?  If not check out enable-cors.org for details on how to enable this capability for your server.


I checked this out and then looked on my web server which is running ArcGIS Server and hosting the two services I'm attempting to use. I use a buffer task and a query task, and they're both targeting the same instance:

http://some.local.domain/ArcGIS/rest/services/

On 'some.local.domain' ArcGIS Server has several web.configs, one in /rest and another in /services, which of these (or both?) need to have this configuration set up: ?

<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
      </customHeaders>
    </httpProtocol>


I've added this in both places to no avail. Perhaps I'm missing something here about CORS. Where on my "server" does this setting go? I'm just targeting ArcGIS Server locally.
0 Kudos
AaronConnolly
Regular Contributor
I've followed the instructions for IIS7 found here:

http://enable-cors.org/server.html

I put a web.config in c:\inetpub\wwwroot\ArcGIS\ with the specified XML and the application is still not working. What am I doing wrong? Why would a buffer task work, but not a query task?
0 Kudos