我正在尝试使用 Windows 身份验证在 IIS 中托管 WCF Web 服务。由于限制,我们必须使用 basicHttpBinding 并使用模拟(模拟调用者的身份以访问链下资源)。
我已在我的 WCF 服务的操作合同上以声明方式启用模拟:
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
我的 web.config 是:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows">
</transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="NotesService">
<endpoint address="http://Client1.osp.local:15000/NotesService/NotesService.svc" bindingConfiguration="basic" binding="basicHttpBinding" contract="NotesService.ServiceContract.INotesService">
<identity>
<servicePrincipalName value="HTTP/Client1.osp.local:15000"/>
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
但是,我收到激活错误。我错过了什么?
我得到的错误是:
The contract operation 'Process' requires Windows identity for automatic
impersonation. A Windows identity that represents the caller is not provided by
binding ('BasicHttpBinding','http://tempuri.org/') for contract
('NotesService','http://tempuri.org/'.