【问题标题】:WSHttpBinding and HTTP and Windows AuthenticationWSHttpBinding 和 HTTP 和 Windows 身份验证
【发布时间】:2012-09-26 07:03:09
【问题描述】:

我尝试使用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>

【问题讨论】:

    标签: wcf http authentication wshttpbinding


    【解决方案1】:

    我得到了下一个错误

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

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

    【讨论】:

      【解决方案2】:

      您需要在 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> 
      

      【讨论】:

      • 感谢您的回答。它适用于匿名,但不适用于 Windows 身份验证。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-22
      • 2010-09-29
      • 2018-01-02
      • 1970-01-01
      相关资源
      最近更新 更多