Webservice exception: illegal enumeration value

I'm calling a webservice (complex type) and using a DomainToXML mapping. Within this mapping, I have to map Enumeration values to String. I'm using several convert microflows where I use the enumeration value as the input parameter, create a variable of type string where I set the "toString($EnumValue) and return value is a string with the created variable. The problem occurs when an enumeration value is NULL. Although I check whether the enumeration value = empty and return a '', otherwise the created string value. The webservice applies from one Mendix application to another Mendix application. Both traces of the webservice log nodes are provided below. Any help is appreciated. EDIT At the published microflow side, all members except from one attribute (non enumeration) are set to optional. Response content for 'http://www.example.com/SaveApplicationToArchive': <soap:envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:body><soap:fault><faultcode>Client</faultcode><faultstring>Illegal enumeration value for BondOwner ()</faultstring></soap:fault></soap:body></soap:envelope> com.mendix.modules.webservices.WebserviceException: Illegal enumeration value for BondOwner () at jB.a(SourceFile:468) at jB.a(SourceFile:395) at jB.a(SourceFile:352) at jB.a(SourceFile:302) at jB.a(SourceFile:267) at jB.b(SourceFile:129) at jB.a(SourceFile:88) at com.mendix.modules.webservices.WebserviceModule.handleWebserviceCall(SourceFile:380) at dI.processRequest(SourceFile:27) at fF.a(SourceFile:71) at com.mendix.core.MxRuntime.processRequest(SourceFile:924) at com.mendix.m2ee.server.handler.RuntimeHandler.handle(RuntimeHandler.java:42) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113) at org.eclipse.jetty.server.Server.handle(Server.java:334) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559) at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1007) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:747) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:209) at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436) at java.lang.Thread.run(Thread.java:662)
3 answers

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.