2010-03-30 48 views
7

當我部署了我WCF數據服務到生產託管,我開始得到以下錯誤(或類似的,這取決於身份驗證方案是主動):如何禁用身份驗證方案爲WCF數據服務

IIS指定的認證方案 '基本,匿名',但綁定 僅支持一個驗證方案的確切規格 。有效的 認證方案是摘要, 協商,NTLM,基本或匿名。 更改IIS設置,以便僅使用一個 單身份驗證方案。

顯然WCF數據服務(一般WCF?)不能處理有多個身份驗證方案處於活動狀態。

好吧,所以我知道,我可以通過IIS控制面板...通過支持請求禁用Web應用程序的所有的一個身份驗證方案!

有沒有在web.config中的每個服務級別上指定單一認證方案的方法?

我想這可能是直線前進的作出改變,以<system.serviceModel>但是......事實證明,WCF數據服務不會在web配置自我配置。如果您查看DataService<>類,則它不會實現[ServiceContract],因此您不能在<service><endpoint>中引用它,我認爲這將通過XML更改其配置。

P.S.我們的主機使用II6,但IIS6 & IIS7解決方案讚賞。

回答

16

首先,可以在Web配置文件中配置Data Services。 DataService使用的協定稱爲System.Data.Services.IRequestHandler。

以下是您可以在Web配置文件中進行配置的內容。

在system.servicemodel元素的服務標籤添加

<service name="{you service type name including the namespace i.e. myapplication.myservice}"> 
    <endpoint address="" binding="webHttpBinding" contract="System.Data.Services.IRequestHandler"> 
    </endpoint> 
</service> 

一旦你有,你可以開始配置使用標準WCF配置元素的東西都舉止。

其次啓用或IIS中的特定服務,你可以做以下的殘疾人身份驗證方法:

在在IIS右鍵點擊你的服務文件的快照(即yourservice.svc),然後單擊屬性。 一旦進入屬性,進入文件安全性選項卡並選擇身份驗證和訪問控制組框中的編輯按鈕。之後,就像在IIS中設置目錄安全一樣。

作爲任何問題解決的最後一個建議,啓用wcf disgnostics是很重要的,同時使用xml配置配置它,使用WCF編寫,數據服務日誌記錄根據wcf是豐富且非常豐富的。

你可以找到更多關於在WCF Administration and Diagnostics

我希望我能夠幫助你解決問題

讓我知道事情如何去。

問候

丹尼爾Portella

UPDATE:

嗨施耐德

指定閱讀下面

對於Windows身份驗證的例子在XML認證方案

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <webHttpBinding> 
     <binding name="MyBindingName" > 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service name="{you service type name including the namespace i.e. myapplication.myservice}"> 
     <endpoint address="" binding="webHttpBinding" bindingConfiguration="MyBindingName" contract="System.Data.Services.IRequestHandler"> 
     </endpoint> 
     </service> 
    </services> 
    </system.serviceModel> 
</configuration> 

對於其他類型的身份驗證,請檢查MSDN庫實例

Common Scenarios for security

+0

感謝。端點配置很有用。現在我有,我會尋找一種方法來指定身份驗證方案在XML ... – Schneider 2010-03-30 13:25:21

+0

添加更新以上希望ti解釋如何設置服務的身份驗證 – dmportella 2010-03-31 11:46:55

+0

如果我能我會給你賞金..!謝謝你太多了! – Rashack 2013-03-15 07:11:31