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":{}}]}