I have exactly the same problem. I can get the token but not the Geocode
operation to succeeed. It throws "Credentials are either invalid or
unspecified." fault exception. On the GeocodeRequest, I create a brand new
Credentials instance and assign it token value to the one obtained from the
first web service call. The web service config for the GeocodeService is:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGeocodeService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://staging.dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IGeocodeService"
contract="ServiceReference1.IGeocodeService"
name="BasicHttpBinding_IGeocodeService" />
</client>
</system.serviceModel>
Here is my code:
TokenSpecification spec = new TokenSpecification();
spec.ClientIPAddress = myIPAddress;
spec.TokenValidityDurationMinutes = 60;
CommonServiceSoap tokenService = new CommonServiceSoap();
tokenService.Credentials = new NetworkCredential(myAccount,
myPassword);
//This works fine
string token = tokenService.GetClientToken(spec);
GeocodeRequest request = new GeocodeRequest();
request.Credentials = new Credentials();
request.Credentials.Token = token;
request.Query = "23405 N 22nd Way, AZ 85024";
// Set the options to only return high confidence results
ConfidenceFilter[] filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter();
filters[0].MinimumConfidence = Confidence.High;
GeocodeOptions geocodeOptions = new GeocodeOptions();
geocodeOptions.Filters = filters;
request.Options = geocodeOptions;
// Make the geocode request
GeocodeResponse response = null;
try
{
GeocodeServiceClient c = new GeocodeServiceClient();
//********** The following line throws exception **********
response = c.Geocode(request);
}
catch (Exception ex)
{
throw;
}
lblResults.Text = response.Results[0].DisplayName;
Any help is greatly appreciated.
Thanks.
Raghu/..
Post by Lee SHi,
I have a developer for virtual earth.
I can get retreive a client token by using token service successfully.
I used that token to Credentials property of GeocodeRequest class.
"Credentials are either invalid or unspecified".
http://staging.dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl
I am unable to proceed further in my development.
Any feedback is greatly appreciated.
Addition : By the way, I think the token is not the problem since
ImageryService is working correctly with that token.
Regards,
Lee