datacontract

.NET - Is there the attribute [DataContract] for a Web Service?

note that I am not using WCF, i'm only using ASP.NET web service. Anything similar? Thank you. ...

Json parsing F#

Hello, #r@"\.NETFramework\v4.0\Profile\Client\System.Runtime.Serialization.dll" open System.Runtime.Serialization open System.Runtime.Serialization.Json [<DataContract>] type geo = { [<field: DataMember(Name = "type")>] t:string [<field: DataMember(Name = "coordinates")>] coordinates:string }...

Can i use datacontracts in WCF for streaming

Hello Experts, Please can i use datacontracts in WCF for streaming instead of message Contract. If yes, will it offer any performance improvement? THanks ...

WCF: Data contract being converted to message contract

My WCF service exports a single operation, marked with the catch-all action and reply action so that it represents a common entry point to the service: [ServiceContract] public interface IService { [OperationContract (Action="*", ReplyAction="*")] Message MyMethod (Message msg); } Client proxies are still generated as data con...

Using WCF DataContract in MVC SessionState using AppFabric cache

Hi, I have a Data Access Layer, a Service Layer, and a Presentation Layer. The Presentation Layer is ASP.NET MVC2 RTM (web), and the Service Layer is WCF (services). It's all .NET 3.5 SP1. The problem is that in the services, the objects being returned are marked with the [DataContract] attribute. The web is using the AppFabric Cache (...

How can I use internal constructors in public data contracts?

I've got several data contract classes like this: [DataContract] public class FooData { [DataMember] public string Name; // ... many more members public FooData (string name) // again, many more arguments { Name = name; // ... } } Since FooData is always used to transport Foo objects over the ...

Entity Framework POCO with WCF software design question

I am going to use Entity Framework and WCF in my application. The suggested practice, as I saw, is using POCO with Entity Framework and also using POCO classes as DataContracts. That is actually what POCO and Attributes are used for, -if I am not wrong. However I am asked to use seperate classses for Entity Framework POCO's and WCF Data...

C# Data Contract deserialisation returning 'null' for collection.

We're using DataContractSerializer to deserialise XML data coming into a RESTful API written in MVC.Net. I'm trying to send a list of objects into an action method, however the deserialisation always returns null, even when using XML serialised from the same classes. Does anyone have any idea's of why this is happening. Code is below. [...

KnownType Serialization Issue

Having read the documentation and many many articles I believe the following should work but it doesn't. This is how my datacontracts are structured. [DataContract] [KnownType(typeof(Friend))] public class Person { private string name; [DataMember] public string Name { get { return name; } set { name = value; }} private P...

Stop DataContractSerializer putting in namespace?

I want to serialize datacontract classes into XMl, but without the Namespaces. I've added: [DataContract(Namespace="")] but I still get: <Person xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt; <Title>Mr</Title> ... </Person> Is there any way to stop this happening as I just want the clean xml to pass into a legacy componen...

WCF DataMember attribute for read-only fields?

I am trying to create a class with a read-only Id field, however I am having problems retaining the value when the object passes through the WCF server. I cannot set the [DataMember] attribute on the public property since there is no set method, and I would like to keep it that way if possible since I do not want this value changed by e...

WCF Client having problems recognizing ServiceKnownTypes?

How would I tell the WCF service what KnownTypes to use when passing data back to the client? I know I can use the [ServiceKnownType] attribute, which makes the service call run fine from a WCF Test Server, however it still fails from the client. Am I missing something here? [OperationContract] [ServiceKnownType(typeof(SubClassA))] [Se...

Data Contract for a class with fields being user defined classes itself

I am Using WCF service to implement my web-service I have problem when I try to call my function which takes URL as input parameter and returns an object class which was defined by me. public class Service: IService<br> { public ClassWS My_Stores(String URL) { try { //ClassWS is a class which has othe...

What is the preferred way to implement serializable classes in C#

I've seen many different ways to serialize objects in C# that I'm not sure which one to use and when. In the current situation I'm serializing for exposure through WCF so I'm guessing the [DataContract] attribute is the way to go. Currently I'm reading in some XML, then exposing the resulting object through WCF. So I am deserializi...

DataContractSerializer not deserializing all variables

I'm trying to deserialize some xml without having the original class that was used to create the object in xml. The class is called ComOpcClientConfiguration. It's succesfully setting the ServerUrl and ServerUrlHda values, but not rest of them... So what I'm asking is: How can I make the rest of these values get set properly, and why are...

In WCF how do you put a datacontract on a class that has already been defined elsewhere?

Hi, So I have some class in a business logic .dll. It is not wrapped in a datacontract, I would like to expose it to anything calling the service by doing so in the Service and IService classes (for example). But the only examples I have seen have been to expose classes that are defined in the service, I do not wish to do this and I do ...

Bad Storage property exception when trying to implement linq-sql in a WCF service

I've been trying to get a WCF service to access a file database that is stored on a local file system to no avail currently. I created a database called data.mdf in visual studio 2010 and ran this sql query on it. create table Person (PersonID int identity (1000,1) not null, Name nvarchar(50) not null, Address nvarchar(max...

Why cant I use lambda when serializing DataContract?

Made som mock code below to illustrate my example. The problem is the lambda expression. If I leave it as in the code example it will not serialize when I try to call the service. However if I type .ToList() after the lambda it serializes as it should. Why is that? I can't see why the code below should not work... Anyone care to enlight...

WCF Service returning 400 error: The body of the message cannot be read because it is empty.

I have a WCF service that is causing a bit of a headache. I have tracing enabled, I have an object with a data contract being built and passed in, but I am seeing this error in the log: <TraceData> <DataItem> <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"...

wcf generic datacontract does not get serialized

I am having the following data structure: [DataContract] public class OperationResult<T> { public OperationResult() { } [DataMember] public Int32 OpResult { get;set; } [DataMember] public IList<T> OperationResults { get;set; } public static OperationResult<T> Success(IList<T>...