- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个使用 Microsoft.IdentityModel (WIF 3.5) 的 token 发行者 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'
我确实有对 System.ServiceModel
的程序集引用和 System.IdentityModel
在 <assemblies>
节点。
即使我忽略 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
..
最佳答案
有时解决此类问题的最佳方法是从头开始创建一个新的 WCF 项目,重新配置您的端点等。并从旧项目复制现有服务,尤其是从旧项目迁移时WCF 版本。
这是我每次遇到 WCF 服务问题时都会遵循的 list :
服务器
确保您的服务契约(Contract)是使用具有适当属性的接口(interface)定义的,例如:
IMyService.cs
[ServiceContract]
public interface IMyService
{
[OperationContract]
int ThisAnOperation(int a, int b);
}
检查您是否使用正确的界面实现了契约(Contract):
MyService.cs
public class MyService: IMyService
{
public int ThisAnOperation(int a, int b)
{
return a * b;
}
}
你需要有一个服务主机来访问你的服务,它们是扩展名为.svc的文件:
添加以下代码行,引用实现您的服务的类:
<%@ ServiceHost Language="C#" Debug="true" Service="YourNamespace.MyService" CodeBehind="MyService.cs" %>
最后,您需要设置一个绑定(bind),定义哪些传输和协议(protocol)可用于访问您的服务器,从一个简单的基本 HTTP 绑定(bind)开始,以检查您的服务是否按预期工作,然后将其更改为更多产品准备就绪,包括根据需要进行身份验证和/或加密和压缩。
设置基本的 HTTP 绑定(bind):
删除 block <system.serviceModel>...</system.serviceModel>
从你的文件 web.config 如果它已经存在。
构建您的解决方案,它应该编译成功,否则修复任何错误并重试。
右键单击您的 web.config 文件,然后单击“编辑 WCF 配置”,然后单击“创建新服务”,在“服务类型”中,浏览并选择编译服务时生成的 DLL 文件(应该在 bin 文件夹中)并选择您要发布的服务类:
指定服务契约(Contract)(应自动填写)。
在下一页中,为您的服务选择传输协议(protocol),在本例中为“HTTP”,然后选择“基本 Web 服务互操作性”。
在下一页中,您可以指定端点的地址,出于测试目的,您可以将此字段留空(确保还从文本字段中删除“HTTP”)。
<点击下一步,关闭配置窗口并保存。
现在您应该能够运行该服务并浏览到 MyService.svc 以访问您的服务。
激活元数据发布以便可以找到您的服务,为此,将以下行为添加到您的 web.config 中:
<system.serviceModel>
<services>
<service name="WcfService1.MyService">
<endpoint binding="basicHttpBinding"
bindingConfiguration="" contract="WcfService1.IMyService"
BehaviorConfiguration="MyServiceBehaviors" />
</service>
</services>
</system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
现在您应该能够运行您的项目并在浏览器中获取服务的元数据描述页面,客户端可以使用此信息来查找服务并生成服务代理:
客户
尝试通过完成向导生成代理,重建您的项目并尝试。如果您仍然遇到同样的问题,请删除生成的引用并重复第 1 点和第 2 点,然后:
单击“高级”并取消选中“在引用的程序集中重用类型”:
然后完成向导并编译。
希望现在一切正常!!!
关于c# - 无法解析/使用 System.ServiceModel.Security.WSTrustServiceContract 作为服务名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47943115/
我正在 IIS 中运行我的 Web 项目。 这是一个4.0框架的APP。 我有一个 Service.svc,当我运行我的应用程序时收到此错误。 "Could not load type 'System
有一段时间,我在尝试使用 Azure 模拟器启动任何类型的应用程序时遇到以下错误: Microsoft Azure Tools: Method not found: 'Void Microsoft.W
我有一个由针对 .NET Standard 2.0 和 .NET Core 2.1.304 的项目组成的解决方案。在构建此解决方案时,它利用了旧的易受攻击版本的 System.ServiceModel
现象: 最近遇到了WCF 服务无法调用的错误,异常如下。 System.ServiceModel.ProtocolException, System.ServiceModel, Version=4
我在可移植类库中有一个接口(interface),启用了构建时的代码分析。当我用 WCF 服务的 ServceContract 和 OperationContract 标记它时,它开始从代码分析中抛出
我正在 sharepoint 上部署 webpart 并遇到一些错误。 webpart 使用来自 Web 服务的数据并使用 Microsoft Chart (Framework 3.5) 显示图表。当
我正在学习 WCF 并找到了 this article在一个简单的 WCF 示例中。 在下面的代码中(来自上面的文章),为什么System.ServiceModel.Dispatcher.Channe
我们有一个启动WCF服务器的应用程序,该应用程序从中读取数据。 它会启动,并且可以在所有Windows XP计算机上正常阅读。 但是,在Vista机器上,我们得到: System.ServiceMod
如果此问题在 stackOverflow 上出现两次,我们深表歉意 我试图在 Windows Server 2003 机器上运行 wcf 服务。我收到了 System.ServiceModel.Add
您好,当应用程序托管在服务器中时,我遇到了以下错误。该应用程序在本地盒子上运行良好。“已超过传入消息的最大消息大小配额 (100000000)。要增加配额,请在适当的绑定(bind)元素上使用 Max
我在 Win7(64 位)上使用 VS2010 express,我正在尝试使用 System.ServiceModel 但我收到一个错误,指出没有 ServiceModel System 命名空间:
我想在我的 Unity 应用程序中使用 WCF 服务(通过命名管道)。因此,我包括以下两个命名空间: using System.ServiceModel; using System.ServiceMo
我有以下代码: public partial class MyServiceClient : System.ServiceModel.ClientBase 派生,请使用此选项 m_MyClient.S
如何在我的应用程序中调试 system.servicemodel 类? 最佳答案 听起来您对调试 .NET 框架代码本身感兴趣吗?如果是这样,微软已经向公众发布了大部分 .NET 框架的源代码。 但是
我发现的所有与智能感知相关的问题似乎都与自定义配置设置有关。我正在尝试在已从 web.config 移出到 service.config 的 .net 标准部分上获得智能感知。 有办法吗? 最佳答案
我在客户端应用程序上遇到了这个异常,不知道如何解决这个问题。 当返回的数据(价格列表)超过 15MB,但适用于小于 15MB 的消息时,我遇到了这个异常。 错误消息: 接收对“http://local
我创建了一个 Core 3.1 应用程序,该应用程序使用基于 .net 标准 2.0 的 Web 服务。 在本地开发环境中,一切正常。在我将其部署到 UAT (IIS) 上之前,我收到以下异常: Ex
我添加了一个名为 http://192.168.5.180:8080/intg/CrmWebService.asmx 的服务引用。名称为 CrmWebProxy。 下面是代码行。 Microsoft.
当我将网站发布到我的 plesk 服务器时,我收到以下错误: Unrecognized configuration section system.serviceModel. 最佳答案 您的主机支持哪个
有什么方法可以访问“System.ServiceModel”客户端配置,即基于类 (dll) 项目中的 app.config? 最佳答案 ConfigurationManager.GetSection
我是一名优秀的程序员,十分优秀!