开发者

WCF REST: Is it possible to remove the namespace added to my response XML?

开发者 https://www.devze.com 2022-12-25 00:19 出处:网络
I want to remove the default xmlns (namespace) added to my service\'s response (see image below) Is t开发者_如何学运维here a way to do this? This because in order to consume this service from a C#

I want to remove the default xmlns (namespace) added to my service's response (see image below)

WCF REST: Is it possible to remove the namespace added to my response XML?

Is t开发者_如何学运维here a way to do this? This because in order to consume this service from a C# windows app, I have to add the namespace to every data object's header - DataContract that I will be serializing.


I think if you just use

[DataContract(Namespace="")]

on the Bookmarks class, that should do it.


I just tried this and got the following:

<CompositeType xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <BoolValue>true</BoolValue>
  <StringValue>Hello </StringValue>
</CompositeType>


Actually, WCF REST Contrib proved to be the perfect solution using their PoxDataContract.


Expanding on @Tawani's answer, if you want to support attributes or otherwise customize your XML serialization you can easily extend WcfRestContrib by creating a custom IWebFormatter. Here's my answer to a similar question explaining how to do this using an XmlSerializer.

0

精彩评论

暂无评论...
验证码 换一张
取 消