datacontract

WCF DataContracts

I have a WCF service hosted for internal clients - we have control of all the clients. We will therefore be using a data contracts library to negate the need for proxy generation. I would like to use some readonly properties and have some datacontracts without default constructors. Thanks for your help... ...

.NET base type cannot be serialized by WCF

I'm writing a WCF service and want to expose some custom configuration elements (e.g. Custom ConfigurationSection and ConnectionStringSettings) so that I can modify the service's configuration. One of my custom configuration elements inherits from System.Configuration.ConfigurationElementCollection. When I try to start my WCF service I g...

Creating WCF messages with mutiple namespaces.

I'm trying to create a WSTransfer implementation (I realise Roman Kiss has written one already for WCF - but it doesn't actually meet the specifications) I've ended up abandoning data contracts on the service contacts because WSTransfer is loosely coupled; so each the create message looks like Message Create(Message request). This work...

WCF DataContract/ServiceOperation involving .NET XmlDocument type

hi all, im just wondering about data contracts to be sent over the wire in WCF communication. i know for the sake of interoperability it is not advisable (maybe not even allowed?) to send native .NET types as part of a data contract. I wish to have a service which accepts, as an input to a ServiceOperation, a .NET XmlDocument type. If ...

wcf service to service communication & data contract

hi all! i have recently been involved in developing a WCF service which acts as a kind of multicast relay (i.e. accepts some incoming data, does some processing and then sends it off to multiple other external services). this service (which i will refer to as "my service") is fed data by a second internal service. this data is going to...

Are Enterprise Level DataContracts a Good Practice?

Is it a good practice to define DataContracts in an enterprise level assembly and then reference them in WCF service projects as opposed to defining them at the individual WCF service solution level? All of the WCF examples that I have seen have avoided that topic and have only defined DataContracts in the service solution. Some programm...

What is best-practice when designing SOA WCF web-services?

Given an operation contract such as: [OperationContract] void Operation(string param1, string param2, int param3); This could be redesigned to: [MessageContract] public class OperationRequest { [MessageBodyMember] public string Param1 { get; set; } [MessageBodyMember] public string Param2 { get; set; } [MessageB...

Portable / Interoperable WCF Contracts

I was wondering if anybody out there had some good tips/dos and don'ts for designing WCF contracts with a mind for web-service interoperability, both in terms of older Microsoft web service technologies (e.g. WSE) and non-Microsoft technologies such as Java calling WCF web services. For example: are there any special rules that need t...

Naming Generic DataContracts in WCF

I am using a Generic Class as a Response Data Contract. All is good and this is streamlining the design of my WCF service significantly. Each request is given a standard response object with the following signature: Status (Enum) Message (String) Result (T) Below is the Response Class: [DataContract] public class Response<T> ...

How can you control WCF serialization so it uses attributes instead of elements?

If I have a class marked as a DataContract and a few properties on it marked with DataMember attributes I can serialize it out to XML easily, but it would use an output like. <Person> <Name>John Smith</Name> <Email>[email protected]</Email> <Phone>123-123-1234</Phone> </Person> What I would prefer is attributes, like... ...

Which list/collection type is best to use in a WCF data contract?

When defining a WCF data contract, which type should one use for collections/lists? Should it be ICollection<T>, IList<T>, T[] or...? Should I use interface types or the concrete types? What trade offs are there to consider? ...

WCF contract changes that affect clients

I was curious if someone could outline which types of WCF contract (interface) changes on the server side would break a client trying to send in a message, and why. I believe WCF can handle certain discrepancies, but I'm not sure exactly what you can change safely, and what you can't. Add/remove parameters from an OperationContract? A...

How do you send complex objects using WCF? Does it work? Is it good?

Can I have a data contract of this shape?? [DataContract] public class YearlyStatistic{ [DataMember] public string Year{get;set;} [DataMember] public string StatisticName {get;set;} [DataMember] public List<MonthlyStatistic> MonthlyStats {get;set} }; I am assuming here that class MonthlyStatistic will also need to be a DataContrac...

Serialization / Derialization of a tree structure

I'm trying to figure out the best way to save (serialize) and later open (deserialize) a tree structure. My structure is made up of various object types with different properties, but each inherits from a base abstract "Node" class. Each node has unique ID (GUID), and has an AddSuperNode(Node nd) method that will set the parent of a nod...

Collections in DataContracts in partial trust scenarios

I've been pretty confused on one point in design of DataContracts for serialization. Say I have an object (e.g. a Customer) and it exposes a collection property (e.g. an AddressCollection named Addresses). Framework design guidelines dictate that I should not expose a public mutator for the property, i.e., the collection property shoul...

Resolve CLR Type from DataContract.Namespace?

Hello, I'm a newbie whitebelt with WCF. I have a namespace: http://schemas.datacontract.org/2004/07/System/ArgumentException. I'm looking to take that string and convert it into a CLR type so that I end up with typeof(ArgumentException). Is this possible? :) Thank you, MichaelD ...

Expose object from class library using WCF

I'm using a class library that exposes a few objects. These objects have a couple of properties that hold data my clients need. I'd like to create a WCF service that returns the objects to my clients but I cannot update the class library in order to add the DataContract and DataMember attributes. What is the easiest way of exposing th...

Null vs Value Not Set

We've written a web service which uses a simple entity translator to map the values of DTO back on to "real" server side business objects. As part of this excercise. We have come across an "interesting" distinction between explicitly set null values and clients having not set a value. The problem is essentially that we want to set a def...

Unique namespace for generic DataContract

Hello. Is there a way to generate a unique data contract namespace for generic types (similiar to data contract name) in C#? I'd like to do something like this, where {0} in the namespace value would be replaced by the specific data type name. [DataContract(Name = "DataResult_{0}", Namespace = "CommonTypes_{0}"] public class DataResu...

DataContract issue in WCF

Hello everyone, Suppose I have a method and the return type is enum, my question is should I declare the enum as DataContract or not? Samples like, in the sample, OrderStatus is an enum data type, OrderStatus Poll(string queryID); Should I declare OrderStatus enum type as DataContract? thanks in advance, George ...