| | | | Browse by category |
In XML booleans can be represented by either "1 and 0" or "true and false". By default LEIF marshals booleans as strings "1" or "0" to make the output xml as compact as possible. Some servers and/or applications, however, expect booleans to be represented with the strings "true" and "false".
Action
Fortunately LEIF allows you to work around this problem easily using a configuration file. The XML Object Link User Guide explains this use of configuration files in section 8.7.
As with all user-created configuration files, you'll want to include the contents of the provided soapArray.cfg file located in the RW_HOME/xslt/xmlol directory, which provides array support by default. If you create your own configuration file, XMLOL no longer reads in the mapping in the soapArray.cfg file, consequently arrays will not be supported in the generated code unless you include this information in your own configuration file.
You can ommit this information if you're not working with arrays, but you can and should use the contents of this file as a starting point as a general rule.
Here are the contents of the soapArray.cfg file:
<config xmlns="http://www.roguewave.com/ratchet">
<mappings>
<template xsdvalue="Array" nsuri="http://schemas.xmlsoap.org/soap/encoding/" xsltname="arrayhandler.xslt" handleBody="no"/>
</mappings>
</config>
To add support for marshalling boolean values as "true" or "false" to this file you need to add the logic to make the conversions. Here is the completed configuration file that will accomplish the conversions with the additional "typeinfo" set apart by whitespace for emphasis:
<config xmlns="http://www.roguewave.com/ratchet">
<mappings>
<template xsdvalue="Array" nsuri="http://schemas.xmlsoap.org/soap/encoding/" xsltname="arrayhandler.xslt" handleBody="no"/>
<typeinfo cppType="bool" isPrimitive="true">
<fromString>"true" == $value$ || "1" == $value$</fromString>
<toString>($value$)?"true":"false"</toString>
<defaultValue>"$value$"</defaultValue>
<initialValue>false</initialValue>
</typeinfo>
</mappings>
</config>