Tag: wcf

为什么DateTime.MinValue不能在UTC之前的时区中序列化?

我遇到了WCF REST服务的问题。 我尝试返回的线对象没有设置某些属性,导致DateTime.MinValuetypes为DateTimetypes的属性。 该服务返回一个空文档(HTTP状态200 ???)。 当我尝试自己调用JSON序列化时,引发的exception是: SerializationException:在转换为UTC时,大于DateTime.MaxValue或小于DateTime.MinValue的DateTime值无法序列化为JSON。 这可以通过在控制台应用程序中运行以下代码来进行重现: DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(DateTime)); MemoryStream m = new MemoryStream(); DateTime dt = DateTime.MinValue; // throws SerializationException in my timezone ser.WriteObject(m, dt); string json = Encoding.ASCII.GetString(m.GetBuffer()); Console.WriteLine(json); 这是为什么? 我认为这与我的时区(GMT + 1)有关。 由于DateTime.MinValue是默认的(DateTime),我希望这可以序列化没有问题。 有关如何使我的REST服务的行为的任何提示? 我不想改变我的DataContract。

传入消息的最大消息大小限额(65536)已被超出

在创buildless量表的范围时,我得到这个exception,所有这些表都是巨大的devise <bindings> <wsHttpBinding> <binding name="wsHttpBinding_ISyncServices" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""> <extendedProtectionPolicy policyEnforcement="Never" /> </transport> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> </bindings> 我已经将MaxReceivedMessageSize为2147483647,但是在这条线上还是给出了一个例外 client.GetTableDescription(scopeName, syncTable) 传入消息的最大消息大小限额(65536)已被超出。 要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性。

与WCF服务共享枚举

我有几个不同的应用程序,我想分享一个C#枚举。 我不能完全弄清楚如何共享常规应用程序和WCF服务之间的枚举声明。 这是情况。 我有2个轻量级的C#destop应用程序和一个WCF Web服务,都需要共享枚举值。 客户1有 Method1( MyEnum e, string sUserId ); 客户端2有 Method2( MyEnum e, string sUserId ); Webservice有 ServiceMethod1( MyEnum e, string sUserId, string sSomeData); 我最初的目的是创build一个名为Common.dll的库来封装枚举,然后在需要枚举的所有项目中引用该库。 但是,WCF使事情变得困难,因为您需要将枚举标记为服务的组成部分。 喜欢这个: [ServiceContract] [ServiceKnownType(typeof(MyEnum))] public interface IMyService { [OperationContract] ServiceMethod1( MyEnum e, string sUserId, string sSomeData); } [DataContract] public enum MyEnum{ [EnumMember] red, [EnumMember] green, [EnumMember] blue […]

如何在WCF Test Client(WcfTestClient.exe)中指定列表参数?

