How to get rid of the default xml namespace if i am the one to serialize an object to wcf using datacontact
Here is my interface
[ServiceContract(Namespace = "")]
interface IParam { }
Here is my class
public class Parameter : IParam
{
private string categoryName;
[DataMember]
public string CategoryName
{
get { return categoryName; }
set { categoryName = value; }
}
}
My work contact
[OperationContract]
string GetSegmentsByCategoryName(Parameter Params);
Here is my main one:
Parameter abc = new Parameter ();
abc.CategoryName = "xxx";
str = client.Channel.GetSegmentsByCategoryName(abc);
when i check on wireshark i got this xml
<Params xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<CategoryName>
xxx
</CategoryName>
</Params>
i to get rid of the xmlns: i = "http://www.w3.org/2001/XMLSchema-instance when i pass the object via wcf httpbinding.
+2
grace
source
to share
1 answer
It is not the default / element namespace, although it is just an unused namespace alias that can be used. It doesn't really break anything. I would strongly advise you to just leave it alone.
If you really, really wanted to do this - perhaps write a message inspector .
+1
source to share