How to use XmlSerializer to generate fault messages properly?

DXS

New Member
I got some service and mixed message (Wrapper over XSD generated code):\[code\][XmlSerializerFormat][ServiceContract(Name = "SomeService", Namespace = "http://some/v1-0")]public interface ISomeService{ [OperationContract(Name = "Some", Action = "http://some")] WrappedResponse ProcessSync(SomeRequestMessage message);}[MessageContract(WrapperName = "WrappedResponse", IsWrapped = true, WrapperNamespace = "http://xxx")]public sealed class WrappedResponse{ [MessageBodyMember(Name = "XSDResponse", Order = 0, Namespace = "http://GeneratedStuff/v1-0")] public XSDGeneratedStructure Response { get; set; }}[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")][System.SerializableAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")][System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://GeneratedStuff/v1-0")][System.Xml.Serialization.XmlRootAttribute("XSDResponse", Namespace = "http://GeneratedStuff/v1-0", IsNullable = false)]public partial class XSDGeneratedStructure { ...}\[/code\]Problem:[*]When I call that service and WCF returning response - it's a valid (wrapped xml with expected namespaces)[*]When I'm trying to create that response in my IErrorHandler: fault = Message.CreateMessage(version, replyAction, new WrappedResponse{Response = responseStructure}, new CustomXmlSerializer(typeof(WrappedResponse)));I don't get expected xml.Custom serializer:\[code\]public sealed class CustomXmlSerializer : XmlObjectSerializer{ private readonly XmlSerializer _serializer; public CustomXmlSerializer(Type type) { _serializer = new XmlSerializer(type); } public override bool IsStartObject(XmlDictionaryReader reader) { throw new NotImplementedException(); } public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName) { return _serializer.Deserialize(reader); } public override void WriteObjectContent(XmlDictionaryWriter writer, object graph) { _serializer.Serialize(writer, graph); } public override void WriteStartObject(XmlDictionaryWriter writer, object graph) { } public override void WriteEndObject(XmlDictionaryWriter writer) { }}\[/code\]It says that when [XmlSerializerFormat] used then WCF uses XmlSerializer. I do the same when creating fault message but my result is not the same.What am I do wrong?
 
Back
Top