Hosting of WCF Service side by side with WCF DataService

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

Sometimes you might host typical WCF service side by side with WCF DataService in one application. As long you use single endpoint based on some security mechanism all will for fine.

For example, assume there is a service MyService which is accessed by MyService.svc and configured like:

  <service name="MyService" >

        <endpoint address="" contract="IMyService" binding="basicHttpBinding" 
                 
bindingConfiguration="BasicHttpBinding_KerberosAuthentication"
/>

     </service>

Assume there is also a WCS DataService accessable by MyDatService.svc. Both service are configured in IIS to use Windows authentication. In this case all will work fine.
Now, you decide to enable additional endpoint for MyService with Basic Authentication to be accessible by for example mobile devices. To do that, you will have to add new endpoint with name “basic” (example)

<service name="MyService" >

      <endpoint address="" contract="IMyService" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_KerberosAuthentication"
/>

      <endpoint address="basic" contract="IMyService" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_BasicAuthentication" 
/>

</service>

Add additionally binding configurations:

  <binding name="BasicHttpBinding_KerberosAuthentication" />

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Windows" />

          </security>

   </binding>

       
  
<
binding name="BasicHttpBinding_BasicAuthentication"
/>

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Basic" />

          </security>

   </binding>

 

After all Enable in IIS Basic Authentication. You will figure out that MyService still works, but MyDataService fails with following exception:

IIS specified authentication schemes 'IntegratedWindowsAuthentication, Basic', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.

To workaround this, append following configuration elements to WCF Data Service:

      <service name="MyDataService" >

        <endpoint address =""

                  binding="webHttpBinding"

                  bindingConfiguration="OData_Binding"

                  contract ="System.Data.Services.IRequestHandler">

        </endpoint>

      </service>

      <webHttpBinding>

        <binding name="BasicHttpBinding_SizedBinding_OData" >

          <security mode="TransportCredentialOnly">

            <transport clientCredentialType="Windows" />

          </security>

        </binding>

      </webHttpBinding>

 


Posted May 10 2011, 03:28 PM by Damir Dobric
Filed under: ,
developers.de is a .Net Community Blog powered by daenet GmbH.