【发布时间】:2011-03-08 11:49:05
【问题描述】:
在升级的项目中,我必须在我的 WCF 服务中使用由第 3 方 (no Control) 发布的 WCF 服务 (Service A)。 我一直在 My Web App 项目 (vs2008) 中使用 ServiceA,它运行良好。
我首先在我的 WCF 项目 (ServiceB) 中添加服务引用。假设服务的名称是“XYZ”。 VS 创建了所有必需的文件,但是当我尝试编译时它给出了错误
类型名称“XYZ”不存在于类型“ServiceB.ServiceB”中;
我的“服务 B”有“ServiceB.SVC”
我试图通过删除命名空间“ServiceB”来克服这个问题。来自 Reference.cs 文件及其内容。然后可以编译此代码。
现在我得到了例外
“调用者未通过服务的身份验证。”
内部异常
由于身份验证失败,无法满足对安全令牌的请求。
在 System.ServiceModel.Security.SecurityUtils.ThrowIfNegotiationFault(消息消息,EndpointAddress 目标) 在 System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(消息incomingMessage, SspiNegotiationTokenProviderState sspiState)
=>
((System.ServiceModel.FaultException)(ex.InnerException)).Message 由于身份验证失败,无法满足对安全令牌的请求。
ServiceB上的Web.Config文件如下:
<wsHttpBinding>
<binding name="WSHttpBinding_IABCService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://aaaaa/ ServiceA.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IABCService"
contract="XYZ.IABCService" name="WSHttpBinding_IABCService">
<identity>
<servicePrincipalName value="host/[hostname]" />
</identity>
</endpoint>
</client>
======
我让自己相信问题可能出在 WCF 访问 WCF 中。我创建了一个 Web 服务 (.asmx) 并添加了对 ServiceA 的引用。当我通过调用该方法进行调试时,我从 ServiceA 获得结果。希望这是一个我可以使用的解决方案,直到我弄清楚 WCF 和 WCF 问题之间,我添加了对我的 WCF 服务(ServiceB)的 asmx 服务的引用。 当我通过运行 ServiceB --> asmx --> Service A 进行调试时,我再次收到 Authentication failed for user error!!!
我认为这与冒充身份有关...
我读到 ServiceB 的 web.config 优先于 asmx web.config,但我无法找到解决方案。
我无法关闭“Security Mode=None”,因为服务 A 回应说没有令牌通过。
任何帮助将不胜感激: 请记住,我可以从 WebApp 和 asmx 使用 WC 服务 A,但不能直接或间接使用另一个 WCF。
谢谢
三月
【问题讨论】:
标签: wcf wcf-security