I have an object generated by an \"Add service reference...\" operation and I am manually serializing it with a generic serializer I wrote.
My problem is that the da
This might be a little off-topic and might not apply if you're using [DataContract]
. Rather, this applies to proxy code generated from a WSDL (in an interop environment with a java endpoint, we've been told the xmlns="" is invalid). So I'm putting it out there in case it helps.
The XmlElementAttribute.Form
property can cause xmlns="" to be output for child members in the WCF request when set to System.Xml.Schema.XmlSchemaForm.Unqualified
.
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string MyProperty {
get; set;
}
which produces something along the lines of
My value goes here
Setting it to System.Xml.Schema.XmlSchemaForm.None
(which is the default value) means it won't output the "unqualified" namespace attribute.
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.None)]
public string MyProperty {
get; set;
}
which produces this:
My value goes here
I'm not sure if you can change this behaviour while importing the wsdl reference, or perhaps the wsdl should have been changed, but I ended up editing the generated proxy code directly (which definitely isn't ideal), but achieved my immediate goal.