Search code examples
wcfwsdlasmxdatacontract

Control name of built-in generic parameter in WCF DataContract


I am converting asmx web service to wcf while attempting to maintain backwards compatibility in the WSDL. One of the DataContract classes is generic. When the generic parameter is a built-in type, such as bool, the first letter is lowercased in WCF, whereas it was uppercased in asmx. E.g.

[Serializable]
public class MethodResult<T>
{
}

would generate

MethodResultOfBoolean

in asmx.

[DataContract(Name="MethodResultOf{0}")]
public class MethodResult<T>
{
}

generates

MethodResultOfboolean 

in WCF.

Is there a way to make it use an uppercase letter in WCF?


Solution

  • I found that adding [XmlSerializerFormatAttribute] to the ServiceContract interface fixed this.