Chris Klepeis
Chris Klepeis

Reputation: 9993

RESTFUL WCF Remove all xmlns

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.

Upvotes: 3

Views: 3922

Answers (2)

Yuki
Yuki

Reputation: 740

Try just removing the DataContract and DataMember attributes. This may solve your problem.

Upvotes: 0

Darrel Miller
Darrel Miller

Reputation: 142222

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.

Upvotes: 1

Related Questions