views:

1138

answers:

4

I just started using WCF and I already came to a project-altering issue. I created a service and put in reference in a webservice, but the every field in the webservice xml file comes with an ExtensionData field.

Example:

alt text

I don't want this. I need it to be only:

alt text

Is there a way to remove this field? Some different kind of serialization?

Tks

+1  A: 

ExtensionData is used to maintain compatibility across services that may share contracts of different versions. It can be safely ignored when passing messages.

You may be able to get rid of it by using something other than the DataContract serializer (im thinking old school [Serializable]), but i could be wrong.

Mike_G
+1  A: 

The ExtensionData is actually a feature that must be built into the type to enable round-tripping. It is always emitted by the DataContractSerializer. One possible way of suppressing this field is using the older XmlSerializer by decorating your service contract interface with the XmlSerializerFormatAttribute.

Darin Dimitrov
A: 

Not answering the question, but maybe this helps...

From MSDN http://msdn.microsoft.com/en-us/library/ms731083.aspx:

The round-tripping feature may be turned off, either by setting ignoreExtensionDataObject to true in the DataContractSerializer constructor or by setting the IgnoreExtensionDataObject property to true on the ServiceBehaviorAttribute. When this feature is off, the deserializer will not populate the ExtensionData property, and the serializer will not emit the contents of the property.

Joe
Setting the value to true doesn't make the ExtensionData property disappear; it just prevents sending data, if any exists, to the client.
Darin Dimitrov
+3  A: 

Most likely, your DataContract classes will be implementing the IExtensibleDataObject interface, right? That's responsible for the ExtensinoData field - just remove that interface, and you should be able to remove the ExtensionData fields, too, from your DataContracts.

Marc

marc_s