If you specify an enumeration value in the Domain-to-XML mapping, you must specify a valid enumeration value. The empty string (''
) is not a valid enumeration value, and that causes an exception on the receiving side.
One solution could be to use one of the values as default value in case the enumeration value is empty
. Another solution could be to use a different mapping that does not specify the enumeration value in the case of empty
.
Edit: Currently it is not possible to dynamically decide whether or not to specify a certain element based on the data. You select the elements that you want to generate when creating the mapping, and all the elements that you select must be filled in with a valid value. For enumerations this means that all selected elements must have a valid enumeration value.
However, as the receiving side in your case is also a Mendix system, you could work around this limitation by having the published web service accept a set of String attributes instead of enumerations. Then, you could convert these String values to their corresponding enumeration values, and use the empty string for empty values. This might be a lot of work though.
In this case I think it might be nice if the published web service would specify that the enumeration value is nillable, and that the mapping would automatically convert empty enumeration values to nil values. I suggest filing a feature request for that.
Hi Benny, Thank you for your answer.
The problem with this solution is, we are trying to do a simple archiving app, in other words, the enum values must be the same on both sides. It cannot be empty on the one side and something 'default' on the other.
We have about 20 enumerations, of which all of them can be empty as defualt, so to specify a different mapping for each of them is not an option.
The enum's empty value is not null, it's ''. Try checking for that instead.