2

I have generated a WCF proxy from a WSDL file and are having problems with a property/field.

The propertie is of a complex type(class) and is decorated with the following attribute in the generated code.

XmlElementAttribute(IsNullable=true)

When the propertie is not set to an object the serializer will still generate it in the XML like this

<OpDDoctorInfo xsi:nil="true" />

I need it to not be generated at all.

I really dont like to change in a generated proxy file but I dont seem to have any other choise?

From this link I can see that if there is a default value and the value that is set is the same then the default behavior will be to exclude it from the xml so why have it been generetad with a attribute like this?

Edit: some thinks that this is a dubblicate of this :

What is the correct way to represent null XML elements?

It is not, that questions asks what the correct way is to handle null. Im asking how to remove the propertie/field from the generated XML while using a generated proxy class. Maybe I have to change in the proxy generated code or is there a better way?

Community
  • 1
  • 1
Banshee
  • 15,376
  • 38
  • 128
  • 219
  • And what kind of problem you have with that generated element? – Evk Mar 13 '17 at 08:11
  • The user of the generated XML file says that XML standard is that the tag should not be in the file at all if there is no value set or if it got its default value. – Banshee Mar 13 '17 at 08:14
  • Possible duplicate of [What is the correct way to represent null XML elements?](http://stackoverflow.com/questions/774192/what-is-the-correct-way-to-represent-null-xml-elements) –  Mar 13 '17 at 08:41
  • Yes, I have found that and it explaints the XML standard but not how to handle it if you need to remove the property/field from the XML with a generated proxy. But I supose I will have to remove the attribute in this genereated proxy class to get what I need. – Banshee Mar 13 '17 at 08:46
  • They're arguing that the `nil` attribute, specifically build into the concept of XML Schemas - [see here](https://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#Nils) is "non-standard"? Good luck with that. It will be interesting to see where else they're treating their interpretation of reality as "the standard" rather than actually being a good citizen. – Damien_The_Unbeliever Mar 13 '17 at 09:17

0 Answers0