known-types

Problem with knowntype attribute in wcf

喜夏-厌秋 提交于 2019-12-30 18:50:10
问题 I'm having the following error in my wcf client. NetDispatcherFaultException was unhandled. The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetVehicleResult. The InnerException message was 'Error in line 1 position 266. Element 'http://tempuri.org/:GetVehicleResult' contains data from a type that maps to the name 'http://schemas.datacontract.org/2004/07/WCFServer:Car'. The deserializer has

WCF contracts - namespaces and SerializationExceptions

六眼飞鱼酱① 提交于 2019-12-24 09:50:57
问题 I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrote [ServiceContract] [XmlSerializerFormat] public interface IFooBarService { [OperationContract] [WebGet( BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat =

DataContractSerializer, KnownType and inheritance

一世执手 提交于 2019-12-21 01:57:10
问题 I've read many articles about known types and i belive my example should work. But it doesn't. I'm getting the following exception on deserialization and don't understand why: Error in line 1 position 2. Expecting element 'A' from namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'.. Encountered 'Element' with name 'C', namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'. using System; using System.Runtime.Serialization; using System.Xml; using System

Using Interfaces With WCF

 ̄綄美尐妖づ 提交于 2019-12-20 02:41:29
问题 I have Googled and read for hours now and I can't find anyone that deals with my specific scenario... I want to use interfaces in my WCF service contracts to loosely couple the service from the classes used on each end of the wire. This will enable us to have a low-level assembly that contains just the Service and Data Contracts (just interfaces) that we can hand to a consultant. On their end of the wire they can instantiate their data classes that implement our Data Contract interface, send

Generally accepted way to avoid KnownType attribute for every derived class

 ̄綄美尐妖づ 提交于 2019-12-17 23:34:09
问题 Is there a generally accepted way to avoid having to use KnownType attributes on WCF services? I've been doing some research, and it looks like there are two options: Data contract resolver NetDataContractSerializer I'm not a big fan of having to statically add KnownType attributes every time I add a new type, hence wanting to avoid it. Is there a third option that should be used? If so, what is it? If not, which of the above two options are the right way to go? Edit - use a method A third

How do you configure WCF known types programmatically?

大兔子大兔子 提交于 2019-12-17 04:18:57
问题 My client/server application is using WCF for communication, which has been great. However one shortcoming of the current architecture is that I must use known type configuration for certain transmitted types. I'm using an in-house Pub/Sub mechanism and this requirement is unavoidable. The problem is that it's easy to forget to add the known type, and if you do, WCF fails silently with few clues as to what's going wrong. In my application, I know the set of types that are going to be sent. I

How do you configure WCF known types programmatically?

痴心易碎 提交于 2019-12-17 04:18:13
问题 My client/server application is using WCF for communication, which has been great. However one shortcoming of the current architecture is that I must use known type configuration for certain transmitted types. I'm using an in-house Pub/Sub mechanism and this requirement is unavoidable. The problem is that it's easy to forget to add the known type, and if you do, WCF fails silently with few clues as to what's going wrong. In my application, I know the set of types that are going to be sent. I

WCF - Object as known type -> interoperable?

£可爱£侵袭症+ 提交于 2019-12-12 12:27:49
问题 Actually there should be a straight forward answer to this question (is about the "Object" property below): Having the following data contract: [KnownType(typeof(bool))] [KnownType(typeof(int))] [KnownType(typeof(string))] [KnownType(typeof(Customer))] [KnownType(typeof(Client))] public class Transaction { // properties [DataMember(Name = "UID")] public int UID{} [DataMember(Name = "Type")] public Enums.TransactionType Type{} [DataMember(Name = "Data")] public Object Data{} } and the

How to add service known types from external config file

吃可爱长大的小学妹 提交于 2019-12-10 18:53:20
问题 I am having difficulty understanding how to exactly go about adding known types; for WCF, from a configuration file that is external to my wcf. I found an example of how to set the configuration file up, however, I am a bit confused as to the way the file is set up and I am not sure as to how I am actually supposed to call this configuration file to load the service known types to my wcf. Here is the example of the configuration file containing the known types. http://codeidol.com/csharp/wcf

Two Interface and one concrete class in WCF

自古美人都是妖i 提交于 2019-12-07 04:32:26
问题 please check the below example namespace GServices { [ServiceKnownType(typeof(SearchType))] [ServiceContract(SessionMode = SessionMode.Allowed)] public interface ITest { [OperationContract] int subtract(int x, int y); } [ServiceKnownType(typeof(SearchType))] [ServiceContract(SessionMode = SessionMode.Allowed)] public interface ITest2 { [OperationContract] int add(int x, int y); } public class G : ITest2, ITest { public int add(int x, int y) { return x + y; } public int subtract(int x, int y)