這裏是我試圖處理情況:如何WCF服務重定向到HTTPS端點與Windows憑據
我們有一個WCF客戶端與HTTP端點工作和HTTPS端點而不是在它從http重定向(302)到https。我們有一個正在執行重定向和SSL功能的F5負載均衡器,但據我所知,它並沒有對請求產生任何意想不到的結果。重定向似乎是WCF在重定向執行後不想提供Windows Kerberos身份驗證信息的罪魁禍首。
一個成功的調用(即HTTP無重定向)的順序是這樣的:
- 客戶端 - 發送POST請求的服務以http方式
- 服務器 - 與401未經授權
- 客戶端響應 - 發送具有授權的協商POST
- 服務器 - 以100繼續響應
- 客戶端 - 發送肥皂數據併成功完成
當呼叫重定向和失敗,它是這樣的:
- 客戶端 - 發送POST請求的服務以http方式
- 服務器 - 具有重定向返回302到https方案爲同一地址
- 客戶端 - 發送GET爲HTTPS地址(我想不通爲什麼這是一個GET而不是POST)
- 服務器 - 與401未經授權 迴應0
- 客戶端 - 拋出異常「HTTP請求未經客戶端身份驗證方案」協商「授權。從服務器接收認證報頭是「協商,NTLM」。」
它類似於this problem但不完全相同(並沒有一個真正的答案了,雖然它引用‘破WCF協議’如果我們關閉F5重定向規則http和https通信工作正常WCF是否真的不處理這個簡單的重定向?是否有解決方法或任何文檔在這個缺陷?
客戶端配置請注意,當使用https測試時,我將TransportCredentialOnly更改爲傳輸):
<client>
<endpoint address="http://fooserver/MyService.svc/" binding="basicHttpBinding" bindingConfiguration="clientBinding" contract="Contracts.IMyService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="clientBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
服務器的配置是這樣的:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="securedBinding" contract="Contracts.IMyService">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="securedBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="80" />
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
的可能的複製[爲什麼會失敗WCF調用遇到302響應時,SOAP服務?(http://stackoverflow.com/questions/17152385/why-would-wcf-fail-to-call-a -so--302-response-is-encounter) – Luizgrs 2015-10-08 20:12:04