I am using WCF to return a plain old XML (POX) document to the caller. I am using the XML Serializer formatter to turn the objects into XML.
In the returned document I have some extraneous xml namespace references (that weren't there in the ASMX version) for the XML Schema and instance. I have seen various arguments on the web that these shouldn't be removed which I don't buy into for returning a plain XML document.
What is the simplest way of removing these xmlns references from a returned XML document in WCF?
The signature looks like:
public ResponseInfo Process(string input) {
}
You can remove the XML namespace by setting the Namespace parameter of the DataContract attribute to an empty string, like so:
[DataContract(Namespace = "")]
public class ResponseInfo
{
// ...
}
I hope this helps...
I had the same problem. Adding BodyStyle:=WebMessageBodyStyle.Bare to WebInvoke worked for me. Response is no longer wrapped in a metadata.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With