WCF Over SSL

While this seems like it would be a simple task, there are a few minor things you need to do to get things going.  I will not go into all of the various details, there are plenty of walk throughs out there to do that.  I am going to focus specifically on the web.config settings.  For me this is where my trouble lived.

I created a very simple WCF.  It has the interface named IService and the svc named Service.  It consisted of several methods to add, subtract, and divide.  Like I said, it was very simple.  It ran great on non-SSL, but then I went to SSL and the trouble started.

I received this error message:

Service ‘WCFTest.Service’ has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

The fix was to properly setup the binding and behaviors, and most importantly the service name and contract.  In my non-SSL version I named the service MyService and the contract pointed at IService.  In the end for the SSL one of the things I did was use the namespace and the service name for the service and the interface name for the contract.  I will put the web.config file below so you can take a look.  I will also include some links that helped me find my way.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
      <customErrors mode="Off"></customErrors>
  </system.web>
  <system.serviceModel>
    <services>
        <service name="WCFTest.IService">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="sslBinding" contract="WCFTest.IService" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpsGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
      <bindings>
          <wsHttpBinding>
              <binding name="sslBinding">
                  <security mode="Transport">
                      <transport clientCredentialType="None" />
                  </security>
              </binding>
          </wsHttpBinding>
      </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

My post to ASP.NET Forums
Beginner’s Guide to WCF

Advertisements

About SheldonS

Web developer for over 15 years mainly with Microsoft technologies from classic ASP to .NET 4. Husband, father, and aspiring amateur photographer.

Posted on October 25, 2011, in WCF and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: