IBM Support

Invalid XML character error thrown when using MQ adapter language data binding

Troubleshooting


Problem

A runtime exception is thrown when trying to serialize incoming data containing unicode characters that cannot be interpreted as XML characters.

Symptom

You receive an error similar to the following message:

[07/02/12 10:07:34:926 EST] FFDC
Exception:java.lang.RuntimeException SourceId:java.lang.RuntimeException
caught trying to serialize BO
......
......
......
java.lang.RuntimeException: An invalid XML character (Unicode: 0x2) was
found in the element content:97520 UNITED STATES[1]
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl$Escape.convertText(XMLSaveImp
l.java:3101)

Diagnosing The Problem

The invalid characters are not true character data, and any attempt to put them into an XML character data stream will result in the "An invalid XML character was found in the element content" error. In this scenario you only have one option, and that is to treat those fields as strictly binary data. This will at least get the data from the bits in the MQ pipe into a data object, and then some mediation can be done on the data to transform it into something useful if required.

Resolving The Problem


The key in resolving the problem is to change a field from being String (or character) data into binary data.
When using the MQ adapter language data binding generator to generate data binding class for interface that references COBOL copybook business objects, the original generated data binding class has methods declared like the following to set the data to and get the data from a String:




You need to go into the Business Object editor to update both the field definition and the Application Info:



  • Change the type of field edi__63__data to ‘hexBinary’.
  • Then open the ‘Properties’ view and select the ‘Application Info’ tab and expand the tree.
  • Select the ‘stringTD’ element, and then press the ‘Delete’ button.
  • Right click on the ‘sharedType’ element and select NewBinaryTD.



To ensure the data binding is re-generated, select the module in the Business Integration perspective and then select ‘Project > Clean..’ from the menu bar.

The data binding method will now look like this and treat the data area as binary data:

[{"Product":{"code":"SSQQFK","label":"WebSphere Integration Developer"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Business Object Editor","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.0.0.4;7.0.0.3;7.0.0.2;7.0.0.1;7.0;6.2.0.3;6.2.0.2;6.2.0.1;6.2","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

More support for:
WebSphere Integration Developer

Software version:
7.0.0.4, 7.0.0.3, 7.0.0.2, 7.0.0.1, 7.0, 6.2.0.3, 6.2.0.2, 6.2.0.1, 6.2

Operating system(s):
Linux, Windows

Document number:
469353

Modified date:
15 June 2018

UID

swg21587642

Manage My Notification Subscriptions