views:

379

answers:

1

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.

+1  A: 

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.

Darrel Miller
I've already tested sending xml to my WCF without a namespace and it appears to have worked. I'll look into changing the service contract, thanks.
Chris Klepeis
Just out of curiosity, what data type is the parameter that accepts the posted body?
Darrel Miller
When I tested I just posted a string in xml format without the namespace, the receiving function parameter object is a custom class which the xml gets serialized into... my data contract
Chris Klepeis