【发布时间】:2018-06-05 04:51:34
【问题描述】:
我有一个使用 Microsoft.IdentityModel (WIF 3.5) 的令牌颁发者 WCF 服务,我需要升级到 System.IdentityModel (.NET 4.5)。问题是我无法将服务的原始名称Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract 更改为更新的对应名称System.ServiceModel.Security.WSTrustServiceContract。由于某种原因,它无法被 IntelliSense 识别:
蓝色波浪线错误是:
The 'name' attribute is invalid - The value 'System.ServiceModel.Security.WSTrustServiceContract' is invalid according to its datatype 'serviceNameType'
我在<assemblies> 节点中确实有对System.ServiceModel 和System.IdentityModel 的程序集引用。
即使我忽略 IntelliSense 错误并运行服务并使用浏览器访问它,我也会收到以下元数据错误:
Metadata publishing for this service is currently disabled.
元数据发布已启用,所以我认为这是因为服务的名称问题。
我也从 VS.NET WCF 测试客户端收到此错误:
Error: Cannot obtain Metadata from http://localhost:49178/Services/Issuer.svc
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
URI: http://localhost:49178/Services/Issuer.svc
Metadata contains a reference that cannot be resolved: 'http://localhost:49178/Services/Issuer.svc'.
There was no endpoint listening at http://localhost:49178/Services/Issuer.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
HTTP GET Error
URI: http://localhost:49178/Services/Issuer.svc
The HTML document does not contain Web service discovery information.
我认为“Metadata contains a reference that cannot be resolved”这一行也指的是服务名称解析错误。
关于在这里做什么有什么想法吗?我会很感激任何帮助..
Issuer.svc:
<%@ ServiceHost Language="C#" Debug="true" Factory="Identity.Services.Wcf.Core.CustomSecurityTokenServiceContractFactory" Service="CustomSecurityTokenServiceConfiguration" %>
工厂:
public class CustomSecurityTokenServiceContractFactory : WSTrustServiceHostFactory
..
服务:
public class CustomSecurityTokenServiceConfiguration : SecurityTokenServiceConfiguration
..
【问题讨论】:
-
您是否遵循link的指南
-
@SamuelShyu:是的,我做到了。该文档仅提及命名空间更改,没有提及行为更改。我什至反编译了 Microsoft.Identity.* 和 System.Identity.* 类,它们是相同的。
-
尝试我的答案第 4 点中的建议:单击“高级”并在生成代理时取消选中“在引用的程序集中重用类型”。
-
有这样的参考吗?您是否检查过或自己添加了程序集?可能版本不支持?
-
@ercet00ilk :是的,参考资料在这里并且正在工作。端点合约使用 System.ServiceModel,例如 System.ServiceModel.Security.IWSTrust13SyncContract,它们可以正常解析/工作。