WCF Custom WSDL XmlSerializerOperationBehavior
Posted
by Jeff
on Stack Overflow
See other posts from Stack Overflow
or by Jeff
Published on 2010-04-01T17:42:16Z
Indexed on
2010/04/01
17:43 UTC
Read the original article
Hit count: 392
Hi,
I have code that builds a custom WCF wsdl on the fly. In one particular scenario, the WSDL exported should use the XmlSerializerOperationBehavior as the IWsdlExportExtension as opposed to the default DataContractSerializerOperationBehavior IWsdlExportExtension.
However, every time I try this from the WSDL generation code, I get a null reference exception from the ExportBody method of the XmlSerializerMessageContractExporter (which is used internally in System.ServiceModel by the XmlSerializerOperationBehavior ExportContract method). I've reflector'd it and I can't see anything obviously wrong. For some reason, .NET also doesn't want to work with source stepping in this scenario...
Simply, the most basic way I can reproduce this is
var c = ContractDescription.GetContract(typeof(IMyService));
foreach (var op in c.Operations)
{
op.Behaviors.Remove(typeof(DataContractSerializerOperationBehavior));
op.Behaviors.Insert(0, new XmlSerializerOperationBehavior(op));
}
new WsdlExporter().ExportContract(c); // throws NullReferenceException
Does anyone have any ideas on this?
Thanks very much.
© Stack Overflow or respective owner