Question

I would like to consume a 3rd party WCF service using basic authentication, but I also need to use SNI. I've hacked together the following example (minus real endpoint stuff) to show what I've setup and the error I get.

Any help much appreciated as I know little about WCF and nothing about SNI.

Config

<endpoint 
 address="https://their.server.com/theirservice.svc"
 binding="basicHttpBinding"  
  bindingConfiguration="BasicHttpBinding_ISyncFramework2"
  contract="ISyncFramework" name="BasicHttpBinding_ISyncFramework2">
 </endpoint>

       <basicHttpBinding>
         <binding name="BasicHttpBinding_ISyncFramework2" 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="Basic" proxyCredentialType="None"
                 realm="" />
           </security>
         </binding>
       </basicHttpBinding>

code:

            var service = new SyncFrameworkClient();
            service.ClientCredentials.UserName.UserName = "username";
            service.ClientCredentials.UserName.Password = "thepassword";

            service.method() // fails!

the call to method fails with:

The requested service, 'https://their.server.com/theirservice.svc' could not be activated. See the server's diagnostic trace logs for more information.

The server trace

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Was it helpful?

Solution

That error is usually a service-side issue not a client-side problem. SNI is a server technology to improve SSL handshaking and in the Microsoft stack is only supported in the unreleased IIS 8 version. Unless the third-party rolled their own SNI/SSL stack it seems unlikely that their WCF service would require it.

On the actual exception you're getting, it seems that something along the lines of this blog post would likely be the cause of the problem. Your config and code snippets look right for basicHttpBinding using SSL and basic HTTP authentication.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top