Skip to main content

Development

How to Handle a DFDL Serialization Error

Problem Statement: If a fixed-length request has to be constructed from a message (for example xml, which has optional fields and complex objects with cardinality >1,) the following scenarios show the DFDL properties that can be used instead of using a conditional check in mapping /compute node to overcome the DFDL Serialization Error.

Sample Scenario: Consider a sample MQ Message flow which accepts an XML message from which a fixed length message has to be constructed and send to an MQ Output Queue.

The following objects are used to create the message flow MF_CustomerDetailsFlow in the application CustomerDetails.

How to Handle a DFDL Serialization Error

The CustomerDetailsFixedLengthRequest fixed length message has to be constructed from the CustomerDetailsRequest whose Address object is optional. Now if the CustomerDetailsRequest has Address objects with cardinality <2 then the DFDL Serialization error occurs.

How to Handle a DFDL Serialization Error

From the exception list of the message tree,

How to Handle a DFDL Serialization Error

Solution: If the fixed length data has to be constructed with 2 of Address objects length always.

In this case, if the value of the Address object in xml has less than 2 objects (i.e. 1 or 0,) then you can set the default value along with the below properties. If Default values are not set, then the  DFDL Serialization error will occur again.

Note: MinOccurs and MaxOccurs should be the same and the Occurs count kind can be implicit/fixed/parsed. The test results are the same.

How to Handle a DFDL Serialization Error

 

Steps to set the default value:

1. Open the schema in the DFDL editor

2.1. To set space when the incoming message has no data for that field, select empty string under the default value column of the field.

How to Handle a DFDL Serialization Error

2.2. To set a value other than space, (for example if zeroes have to be set,) then set the number of zeroes as the default value that has to be set when the incoming message has no data for that field.

For example, if five zeroes have to be set, then the default value should be given as 00000.

If just one zero is set then a zero will be set and the rest will be set with the pad characters specified.

How to Handle a DFDL Serialization Error

If the default value is not set, then a DFDL serialization error occurs.

If the nillability of the element is known from the XML Schema, then the following properties can be used to set the default value.

The Use Nil for Default property will serve the same purpose as the default value that has been set. But the former has precedence over the default value property. So if you specify both, the default value will be ignored.

How to Handle a DFDL Serialization Error

Nil Kind is selected as a literalCharacter so that the Nil Value selected will be repeated over the length of the object.

Nil Value can be anything Space or any Value.

Thoughts on “How to Handle a DFDL Serialization Error”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Priyanka Baalisetti

More from this Author

Categories
Follow Us