[GIS] Change in ArcGIS locator service causing error

arcgis-onlinearcgis-runtimearcgis-runtime-sdk-wpfarcgis-server

I have ran into an odd problem the last few days.

I am using ArcGIS for Runtime and ArcGIS for Server (which is located on a remote machine), as well are ArcMap to publish my services. My services are publishing fine and look OK in my server manager, but when I use my C# application containing the URL for the feature layer I am receiving the message:

Locator service failed: System.Net.WebExceptions: The remote server returned an error: (403) Forbidden.
 at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
 at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
 at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)

Here is an image of the error:

Forbidden

The odd thing about this problem is that the data is still loaded from the ArcGIS server and I still have all Feature Access capabilities.

My URL also looks like this:

Url="http://**.*.*.***:6080/arcgis/rest/services/DicksonCounty/FeatureServer/0"

So I figured out that the issue was with ArcGIS changing their locator service. I have a ArcGIS online subscription and I can still not figure out what site I am supposed to be using now instead of the one that is listed in all of their documentation.

http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Streets_US/GeocodeServer

Has anyone else experienced this?

How should I fix the issue.

Code for locating:

Locator FindlocatorTask = new Locator("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");
                FindlocatorTask.AddressToLocationsCompleted += FindLocatorTask_AddressToLocationsCompleted;
                FindlocatorTask.Failed += FindLocatorTask_Failed;
                AddressToLocationsParameters addressParams = new AddressToLocationsParameters();
                Dictionary<string, string> address = addressParams.Address;

                if (!string.IsNullOrEmpty(Address.Text))
                    address.Add("Street", Address.Text);
                if (!string.IsNullOrEmpty(City.Text))
                    address.Add("City", City.Text);
                if (!string.IsNullOrEmpty(State.Text))
                    address.Add("State", State.Text);
                if (!string.IsNullOrEmpty(Zip.Text))
                    address.Add("ZIP", Zip.Text);

                FindlocatorTask.AddressToLocationsAsync(addressParams);
                PortalGrid.Visibility = Visibility.Visible;
                AddressGrid.Visibility = Visibility.Collapsed;

Best Answer

It appears ESRI has been retiring their old free geocoding services, such as the one at http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Streets_US/GeocodeServer, as described if you visit that URL in a browser. I've found them to be up one minute, down the next, more often the latter as time goes on in the past week.

Anyway, the new ones are still free for certain use cases (like 'enter an address, zoom to it' as described here - basically any use other than batch geocoding), so in my case, with no ArcGIS Online subscription, a simple change from the old URL to the new one made my app work again, no other modifications needed. The new URL is:

http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer

If you go to that URL in a browser, it seems like you can't use it, but that is just because the Services Directory is disabled. An actual query will work - like go to this URL in a browser, you receive the answer:

http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=380+New+York+Street%2C+Redlands%2C+CA+92373&f=pjson

And the help for the new service, like how to use your subscription to do batch geocoding, is here.


Here's an example of what I'm doing, in Silverlight - hope it helps!

search address string as typed by the user: "101 s webster st madison wi"

my code snippet similar to yours:

            ESRI.ArcGIS.Client.Tasks.Locator locatorTask = new ESRI.ArcGIS.Client.Tasks.Locator
            {
                Url = locatorConfig.ArcGISLocator.RESTURL,
                ProxyURL = locatorConfig.ArcGISLocator.ProxyURL,
                Token = locatorConfig.ArcGISLocator.Token
            };
            locatorTask.AddressToLocationsCompleted += new EventHandler<ESRI.ArcGIS.Client.Tasks.AddressToLocationsEventArgs>(ArcGISLocator_GeocodeCompleted);
            locatorTask.Failed += new EventHandler<TaskFailedEventArgs>(ArcGISLocator_GeocodeFailed);
            AddressToLocationsParameters addressParams = new AddressToLocationsParameters();
            ArcGISLocatorParams paramFields = locatorConfig.ArcGISLocator.ParameterFields;

            if (!string.IsNullOrEmpty(paramFields.AddressField)) addressParams.Address.Add(paramFields.AddressField, address);
            if (!string.IsNullOrEmpty(paramFields.CityField)) addressParams.Address.Add(paramFields.CityField, city);
            if (!string.IsNullOrEmpty(paramFields.StateField)) addressParams.Address.Add(paramFields.StateField, state);
            if (!string.IsNullOrEmpty(paramFields.ZipField)) addressParams.Address.Add(paramFields.ZipField, zipCode);
            if (!string.IsNullOrEmpty(paramFields.CountryField)) addressParams.Address.Add(paramFields.CountryField, country);

            locatorTask.AddressToLocationsAsync(addressParams);

the values of the locatorConfig properties you see in the snippet:

The values of variables you see near the end of the snippet, parsed out of that address string:

  • address: "101 s webster st"
  • city: "madison"
  • state: "wi"
  • zipCode: ""
  • country: ""

And the request sent, grabbed from Fiddler:

GET http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?Address=+101+s+webster+st&City=madison&State=wi&Zip=&Country=&f=json& HTTP/1.1

and the response JSON, by pasting that URL into a browser address bar:

{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"101 S Webster St, Madison, Wisconsin, 53703","location":{"x":-89.380682603118885,"y":43.075083755112303},"score":100,"attributes":{}},{"address":"101 S Webster St, Madison, Wisconsin, 53703","location":{"x":-89.380801995315039,"y":43.075177953700688},"score":100,"attributes":{}},{"address":"101 N Webster St, Madison, Wisconsin, 53703","location":{"x":-89.383269776378313,"y":43.077020734720236},"score":92.430000000000007,"attributes":{}},{"address":"101 W Webster St, Madison, Tennessee, 37115","location":{"x":-86.717820077333897,"y":36.251970064368038},"score":92.430000000000007,"attributes":{}},{"address":"101 E Webster St, Madison, Tennessee, 37115","location":{"x":-86.717069182995601,"y":36.251749462468808},"score":92.430000000000007,"attributes":{}},{"address":"101 Webster Cir, Madison, Mississippi, 39110","location":{"x":-90.143067048604621,"y":32.471797799230103},"score":83.349999999999994,"attributes":{}},{"address":"102 S Webster St, Madison, Wisconsin, 53703","location":{"x":-89.380875912392696,"y":43.075155601051222},"score":79,"attributes":{}},{"address":"S Webster St, Madison, Wisconsin, 53703","location":{"x":-89.38031660062984,"y":43.074651800841025},"score":100,"attributes":{}},{"address":"Webster St, Madison, Illinois, 62060","location":{"x":-90.169549322842215,"y":38.681054079683122},"score":90.540000000000006,"attributes":{}},{"address":"N Webster St, Madison, Wisconsin, 53703","location":{"x":-89.382136680062956,"y":43.076082179749903},"score":90.540000000000006,"attributes":{}},{"address":"W Webster St, Madison, Tennessee, 37115","location":{"x":-86.717738909022671,"y":36.251902749213571},"score":90.540000000000006,"attributes":{}},{"address":"E Webster St, Madison, Tennessee, 37115","location":{"x":-86.715515843380672,"y":36.251021493648068},"score":90.540000000000006,"attributes":{}}]}
Related Question