locked
Failed to Bing Map Web Services in WCF service hosted on IIS!

    Question

  • I deployed a WCF service which calls Bing Map Web Services to get latitude/longitude by address. The code looks like:

     

                    GeocodeService.GeocodeRequest geocodeRequest = new GeocodeService.GeocodeRequest();

                    // Set the credentials using a valid Bing Maps token

                    geocodeRequest.Credentials = new GeocodeService.Credentials();

                    geocodeRequest.Credentials.Token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

                    geocodeRequest.Address = new GeocodeService.Address();

                    geocodeRequest.Address.Locality = locality;

                    geocodeRequest.Address.AdminDistrict = region;

                    geocodeRequest.Address.CountryRegion = country;

                    //

                    // Set the full address query

                    this.GeocodeServiceClient = new GeocodeService.GeocodeServiceClient(

                        new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc"));

                    GeocodeService.GeocodeResponse geocodeResponse = this. GeocodeServiceClient.Geocode(geocodeRequest);

                    if (geocodeResponse.Results.Length == 0 || geocodeResponse.Results[0].Locations.Length == 0)

                    {

                        geocodeRequest = new GeocodeService.GeocodeRequest();

                        geocodeRequest.Credentials = new GeocodeService.Credentials();

                        geocodeRequest.Credentials.Token = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

                        geocodeRequest.Query = locality + " " + region + ", " + country;

                        geocodeResponse = this.GetGeocodeServiceClient().Geocode(geocodeRequest);

                    }

                    if (geocodeResponse.Results != null && geocodeResponse.Results.Length > 0)

                    {

                        if (geocodeResponse.Results[0].Locations != null && geocodeResponse.Results[0].Locations.Length > 0)

                            return geocodeResponse.Results[0].Locations[0];

                    }

     

    When this WCF service is hosted on a Windows Console application, Bing Map service can be called successfully. But when it is hosted on IIS, this calling always fails.

    The error message is :

    System.ServiceModel.EndpointNotFoundException: There was no endpoint liste

    ning at https://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservic

    e.svc that could accept the message. This is often caused by an incorrect addres

    s or SOAP action. See InnerException, if present, for more details. ---> System.

    Net.WebException: The remote name could not be resolved: 'dev.virtualearth.net'

       at System.Net.HttpWebRequest.GetRequestStream()

       at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre

    am()

       --- End of inner exception stack trace ---

     

    Server stack trace:

       at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre

    am()

       at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)

       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha

    nnelRequest.SendRequest(Message message, TimeSpan timeout)

       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS

    pan timeout)

       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag

    e, TimeSpan timeout)

       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on

    eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim

    eout)

       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall

    Message methodCall, ProxyOperationRuntime operation)

       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

     

    Exception rethrown at [0]:

       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req

    Msg, IMessage retMsg)

       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa

    ta, Int32 type)

       at GeocodeService.IGeocodeService.Geocode(GeocodeRequest request)

       at GeocodeService.GeocodeServiceClient.Geocode(GeocodeRequest request)

       at Service.GetLocation(String country, String region, String locality)

    I don’t think this error is caused by DNS because I can open the page https://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc in IE on the server.

    Could you give technical support to resolve this blocking issue?

     

    Thank you so much!

     

    Friday, May 07, 2010 2:55 AM

Answers

  • There's your issue. Remove the Custom Binding/Endpoint. This causing you to have two endpoints to the same service.
    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Friday, May 07, 2010 12:46 PM

All replies

  • It sounds like you are missing the service reference information in you project app/web config file. Something like the following should be in your config file:

     

    <system.serviceModel>
    	<bindings>
    		<basicHttpBinding>
    			<binding name="BasicHttpBinding_IGeocodeService" maxBufferSize="2147483647"
    				maxReceivedMessageSize="2147483647">
    				<security mode="None">
    					<transport>
    						<extendedProtectionPolicy policyEnforcement="Never" />
    					</transport>
    				</security>
    			</binding>
    		</basicHttpBinding>
    	</bindings>
    	<client>
    		<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
    			binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
    			contract="BingGeocodeService.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
    	</client>
    </system.serviceModel>
    


    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Friday, May 07, 2010 3:34 AM
  • Thank you for quick response.

    But i found the information you mentioned exist in Web.config of WCF service:

          <customBinding>
            <binding name="CustomBinding_IGeocodeService">
              <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                maxSessionSize="2048">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              </binaryMessageEncoding>
              <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                useDefaultWebProxy="true" />
            </binding>
          </customBinding>
        </bindings>
        <client>
          <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
            contract="GeocodeService.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
          <endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
            binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
            contract="GeocodeService.IGeocodeService" name="CustomBinding_IGeocodeService" />
        </client>

    Friday, May 07, 2010 3:53 AM
  • There's your issue. Remove the Custom Binding/Endpoint. This causing you to have two endpoints to the same service.
    Windows Live Developer MVP - http://rbrundritt.spaces.live.com
    Friday, May 07, 2010 12:46 PM