RESTFUL WCF Remove all xmlns
-
19-09-2019 - |
Question
I set my DataContracts namespace to "" which removed one namespace but I have to remove the other:
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
If theres no other way, how can I serialize my class prior to returning and hack out the namespace?
I have to do this to work with another companys API.
Solution
Your only real option, other than throwing away WCF is to change you service contract to return a stream and do the XML serialization yourself. You could still use the data contract serializer, convert to a string strip out all the namespaces and then convert back to a stream to return, but that sounds nasty.
If you need to accept XML without namespaces in POST bodies then you are in for a whole lot more pain. In that case I would dump WCF really quick.
OTHER TIPS
Try just removing the DataContract and DataMember attributes. This may solve your problem.