WSHttpBinding和HTTP和Windows身份验证

时间:2012-09-26 07:03:09

标签: wcf http authentication wshttpbinding

我尝试使用WSHttpBinding和Windows身份验证和HTTP协议设置WCF服务,而不是HTTPS。可能吗?我正在使用IIS 7.当前我的配置文件在下面。

使用此配置应用程序抛出异常:

  

无法找到与方案http匹配的基地址   绑定WSHttpBinding的端点。注册的基地址方案   是[]。

我的代码是:

<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>

2 个答案:

答案 0 :(得分:1)

我收到了下一个错误

  

主机上配置的身份验证方案   ('IntegratedWindowsAuthentication')不允许配置的那些   绑定'WSHttpBinding'('匿名')。请确保   SecurityMode设置为Transport或TransportCredentialOnly。   此外,这可以通过更改身份验证来解决   通过IIS管理工具,通过这个应用程序的方案   ServiceHost.Authentication.AuthenticationSchemes属性,在   应用程序配置文件在   element,通过更新绑定上的ClientCredentialType属性,   或者通过调整AuthenticationScheme属性   HttpTransportBindingElement。

回答我的问题。这是不可能的。

答案 1 :(得分:0)

您需要在host / baseAddresses配置节点中注册基址。此外,您的DNS身份应该是主机名,而不是端点地址:

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