XML generated by XMLWriter in WCF Custom Encoder generating namespace conflict

CexCrellsueno

New Member
I'm using a custom encoder in my WCF application to write out the SOAP message XML. When I use the default XML \[code\]textMessageEncoding\[/code\] built into WCF it's fine, but when I use a custom encoder I get a problem with the namespaces - the xmlns:a tag below (in the element and the element) is defined twice for two different namespaces and this is causing problems on the service side when parsing\[code\]<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <Action a:mustUnderstand="1" u:Id="_3" xmlns="http://www.w3.org/2005/08/addressing" **xmlns:a="http://schemas.xmlsoap.org/soap/envelope/"**></Action> <MessageID u:Id="_4" xmlns="http://www.w3.org/2005/08/addressing"> <!--Omitted--> </MessageID> <ActivityId CorrelationId="1" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics"> <!--Omitted--> </ActivityId>\[/code\]Any idea on how to fix this issue? I'm using the C# \[code\]XmlWriter\[/code\] in the custom encoder to write the XML and that's what seems to be causing the issue.Also, how do I get the \[code\]XmlWriter\[/code\] to use a prefix for the \[code\]<Action>\[/code\] tag above so that it's \[code\]<a:Action>\[/code\] rather than using the xmlns for every declaration -\[code\]<Action a:mustUnderstand="1" u:Id="_3" xmlns="http://www.w3.org/2005/08/addressing"\[/code\]Here's my XmlWriterSettings\[code\]XmlWriterSettings writerSettings = new XmlWriterSettings();writerSettings.Encoding = Encoding.GetEncoding(factory.CharSet);writerSettings.OmitXmlDeclaration = true;writerSettings.NamespaceHandling = NamespaceHandling.OmitDuplicates; \[/code\]
 
Back
Top