Tag: #wcf

如何解决“ChannelDispatcher无法打开其IChannelListener”错误?

我正在尝试在Windows服务中托管的WCF和我的服务GUI之间进行通信。 问题是当我尝试执行OperationContract方法时,我得到了 “’net.tcp:// localhost:7771 / MyService’中的ChannelDispatcher与合同’”IContract“’无法打开其IChannelListener。” 我的app.conf看起来像这样: 端口7771正在侦听(使用netstat检查),svcutil能够为我生成配置。 任何建议,将不胜感激。 从exception堆栈跟踪 Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage […]

inheritanceWCF中的通用契约

更多WCF问题…… 🙂 我的所有工作流程都实现了相同的3种方法。 经过大量的复制和粘贴后,我决定让它们从同一个界面inheritance: [ServiceContract(Namespace = “http://schema.company.com/messages/”)] public interface IBasicContract where TRequest : class where TResponse : class { [OperationContract(Name = “GetReport”, Action = “http://schema.company.com/messages/GetReport”, ReplyAction = “http://schema.company.com/messages/GetReportResponse”)] TResponse GetReport(TRequest inquiry); [OperationContract(Name = “GetRawReport”, Action = “http://schema.company.com/messages/GetRawReport”, ReplyAction = “http://schema.company.com/messages/GetRawReportResponse”)] string GetRawReport(string guid); [OperationContract(Name = “GetArchiveReport”, Action = “http://schema.company.com/messages/GetArchiveReport”, ReplyAction = “http://schema.company.com/messages/GetArchiveReportResponse”)] TResponse GetArchiveReport(string guid); […]

WCF:EncryptedKey子句未包含所需的加密令牌’System.IdentityModel.Tokens.X509SecurityToken’

我正在尝试使用WCF客户端连接到基于Java的Web服务 证书我已经提供(自签名)在SOAPUI中完美地工作。 这是我的设置: 但是,我在使用WCF客户端时遇到问题。 我的app.config 使用Keystore Explorer我从JKS导出两个证书: public_test_hci_cert.cer test_soap_ui.p12 网络服务电话: var client = new Example_TestClient(); client.ClientCredentials.UserName.UserName = “user”; client.ClientCredentials.UserName.Password = “pass”; X509Certificate2 certClient = new X509Certificate2(certClientPath, certClientPassword); client.ClientCredentials.ClientCertificate.Certificate = certClient; X509Certificate2 certService= new X509Certificate2(certServicePath); client.ClientCredentials.ServiceCertificate.DefaultCertificate = certService; var response = client.Example_Test(requestObj); 请求完全到达服务器,但似乎WCF不理解响应,因为我得到此exception: “The EncryptedKey clause was not wrapped with the required encryption token ‘System.IdentityModel.Tokens.X509SecurityToken’.” at […]

例外:为’system.data.sqlclient.sqlconnection’输入初始值设定项?

我无法弄清楚这个例外的问题是什么。 ‘System.Data.SqlClient.SqlConnection’的类型初始值设定项引发了exception 第一次尝试:我正在使用WCF服务来制作一些小应用程序。 它工作正常,我可以正确使用LINQ。 2或3天后。 也许在我关闭Visual Studio并再次加载项目之后。 出现exception。 第二次尝试也一样。 我创建了另一个项目,它工作得很好,直到我做其他事情(我不更改任何代码) SQL Server工作正常,我可以通过SQL Management Studio连接没有问题。 单击Debug error会将我引导至linq文件的连接字符串。 可能是什么问题呢? 我试图搜索但找不到解决这个问题的答案。 谢谢

将JSON日期信息解析为C#DateTime

我有一个返回CLR对象的WCF服务。 该对象定义如下: [DataContract] public class Person { [DataMember] public string FullName { get { return fullName; } set { id = fullName; } } private string fullName = string.Empty; [DataMember] public DateTime BirthDate { get { return birthDate; } set { birthDate = value; } } } 正在创建此对象的实例并从我的WCF服务返回。 此服务如下所示: [OperationContract] [WebGet(UriTemplate = “/GetPersonByID/{id}”, ResponseFormat = […]

如何在类库项目中配置entity framework

我已经创建了一个类库项目,其中包含entity framework对象,该对象将负责我的多个项目的公共数据访问层。在将生成的dll文件添加到我的域项目并使用类库项目中的实体对象之后,我面临着以下问题。 在应用程序配置文件中找不到名为“ABC”的连接字符串。 我已将edmx的Metadata Artifact处理属性设置为Embed in Output Assembly App.Config标记 实体代码如下 public ABC_IntegrationEntities() : base(“name=ABC”) { } 我从datadirectiory“App_Data”访问数据库还有一件事 我正在引用dotnetcurry.com上的博客。 http://www.dotnetcurry.com/showarticle.aspx?ID=617 提前致谢!

如何在WCF服务中使用RequestContext MapPath

这篇MSDN文章说: HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead. 我要做的是从我的IIS托管的WCF服务加载一些XSD文件。 问题是,我无法弄清楚如何在任何旧的vanilla ASP.NET网站中执行Server.MapPath(),例如: HttpContext.Current.Server.MapPath(schemaUri); 在IIS托管的WCF服务中使用RequestContext的等效方法是什么? 模式位于服务应用程序根目录下的“Schemas”目录中。 它们是使用web.config中的自定义配置部分引用的,如下所示: 我试图像这样加载: var schemaUri = HttpContext.Current.Server.MapPath(schema.Uri); 从普通的ASP.NET网站中可以正常工作,而不是IIS托管的WCF服务。

SqlDataReader读入List

我在C#中编写一个方法来从WCF服务查询SQL Server Express数据库。 我必须使用ADO.NET来执行此操作(然后使用LINQ重写它)。 该方法接受两个字符串( fname, lname ),然后从匹配记录中返回“Health Insurance NO”属性。 我想把它读成一个列表(还有其他一些要检索的属性)。 当前代码返回一个空列表。 我哪里错了? public List GetPatientInfo(string fname, string lname) { string connString = “Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\xxxx\\Documents\\Visual Studio 2010\\Projects\\ADOWebApp\\ADOWebApp\\App_Data\\ADODatabase.mdf;Integrated Security=True;User Instance=True”; SqlConnection conn = new SqlConnection(connString); string sqlquery = “SELECT Patient.* FROM Patient WHERE ([First Name] = ‘”+fname+”‘) AND ([Last Name] = ‘”+lname+”‘)”; SqlCommand command = new […]

WCF新手 – 如何安装和使用SSL证书?

对于之前完成它的人来说,这应该是一件轻而易举的事…… 我正在尝试使用NetTcpBinding设置自托管的WCF服务。 我从Thawte那里获得了一个试用版SSL证书,并在我的IIS商店中成功安装了这个证书,我认为我已经在服务中正确设置了它 – 至少我不会例外! 现在,我正在尝试连接客户端(这仍然在我的开发机器上),并且它给了我一个错误,“Message =”X.509证书CN = ssl.mydomain.com,OU =用于测试目的只要。 无保证。,OU = IT,O =我的公司,L =我的城镇,S =无,C = IL链建设失败。 使用的证书具有无法validation的信任链。 替换证书或更改certificateValidationMode。 已处理证书链,但终止于信任提供程序不信任的根证书。“ Ooookeeeey ……现在怎么样? 客户端代码(我想在代码中执行此操作,而不是app.config): var baseAddress = “localhost”; var factory = new DuplexChannelFactory(new InstanceContext(SiteServer.Instance)); factory.Endpoint.Address = new EndpointAddress(“net.tcp://{0}:8000/”.Fmt(baseAddress)); var binding = new NetTcpBinding(SecurityMode.Message); binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; factory.Endpoint.Binding = binding; var u = factory.Credentials.UserName; u.UserName = […]

“无法找到名称为…的端点元素”

很抱歉这个问题很长…我花了两天时间调试并且有很多笔记…… 我有一个WCF数据服务和另一个尝试通过TCP和/或HTTP作为客户端连接到它的进程。 我有一个非常简单的测试客户端应用程序似乎连接正常,但更复杂的生产应用程序无法连接(TCP或HTTP)。 在两个客户端项目中,我让Visual Studio 2008使用“添加服务引用”生成app.config,并让它从数据服务中提取元数据。 以下是适用于简单测试客户端的代码: using Client.MyDataService; namespace Client { class Program { static void Main(string[] args) { MyDataServiceClient client = new MyDataServiceClient(“net.tcp”); client.GetRecords(); } } } 以下是更复杂的生产客户端的代码: DataServiceManager.cs: using MyServer.MyDataService; namespace MyServer.DataServiceBridge { class DataServiceManager { MyDataServiceClient dataServiceClient = new MyDataServiceClient(“net.tcp”); } } 在主要过程中: DataServiceManager d = new DataServiceManager(); 这是简单客户端和生产客户端的app.config文件: 在MyServer的bin \ […]