我们有一个 Web 应用程序,作为“网络服务”在应用程序池中运行。
Web 应用程序连接到另一个 Web 服务器上的服务 (.svc)。另一个 Web 服务器也将服务托管为“网络服务”。我相信这是默认设置。
以下端点,在其他任何地方运行时都可以完美运行。
<endpoint address="http://server123/UnitTrustService/UnitTrustService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_UnitTrustService"
contract="UnitTrustServiceReference.UnitTrustService" name="WSHttpBinding_UnitTrustService">
<identity>
<servicePrincipalName value="server123" />
</identity>
</endpoint>
不幸的是,当从网站执行时,我们收到以下错误。
System.ServiceModel.Security.MessageSecurityException:
The identity check failed for the outgoing message.
The expected identity is 'identity(http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn)'
for the 'http://server123/UnitTrustService/UnitTrustService.svc' target endpoint.
Server stack trace: at System.ServiceModel.Security.IdentityVerifier.EnsureIdentity(EndpointAddress serviceReference, AuthorizationContext authorizationContext, String errorString)...
有任何想法吗?
我已经尝试在具有完全相同配置的 Web 服务器机器上将它作为本地系统运行,并且它运行良好。
和IIS有关系吗?
问候
克雷格。
最佳答案
这可能表明 存在问题客户的网络配置。仔细检查 <identity>
为客户。例如,如果服务期望标识为 userPrincipalName
,则客户端 web.config 中的以下示例代码段可能会导致此异常。而不是 servicePrincipalName
.这是一个很容易错过的区别,我以前也遇到过。
<system.serviceModel>
<client>
<endpoint address="http://server.domain.com/Services/DoSomething.svc" behaviorConfiguration="EndpointBehavior" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDoSomething" contract="Mycontract" name="WSHttpBinding_IDoSomething_Custom_AddSomething">
<identity>
<servicePrincipalName value="user@domain.com" />
关于wcf - 作为网络服务连接到服务的预期身份,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2920882/