I've been getting quite a few messages about this "400: Bad Request" error people are seeing when trying to reference the Virtual Earth Web Service, more specifically when trying to fetch tokens so it's worth posting a little something on how to fix it. Specifically, the error is, "There was an error downloading 'http://staging.common.virtualearth.net/find-30/common.asmx'. The request failed with HTTP status 400: Bad Request."
The current documentation in the SDK shows a reference to https://staging.common.virtualearth.net/find-30/common.asmx; however, users aren't getting the WSDL downloaded (I've had this problem myself). So, the solution is to change the reference to https://staging.common.virtualearth.net/find-30/common.asmx?wsdl.
In Visual Studio 2008, you'll need to take a (odd) extra step. For some reason adding a Web Reference is different when you go to the "Add Service" advanced options than if you were to just Add Web Reference from Website menu. So, in Visual Studio 2008...
This should fix your issues. We'll be updating the SDK soon too.
CP
If you want to create a CS file using a WSDL utility, make sure you include your user name and password, otherwise you’ll get the same ‘400: Bad Request’ error:
wsdl.exe /l:CS /n:StagingVEToken /u:USERNAME /p:PASSWORD /out:bin/StagingVEToken.cs https://staging.common.virtualearth.net/find-30/common.asmx?wsdl
Just a note, that work around doesn't appear to work for me.
With VS NET 2010,can I add the Reference?
Yes - this is fixed in VS 2010.
I'm getting the same "400" error, after applying all of the suggestions above.
The URL I'm using is:
staging.common.virtualearth.net/.../common.asmx
and my IDE is VS 2005.
Though I receive this error, and thus cannot name the Web reference nor click the [disabled] Add Reference button, I do see six methods listed in the 'description' multi-line text box below the URL field. They are GetClientToken, GetCountryRegionInfo, GetDataSourceInfo, GetEntityTypes, GetGreatCircleDistances, and GetVersionInfo.
Also, I tried adding the above URL to the Trusted Sites along with this 2nd URL:
common.virtualearth.net/.../common.asmx
Still getting the error.
Please help, thanks.
No fun in VS 2005. You have to create your own proxy. Details here: msdn.microsoft.com/.../cc980833.aspx.
No joy for me either with the work around.
VS2008, SL3.0
Does not work for me!
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
I did all steps but I have same the problem why
greetings.