0

Need help to validate if one of the incoming XML tag contains serialized data or not. If ir doesn't contain then have to thow an user defined exception. This has to be achieved using ESQL.

example :

<input_data>
<source>ABCD</source>
<key_data>incoming serialized data</key_data>
</input_data>

here Key_data should be validated to check if it contains anything other than serialized data.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
user2995546
  • 1
  • 1
  • 1
  • 1

2 Answers2

1
IF FIELDNAME(rootTagname.*:input_data) = 'input_data' THEN

    -- do some thing as per your requirement 
ELSE

  THROW USER EXCEPTION MESSAGE 'some number' VALUES ('no value received for input_data.');

end IF;
Pete
  • 57,112
  • 28
  • 117
  • 166
0

How are you defining serialized data? You can check that the data contains something by using something along the lines of:

IF InputRoot.XMLNSC.input_data.key_data IS NULL OR FIELDVALUE(InputRoot.XMLNSC.input_data) = '' THEN
  THROW USER EXCEPTION MESSAGE 2951 VALUES('Data element was empty')
END IF;

If you ened to actually check the data then you need to replace the if condition with a function which can determine if the data is "serialized data" or not. For example if you wanted to test if the data was a serialized java object then you could build an EXTERNAL Java function that attempted to deserialize the object and return true/false.

Ultimately Broker doesnt know what you mean by serialized data though so you ened to provide that context through your own application code.

Dave
  • 633
  • 4
  • 6