2011-07-08 75 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中做过模仿,但我建议您着眼于提供凭据(通过配置文件或编程方式创建代理)。