Silverlight 4 WCF Duplex Service - How to configure for HTTPS

1.4k views Asked by At

How do I configure my Silverlight app and duplex WFC service to use HTTPS? Currently evrything works if using HTTP, but as soon as the client hits the site using HTTPS, the callback creation within the service fails. I believe I need to modify my config file, but I can't figure out what it should be set to.

Here is my current config:

<system.serviceModel>

<extensions>
  <bindingExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,
         System.ServiceModel.PollingDuplex,
         Version=4.0.0.0,
         Culture=neutral,
         PublicKeyToken=31bf3856ad364e35"/>
  </bindingExtensions>
</extensions>

<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />

      <serviceThrottling maxConcurrentSessions="2147483647" maxConcurrentInstances="2147483647" />
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <pollingDuplex>
    <binding name="myPollingDuplex" duplexMode="SingleMessagePerPoll" />        
  </pollingDuplex>
</bindings>

<services>
  <service name="UnityEca.Web.Services.SearchPollingService">
    <endpoint address="" binding="pollingDuplex" bindingConfiguration="myPollingDuplex" contract="UnityEca.Web.Services.SearchPollingService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />

From my Silverlight app, I create the client proxy like so:

SearchPollingServiceClient client = new SearchPollingProxy.SearchPollingServiceClient(
    new PollingDuplexHttpBinding { DuplexMode = PollingDuplexMode.SingleMessagePerPoll },
    new EndpointAddress("../Services/SearchPollingService.svc"));

Thanks...

1

There are 1 answers

3
Ken Smith On

Have you implemented a clientaccesspolicy file for SSL? See here: http://timheuer.com/blog/archive/2008/10/14/calling-secure-services-with-silverlight-2-ssl-https.aspx

You may also need to add a security element to your ServicesReferences.clientconfig file:

<bindings>
  <pollingDuplex>
    <binding name="myPollingDuplex" duplexMode="SingleMessagePerPoll">
        <security mode="Transport" />
    </binding>
  </pollingDuplex>
</bindings>

See this question for more details.