Geoffrey Emery
Tech Goodness

Virtual Earth Web Services - Using HTTPS Secure Socket Layer (SSL) Protocol

January 21, 2009 21:45 by gemery
If you want to send and receive Virtual Earth Web Services requests using Secure Socket Layer (SSL), follow the steps below.

Follow this post to get you token

http://blog.geoffreyemery.com/post/Virtual-Earth-Web-Services---Requesting-a-Token.aspx

Follow this post to find web services

http://blog.geoffreyemery.com/post/Virtual-Earth-Web-Services.aspx

 

  1. Generate proxy classes using the staging or production service metadata URLs listed above by adding a service reference using the Visual Studio User Interface or by using the svcutil.exe tool. More information about this is found in the Generating Client Proxy Classes topic.
  2. Edit the service endpoint address URLs found in your configuration file to begin with "https" instead of "http".
  3. If you are using Visual Studio 2008 and the .NET Framework 3.0, you also need to change the BasicHttpSecurityMode to Transport. To do this, either set the mode of the security tag in your Visual Studio 2008 configuration file to Transport, or initialize your service variable with this security mode.

Add this to the config

<!-- Visual Studio 2008 configuration settings for SSL -->
<system.serviceModel>
   <bindings>
      <basicHttpBinding>
         <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"
            useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="Transport">
               <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
               <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
         </binding>
      </basicHttpBinding>
   </bindings>
   <client>
      <endpoint address="https://staging.dev.virtualearth.net/WebServices/v1/ImageryService/ImageryService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IImageryService" contract="IImageryService" name="BasicHttpBinding_IImageryService" />
   </client>
</system.serviceModel>

 

// Instead of setting the security mode in the configuration file, 
//    initialize the service client variable with the Transport
//    security mode.
SearchServiceClient client = new SearchServiceClient(new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress("https://staging.dev.virtualearth.net/webservices/v1/searchservice/searchservice.svc");
 
 
 
 

MSDN Refrence


Related posts

Comments are closed