0
votes

I have a plugin that use Geocode web service of bing maps to retrieve data.

This is how i set my client:

  BasicHttpBinding bindingBing = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
  GeocodeServiceClient geocodeService = new GeocodeServiceClient(bindingBing, new EndpointAddress("https://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc"));
  geocodeService.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 30);

  GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);

I need to NOT do the geocodeReponse if the service is unavaible or my bing maps key is invalid. Right now, it trys to make the request and fails everytime. I dont know what i missing between my client and my response. Any help?

1

1 Answers

1
votes

You need to specify credentials. Here is an example:

GeocodeRequest geocodeRequest = new GeocodeRequest();

// Set the credentials using a valid Bing Maps key
geocodeRequest.Credentials = new GeocodeService.Credentials();
geocodeRequest.Credentials.ApplicationId = key;

That said, you may have noticed that the documentation for the Bing Maps SOAP services is no longer online. I would take this as a hint. I stopped recommending the Bing Maps SOAP services when the REST services were released 5 years ago. The REST services are faster, have more features, and has a smaller response size which means less bandwidth usage. There REST services should always be used instead of the SOAP services. You can find documentation on the Bing Maps REST services here: http://msdn.microsoft.com/en-us/library/ff701713.aspx There is also information in there on how to use them in .NET.