The service operation '' that belongs to the contract with the '' name and the 'http://tempuri.org/' namespace does not allow impersonation.

I get the above error when using wcf. 我遇到上面错误在使用wcf服务时。

The solution is as follows:

解决方案在这里:无法从命名空间“http://tempuri.org/”导入绑定“”

报错含义

该错误表示:合同中指定命名空间的服务操作不允许模拟(impersonation),即服务端没有开启"允许模拟调用方身份"。

解决办法

  • 在服务实现方法上添加 [OperationBehavior(Impersonation = ImpersonationOption.Allowed)]。
  • 或在服务行为配置中设置 impersonateCallerForAllOperations 为 true。
  • 也可在配置文件中调整涉及 impersonation 的行为,由客户端自行处理凭据。