datacontract

Deserialize an array of strings with DataContract

I have an xml schema with a type defined like this: <xs:complexType name="InteractiveWorkflowAddress"> <xs:sequence> <xs:element name="endpointAddresses" nillable="true" type="q1:ArrayOfstring" xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /> <xs:element name="instanceId" type="ser:guid" />...

Custom serialization with DataContractSerializer

Hi, I'm currently using wrapper classes for my DataSets ,in order to implement custom serialization. I would like to use DataContractSerializer (more like have to use it) but still support the custom serialization. The problem is that the [DataContract] and [Serializable] attributes don't seem to get along so well... how could I override...

How do I control an element name in WCF?

Is it possible to control the "name" of a WCF return element? For example, I have a WCF method PerformAction which returns an ActionResponse. The ActionResponse type looks like this in the WSDL: <xs:element name="ActionResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="PerformActionResult" nillable="...

data contract issue wcf

hi all, i have a problem regarding data contract in my application. i have 5 tables in my database and i required 3 of them as datatype. so i created a class and decleared all required table as class under [datacontract] here's the code [DataContract] public class CustomerDetail { [DataMember] public int Custome...

Including XML Comments in DataContract Serializer Metadata

is there some way of sending the summary info of properties in a DataContract? e.g. [DataContract] public class MyClass { /// <summary> /// My Summary information /// </summary> [DataMember] public int MyProperty {get;set;} } can this be available to the client that gets the datacontract? I doubt it, just hoping somebody kn...

System.Runtime.Serialization.InvalidDataContractException in production environment , not in test environment

I’m moving a web service from our test environment to our production environment, and am installing it under “services” The web service works fine in test, but in prod I get this error: “System.Runtime.Serialization.InvalidDataContractException: Type ‘CustomClass' cannot be serialized. Consider marking it with the DataContractA...

WCF DataMember List<> without enclosing element

The following DataContract: [DataContract(Namespace = "http://namespace", Name = "Blarg")] public class Blarg { [XmlAttribute("Attribute")] public string Attribute{ get; set; } [DataMember(Name = "Record", IsRequired = false, Order = 4)] public List<Record> Record{ get; set; } } Seriali...

WCF Data Contract / Serialization

I created a simple WCF application which expose one operation. This operation takes a composite data type as parameter. I have not decorated this composite data type with [DataContract] attribute. But this is working and I can see the Schema for this in WSDL. Now my understanding is that this new custom type should be decorated with ...

WCF - Can I use an existing type to be passed through my WCF service...

I have a service. I have an existing class of business objects. What I would like to know is how can I pass a class through WCF from the business object assembly without having to create a new class in my WCF site while appending or tags? Here is an existing UDT: Namespace example: Application.BusinessObjects.Appointments Public St...

How do I use methods in classes decorated with DataContractAttribute in a WCF Client?

I'm writing a .net WCF service. I've written a few classes that I want to return to the calling code from the WCF service; hence, I decorate them with the DataContract attribute. Let's suppose that my WCF service is called FooService. It contains a method called FooMethod which returns an object of type FooData (which is decorated wit...

WCF data contract

I have a data contract and I defined some constant variables in it and have [DataMember] tag for each constant variables. However, my client side does not retrieve those constant variables. I want those constant variables synchronized with the WCF service every time I update the metadata of my WCF service at my client side. I don't want ...

Why does Visual Studio use backing fields for WCF Service References?

As many of you will be aware, I can use the DataContract attribute to mark a class for serialization into XML in a WCF service. For example, I can create a DataContract thus: < DataContract() > Public Class fooClass < Datamember() > Public fooString as String End Class When I add a service reference to the code that wi...

Can I prevent a specific datamember from being deserialized?

I have a datacontract like this [DataContract] class MyDC { [DataMember] public string DM1; [DataMember] public string DM2; [DataMember] public string DM3; } and sometimes I want to prevent DM2 from being deserialized when being returned from an OperationContract. Something like this: [OperationContact] pu...

Associating a variable with a class in C# (for JSON)

I'm having to grab API-provided JSON for a project of mine, and that means deserialising JSON using a class, and I've chosen to go with DataContract classes. In any case, different URLs correspond to different JSON outputs for the API. So what am I asking? It's to see if there's any better way to have URLs corresponding to the DataContr...

Sending own data collection in WCF

I have own collection DataContracts: [DataContract] public class DzieckoAndOpiekun { public DzieckoAndOpiekun() { } public DzieckoAndOpiekun(string dzImie, string dzNazwisko, string opImie, string opNazwisko) { this.DzieckoImie = dzImie; this.DzieckoImie = dzNazwisko; this.OpiekunImie = opImie; ...

Serialization of class derived from List<> using DataContract

I'm trying to serialize a class derived from List<> using DataContract. The problem is that properties of my class won't get serialized. My classes: [CollectionDataContract] /*[Serializable]*/ /*[DataContract]*/ public class DownloadRuleCollection : List<DownloadRule> { [DataMember(EmitDefaultValue = false)] public string Some...

Renaming of class property that is marked with a DataMemberAttribute

Actually i have a class like this [DataContract] public class Item : IExtensibleDataObject { [Browsable(false)] public virtual ExtensionDataObject ExtensionData { get; set; } [DataMember] public string ID { get; set; } [DataMember] public string Name { get; set; } public Item() : this(String.Empty,...

Error when porting WCF project from VS 2008 to 2010

I am getting a strange error after trying to compile under 2010. The compiler doesn't seem to understand my [DataMember] attribute: error CS0246: The type or namespace name 'DataMember' could not be found (are you missing a using directive or an assembly reference?) Shouldn't this all be defined in System.Runtime.Serialization? Any in...

Rolling my own CMS with the WCF, what should my contract be?

I'm looking to create a solution for a asp.net mvc app that displays unstructured course descriptions that have been scraped from around the web. The web server will be on a web hosting company while the description db will be on a private network, so I'd like to pass the description to the mvc app through a WCF service. For the body of...

Is there any way to hide/flatten base types in WCF service data contracts?

Consider the following simple example: [DataContract("{0}Base")] public class Base<T> where T : Entity<T> { // Common methods & properties. No WCF exposed properties } [DataContract] public class Employee : Base<Employee> { // WCF exposed properties } The base class Base has no properties of interest to the WCF service consu...