Search code examples
wcfhttpauthenticationwshttpbinding

WSHttpBinding and HTTP and Windows Authentication


I tried to setup WCF service with WSHttpBinding and Windows Authentication and HTTP protocol, not HTTPS. Is it possible? I am using IIS 7. Current my config file is below.

With this config application throws exception:

Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [].

My code is:

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WsBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <services>
      <service behaviorConfiguration="WsBehavior" name="LoginService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsBinding" contract="ILoginService">
          <identity>
            <dns value="http://localhost:50001/Ws/" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="1">
      <baseAddressPrefixFilters>
        <add prefix="http://localhost:50001/Ws/" />
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

    <bindings>
      <wsHttpBinding>
        <binding name="WsBinding" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>

Solution

  • I got next error

    The authentication schemes configured on the host ('IntegratedWindowsAuthentication') do not allow those configured on the binding 'WSHttpBinding' ('Anonymous'). Please ensure that the SecurityMode is set to Transport or TransportCredentialOnly. Additionally, this may be resolved by changing the authentication schemes for this application through the IIS management tool, through the ServiceHost.Authentication.AuthenticationSchemes property, in the application configuration file at the element, by updating the ClientCredentialType property on the binding, or by adjusting the AuthenticationScheme property on the HttpTransportBindingElement.

    So answer on my question. It's impossible.