I have a series of objects that look like this:
namespace MyNamespace
{
[DataContract(Namespace="")]
public class MyClass1
{
[DataMember]
public string MyProperty {get;set;}
}
}
I have a method which exposes the WebInvoke that looks like this (very simplified as this actually does nothing right now, but still works for this test)
[WebInvoke(UriTemplate = "", Method="POST")]
public MyNamespace.MyClass1 GetItem(MyClass1 postedItem) { return postedItem; }
I would really like to be able to accept XML that looks like this:
<MyClass1>
<MyProperty>1</MyProperty>
</MyClass1>
or this:
<MyClass1 xmlns:"http://schemas.datacontract.org/2004/07/MyNamespace">
<MyProperty>1</MyProperty>
</MyClass1>
But so far my research seems to indicate this is not possible. My only idea right now is to use a IDispatchMessageInspector and consume the message, remove the xmlns namespace, and then allow WCF to continue processing the message. I have not had a lot of luck with this however, because once I consume the message it is no longer available for WCF to consume and deserialize.
Is there an easier way? Is there a better way?