Using Non Data Contract Types in Indigo

The Data Contract provides the features that were not possible with the earlier serialization technologies, features such as Versioning, Object Identity and Object Graph preservation. This is a great way to go if you are starting fresh. However there might be situations in which using the Data Contract is either not possible or not practical.

For example,

  1. You are an Indigo service and you want to Interop with existing or down level clients with minimal code changes to the client
  2. You are an Indigo client who want to consume the existing or down level service and hence non Data Contract types
  3. You already have existing types that you do not want to or can not covert to data contract types

In all such cases you want to use XmlSerializer to serialize and de-serialize types instead of Indigo XmlFormatter. The ServiceContract attribute has a property called FormatMode, this property instructs the runtime to use either XmlFormatter or XmlSerializer.

[ServiceContract(FormatMode=ContractFormatMode.XmlSerializer)]
public interface MyInteroperableContract
{

Over the next few posts we will get to the details of achieving Interoperability in the scenarios mentioned above and their implications on wire messages, WSDL and programming model. If you can’t wait, here is the brief description of what you need to do.

If you are a service and want to Interop with down level client most probably the only thing that you need to do it to set the FormatMode proeprty of ServiceContract to ContractFormatMode.XmlSerializer. If you are trying to Interop with the existing service, use /useXmlSerializer or /uxs option to svcutil. In some cases you may also have to use /typedMessages or /tm option as well.