views:

146

answers:

1

Hi

With the XmlSerializer I can have my members in different namespaces to the parent type. Can I do the same thing with DataContractSerializer? I would like the following Xml

<h:Type xmlns:h="http://schemas.e.com/WebServices" xmlns="http://schemas.e.com/WebServices"&gt;
  <Member xmlns="http://schemas.e.com/CoreTypes"&gt;0&lt;/Member&gt;
</h:Type>

Is this possible in Wcf with DataContractSerializer?

Thanks

A: 

You can define subdatacontracts in different namespaces and use them as members of another datacontract, but you can't control the individual member names and/or shapes. DataContract serializer isn't intended to replace XmlSerializer for fine-grained control of the "shape" of your XML.

nitzmahone
so are u saying it can't be done? or it can, but it shouldn't.should i be heading back to using the XmlSerializer?
ryancrawcour
Basically. DataContracts were not designed for fine control- they're for "quick, easy, and repeatable" when both sides of the pipe are WCF. XmlSerializer and WCF get along just fine- it just uses DataContractSerializer by default.
nitzmahone