HTTP Error 403 while consuming ImageryService RRS feed

  • Question

  • Hello.

    I want to use the Bing Maps Imagery Service (URL: )

    Therefore I added a service reference to my ASP.Net WebSite in my Visual Studio 2010. This seems to have worked.

    But if I want to use the service with the code beyond I get the following error:
    The HTTP request was forbidden with client authentication scheme 'Anonymous'.

    The remote server returned an error: (403) Forbidden.

     oMapUriRequest As
    oMapUriRequest.Credentials = New  ImageryService.Credentials () With  {.ApplicationId = GetStaticBingMapsKey("1" )}
    oMapUriRequest.Center = New  ImageryService.Location () With  {.Latitude = 0, .Longitude = 0}

    Dim  oMapUriResponse As  ImageryService.MapUriResponse

    Using  ws = New  ImageryService.ImageryServiceClient ("BasicHttpBinding_IImageryService" )
        oMapUriResponse = ws.GetMapUri(oMapUriRequest)
    End  Using



    returns the Bing Maps Key either of staging ("1") or production ("0") environment.

    Here is the snippet of the web.config containing the binding:

         <binding name="BasicHttpBinding_IImageryService" 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"
             <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" />

    Could you, please, tell me a solution?

    Thanks in advance.



    • Moved by Ricky_Brundritt Friday, March 9, 2012 4:42 PM (From:Bing Maps: Map Control and Web services Development)
    Wednesday, March 2, 2011 12:05 PM


  • Added this and now it works:

                Dim cred As New System.Net.NetworkCredential("myDomainUser", "myDomainUserPassword", "myDomain")
                Dim prox As New System.Net.WebProxy("myProxy", True)
                prox.Credentials = cred
                WebRequest.DefaultWebProxy = prox

    • Marked as answer by webjagger Wednesday, March 23, 2011 1:28 PM
    Wednesday, March 23, 2011 1:28 PM