我正在使用WCFtesting客户端(WcfTestClient.exe)来testing我的一个wcf服务。 我有一个消息合约,它有一个DataContracts列表为:我的消息合约如下所示: [MessageContract] public class UpdateInvoiceStatusesRequest { private List<InvoiceStatusHistory> _invoiceStatusHistory; [MessageBodyMember(Order = 0)] public List<InvoiceStatusHistory> InvoiceStatusHistory { get { return _invoiceStatusHistory; } set { _invoiceStatusHistory = value; } } } 和我的数据合同是: [DataContract] public class InvoiceStatusHistory { private int _invoiceId; private int _status; private string _comment; private string _timeStamp; [DataMember] public int InvoiceId { get { […]

“这个错误的创造者没有指定一个理由”exception

我有WCF服务中的以下代码基于某些情况抛出自定义错误。 我得到一个“这个错误的创造者没有指定一个原因”的例外。 我究竟做错了什么? //source code if(!DidItPass) { InvalidRoutingCodeFault fault = new InvalidRoutingCodeFault("Invalid Routing Code – No Approval Started"); throw new FaultException<InvalidRoutingCodeFault>(fault); } //operation contract [OperationContract] [FaultContract(typeof(InvalidRoutingCodeFault))] bool MyMethod(); //data contract [DataContract(Namespace="http://myuri.org/Simple")] public class InvalidRoutingCodeFault { private string m_ErrorMessage = string.Empty; public InvalidRoutingCodeFault(string message) { this.m_ErrorMessage = message; } [DataMember] public string ErrorMessage { get { […]

WCF Web服务错误:服务无法激活,因为它不支持ASP.NET兼容性

我正在尝试创build一个平静的wcf web服务。 当我尝试通过客户端连接到服务时,出现以下错误: 该服务无法激活,因为它不支持ASP.NET兼容性。 此应用程序启用了ASP.NET兼容性。 closuresweb.config中的ASP.NET兼容模式,或将AspNetCompatibilityRequirements属性添加到R​​equirementsMode设置为“允许”或“必需”的服务types。 其他人有问题,但他们修改了他们的web.config。 我已经实施了他们的修复程序,但问题仍然存在。 这里是我的web.config: <system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="WebBehavior" > <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="MyServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="MyServiceBehavior" name="myfirstwcf"> <endpoint address="ws" binding="basicHttpBinding" contract="Imyfirstwcf" /> <endpoint address="ws2" binding="wsHttpBinding" contract="Imyfirstwcf" /> <endpoint […]

WCF中的DataContract有什么意义?

当你创build一个WCF项目时,VS.net创build一个模板。 它将一个类添加到iService1.cs文件中: // Use a data contract as illustrated in the sample below to // add composite types to service operations. [DataContract] public class CompositeType { bool boolValue = true; string stringValue = "Hello "; [DataMember] public bool BoolValue { get { return boolValue; } set { boolValue = value; } } [DataMember] public string […]

什么是WCF中的“端点”?

我的印象是,一个端点被定义在一个configuration文件中作为可能的客户端列表,但这没有任何意义(我认为它说什么电脑可以连接到该服务)现在我收集,它是更多的一个定义,那么请有人解释一下我的终点是什么? 我理解定义契约接口的概念,然后执行契约,但我迷失在那里,实际上有一些可用的东西。 什么是这方面的地址? 主机地址? 绑定是通信方法/协议使用正确吗? 合同本质上是“共享的对象”(是的,我知道这在技术上是不正确的,但在这里与我一起工作)

是否可以在不使用SDK的情况下调用Dynamics CRM 2011的后期绑定WCF组织服务 – 直接定制绑定?

我试图实现一个纯粹的WCF场景,我想调用Dynamics CRM WCF服务,而不依赖于SDK辅助类。 基本上,我想通过.net框架仅使用本机WCF支持,针对Dynamics CRM 2011实施联合身份validation。 我这样做的原因是我想稍后移植到BizTalk。 我已经使用SvcUtil成功生成了代理类,但策略和安全声明的一部分与configuration模式不兼容。 SvcUtilbuild议用代码来build立绑定,这就是我正在做的。 结果代码在这里: private static void CallWcf() { OrganizationServiceClient client = null; try { // Login Live.com Issuer Binding var wsHttpBinding = new WSHttpBinding(); wsHttpBinding.Security = new WSHttpSecurity(); wsHttpBinding.Security.Mode = SecurityMode.Transport; // Endpoint Binding Elements var securityElement = new TransportSecurityBindingElement(); securityElement.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDes; securityElement.IncludeTimestamp = true; securityElement.KeyEntropyMode = […]

WCF合同名称'IMyService'找不到?

无法在服务“MyService”实现的合同列表中find合同名称“IMyService”。—> System.InvalidOperationException:无法在实施的合同列表中find合同名称“IMyService”服务“我的服务”。 这真让我抓狂。 我有一个在我的开发机器上工作的WCF Web服务,但是当我将它复制到我用于testing的虚拟机时,出现错误,似乎表明我没有实现该接口,但它不能使感觉,因为该服务在我的Windows XP的IIS上工作。 虚拟机使用Windows Server 2003 IIS。 有任何想法吗? 有一点需要注意的是,即使只是试图在Web浏览器中作为客户端访问服务,我也会在虚拟机上发生这个错误。 注意:我正在使用principalPermissionMode =“UseWindowsGroups”,但是这不是我的本地机器上的问题。 我只是把自己添加到适当的Windows组。 但是我的虚拟机没有运气。 configuration: <configuration> <system.serviceModel> <diagnostics> <messageLogging logEntireMessage="false" maxSizeOfMessageToLog="2147483647" /> </diagnostics> <services> <service behaviorConfiguration="MyServiceBehaviors" name="MyService"> <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" name="MyService" bindingName="basicHttpBinding" bindingNamespace="http://my.test.com" contract="IMyService"> </endpoint> </service> </services> <bindings> <basicHttpBinding> <binding name="basicHttpBinding" maxReceivedMessageSize="2147483647"> <readerQuotas maxStringContentLength="2147483647" /> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" proxyCredentialType="None" /> </security> </binding> […]