C# WCF XmlSerialization - How do I remove a node?

lol1232

New Member
I am writing a WCF service that should handle a predefined SOAP/XML format that I have no control over.Here is my exposed service contract:\[code\][OperationContract][WebInvoke(Method = "POST")]bool SavePets(Pets Pets);\[/code\]The SOAP that this service expects is:\[code\]<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <SavePets xmlns="http://tempuri.org"> <Pets> <Dog> <Name>Fido</Name> </Dog> <Dog> <Name>Duke</Name> </Dog> <Cat> <Name>Max</Name> </Cat> </Pets> </SavePets> </s:Body></s:Envelope>\[/code\]However, I need for either the method name (SavePets) or the parameter name (Pets) to be removed, as such, so the service does not expect it:\[code\]<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <Pets> <Dog> <Name>Fido</Name> </Dog> <Dog> <Name>Duke</Name> </Dog> <Cat> <Name>Max</Name> </Cat> </Pets> </s:Body></s:Envelope>\[/code\]I'm not using DataContracts or MessageContracts. My Pets class looks like this:\[code\][System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = false, Namespace = "http://tempuri.org")] [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://tempuri.org", IsNullable = true)] public partial class Pets{...}\[/code\]
 
Back
Top