views:

535

answers:

2

Hi,

I am developing WCF services in .net 3.5 framework and hosting them in IIS 5.1 windows xp sp3 with basicHttpBiding.

Services consuming client developed in .net 2.0 framework. For this I generated proxy client using WSDL.EXE. This tool generates proxy class without any problem, but the problem it adds for every property adds extra property "[property]Specified", but that work fine without any problem, only need to specify "specified = true" when assigning value to any property

To remove this extra property I added XmlSerializerFormat attribe along with ServiceContract attribute. WSDL.EXE generates the class without extra property, but it excludes some class which are included previously.

Is there any properties that I need to set to generate the excluded classes?

Note: All contract classes are attributed with DataContract and properties with DataMemeber.

Thanks
nRk

+1  A: 

The standard WCF DataContractSerializer will serialize everything marked with [DataMember] - regardless of the .NET visibility (public/protected/private/internal).

When you switch to the XmlSerializerFormat, the behavior changes - now the XmlSerializer will serialize everything that has a public visibility, and does not have a [XmlIgnore] marked on it.

I would assume some of your classes and members are not marked with public and thus don't get serialized anymore. Also the XmlSerializer requires classes to have an explicit, parameter-less constructor which will be used in deserialization - do all your classes have that? And of course, that constructor also needs to be public.

marc_s
Thanks Marc, As you specified all properties are having public and having default constructor. The problem is comming, where I need to return to one method is base class, which is inherited by 8 child classes, but I am getting in proxy only 4 classes. All inherited classes are haivng public/default constructor and all properties are public. All classes decorated with DataContract and properties with DataMember attrigute.
nRk
The DataContract/DataMember attributes don't matter here if you're using the XmlSerializer. Are all your 8 child classes defined somewhere in a `[KnownType]` attribute on an operation contract? I would think only those that are mentioned specifically either as a parameter in an operation, or by means of the known-type attribute, will be serialized
marc_s
Thanks for the help.Sorry, I forgot to mention that, in the base class I added attribute [KnownType(typeof(childclass))], I added 8 attributes for each child class.
nRk
+2  A: 

XmlSerializer uses XmlIncludeAttribute instead of KnownTypeAttribute to discover child types that are not included in operation contracts. So you might try adding them to the base class:

[XmlInclude(typeof(ChildClass1))]
[XmlInclude(typeof(ChildClass2))]
public class BaseClass {}
Darin Dimitrov
Thanks Darin, I did as you specified, it works. :)
nRk