datacontract

WCF Data Contract and Reference Entity Data?

Hello, Soliciting feedback/options/comments regarding a "best" pattern to use for reference data in my services. What do I mean by reference data? Let's use Northwind as an example. An Order is related to a Customer in the database. When I implement my Orders Service, in some cases I'll want the reference a "full" Customer from an O...

Supporting DataContracts in .Net 2.0 libraries

Is it possible to create a library that can be consumed from .Net 2.0 and also allows .Net 3.0+ consumers to benefit from DataContracts if they wish? I don't see any technical obstacle for this other than the library that contains the different DataContract related attributes is a .Net 3.0 library. Can these attributes be implemented ma...

WCF DataContract Upcasting

I'm trying to take a datacontract object that I received on the server, do some manipulation on it and then return an upcasted version of it however it doesn't seem to be working. I can get it to work by using the KnownType or ServiceKnownType attributes, but I don't want to roundtrip all of the data. Below is an example: [DataContrac...

IsReference property in data contract

What is the purpose of IsReference property in Data contract. How the request and response vary with these property./ ...

What is data contract (property class) and observable collection

What is data contract (property class) and observable collection when, where and why to use these in context to silverlight please do explain in Details with Examples ++ Thanks and Regards Meetu Choudhary ...

How can we use a DataMember of a DataContract in silverlight

I am creating an application in which i made a WCF service and now a DataContract Class which have some DataMebers in the ServiceContract I am using that DataContract Class No I am able to access the operationContracts but now I want to access the DataMember of the DataContract Class in the silverligh XAML.CS page Please Suggest How ...

Persist a DataContract as XML in a database

I'm working on a kind of "store and forward" application for WCF services. I want to save the message in a database as a raw XML blob, as XElement. I'm having a bit of trouble converting the datacontract into the XElement type I need for the database call. Any ideas? ...

Custom datacontract / datamember name

Hello, I have a following problem. A customer requested a web service that returns data in following format: <status> <name1>Some name</name1> ... </status> But when an error occurs they want to get a following message: <status> <error>Error description</error> </status> I created a web service using WCF and in order to fulfill ...

Should WCF DataContracts be value or reference types?

You're at the service's end of the wire and you don't know your clients. Why would you choose one over the other? ...

DataContracts with behavior.

How bad is it? I have read countless articles and never created abstract DataContracts with behavior before, but it seems that doing so will solve an issue I am having that will prevent me from creating factories everywhere to determine a subclass implementation. My question is, will I be punished if I decide to add behavior to my data c...

WCF, Entity Framework & Data Contracts

Using VS 2008 & .NET 3.5 SP1: I am using WCF to allow clients to connect to a service that reads and writes database entries using Entity Framework. By default the entities that are generated automatically from the database have the DataContract attribute applied. Unfortunately many of the fields are exposed are not meant for consumpt...

WCF DataContract class with methods

This is more of a philosophical/best-practice sort of question rather than a technical problem. Are there any strong arguments against writing a DataContract class with methods that are to be used server-side only? Or what about additional properties that are not decorated with the DataMember attribute? For example: [DataContract] pub...

WCF DataContractSerializer doesn't pick up contract attributes... why not?

I have the following type which I use as a message contract in WCF: [MessageContract(IsWrapped = true, WrapperNamespace = "http://example.com/services", WrapperName = "EchoRequest")] public class EchoRequest { public EchoRequest() { } public EchoRequest(String value) { Value = valu...

Passing Attributes on DataContracts in WCF

Hello, I have a a datacontract which has important attributes on. For example, in the following code: [DataMember] [Description("My Description")] public string Name { get; set; } I want the Description attribute to be auto generated on the client proxy. Is there any solution, or workarounds besides massive duplication? Many thanks...

WCF DataContract ToString function

Can you override the ToString function in a WCF DataContrat? Right now I have: [DataContract] public class Keyword { public int ID { get; set; } public string Name { get; set; } public override string ToString() { return Name; } } But it doesn't seem to work. Anyway to get this working? ...

Inconsistent DataContractAttribute behavior

based on my understanding WCF's data contract model was opt-in vs the old opt-out approach of asmx web-services. you have to explicitly include all the fields and types that you require using DataContractAttribute and DataMemberAttribute. my experience however has been different. take a look at the following examples, ///CASE: 1 ///B...

Service Generated from WSDL Returns Different WSDL

I have generated a WCF service interface from a delivered WSDL schema, this interface have then been implemented in one of my WCF services without any problems. [ServiceBehavior(Name = "HL7Service", Namespace = "urn:hl7-org:v3")] [ServiceContract(Namespace = "urn:hl7-org:v3", Name = "HL7Service", SessionMode = SessionMode.Allowed)] publ...

DataContractSerializer outputting XML with "field" appended to all elements and out of order

I'm new to creating WCF REST services - so please let me kwow if I'm doing things wrong here. I have a REST-based service developed using WCF, with the following DataContract defined: namespace Messaging { [DataContract(Name = "Email", Namespace = "")] public class Email { #region Fields private string s...

WCF Problem Serializing a Message Header

Hi guys I have the following code: public virtual void Initialise() { this.AddHeader("SystemContext", this.UserSettings.SystemContext); } public virtual void AddHeader(string key, object value) { var customHeader = MessageHeader.CreateHeader(key, this.SystemSettings.SystemServiceNamespace, value); OperationContext.Current...

Should i decorate my classes/properties as DataContract/DataMember when i use them in WCF?

I have a framework with objects and data access code. This objects are mapped to the database using NHibernate. For example my framework has class Customer and Order: public class Customer { private Guid _id; private string _name; private IList<Order> _orders; public properties... } public class Order { ...