2011-07-08 74 views
0

我有一個WCF服務(MyService.svc),即在IIS 7.5託管。 我的.svc和Web App本身在同一個虛擬目錄下。 我試圖讓我的一些服務操作的需要用戶模擬:在IIS中託管WCF(Impersonation = ImpersonationOption.Required)

[OperationBehavior(Impersonation = ImpersonationOption.Required)] 

我用basicHttpBinding的有:

<security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Ntlm"/> 
</security> 

發佈此之後,我去到http:///爲MyService。 SVC。 這是當我得到以下錯誤:

The contract operation 'HelloWorld' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('BasicHttpBinding','http://tempuri.org/') for contract ('IMyService','http://MyService'. 

*更新/修復* 我發現我的問題。我沒有在web.config中提供服務名稱的命名空間組件。這是讓整個事情變得糟糕。

<services> 
     <service name="**MyNamespace**.MyService" behaviorConfiguration="MyServiceBehavior"> 
     ... 
     </service> 
</services> 

回答

0

根據錯誤消息,聽起來您在創建代理時沒有提供憑據?我還沒有在WCF中做過模仿,但我建議您着眼於提供憑據(通過配置文件或編程方式創建代理)。