【发布时间】:2011-09-20 17:15:03
【问题描述】:
再次尝试让我的 WCF 服务在我们的负载平衡环境中工作,我一直充满希望。我已经开始使用<customBinding>,因为recommendation 似乎是设置keepAliveEnabled 指令。
也就是说,我在服务器端设置 Windows 身份验证时遇到问题,因为 <customBinding> 似乎没有以相同的方式运行。
服务器端是这样的:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<customBinding>
<binding name="HttpBinding" closeTimeout="00:00:45">
<textMessageEncoding>
<readerQuotas maxStringContentLength="200000" maxArrayLength="200000" />
</textMessageEncoding>
<httpTransport keepAliveEnabled="false" maxReceivedMessageSize="200000" authenticationScheme="Negotiate"/>
</binding>
</customBinding>
</bindings>
<services>
<endpoint address="http://svcserv/Services/ReportService/Reports.svc" binding="customBinding"
bindingConfiguration="HttpBinding" contract="ReportService.IReports" >
</endpoint>
<endpoint address="mex" binding="customBinding" bindingConfiguration="HttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ReportService.ReportsBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
客户端如下所示:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="CustomBinding_IReports" maxReceivedMessageSize="200000">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="CustomBinding_IReports" address="http://omsnetdev/Services/ReportService/Reports.svc"
binding="basicHttpBinding" bindingConfiguration="CustomBinding_IReports" contract="ReportService.IReports">
<identity>
<servicePrincipalName value="host/svcserv"/>
<dns value="svcserv"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
如果我将 authenticationScheme 设置为“协商”,那么我会收到类似于SOAP header Action was not understood. 或在某一时刻Client found response content type of '', but expected 'application/soap+xml'. 的内容
如果我将 authenticationScheme 更改为“Ntlm”,那么我会收到Exception: The request failed with HTTP status 401: Unauthorized.,但我认为这是由于协商失败(due to the SPN value?),所以它会退回到“Ntlm”并失败。
我会将此作为 IIS 服务器上的配置注销,但我已经验证了这些设置。
【问题讨论】:
-
我修改了标题以使这个问题更具描述性。
标签: .net wcf wcf-security