Parsing an exception when using Event.createEventFromXML in TIBCO BusinessEvents.

Parsing an exception when using Event.createEventFromXML in TIBCO BusinessEvents.

book

Article ID: KB0093504

calendar_today

Updated On: 01-13-2017

Products Versions
TIBCO BusinessEvents Enterprise Edition -
Not Applicable -

Description

Description:
The following exceptions are thrown when Event.createEventFromXML() is used with wrong arguments to create events from XML.

1). java.lang.RuntimeException: com.tibco.xml.data.cursor.UndefinedPropertyException: [attributes] is not defined for the node type "document".
2).? java.lang.RuntimeException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 41; The processing instruction target matching "[xX][mM][lL]" is not allowed.

Issue/Introduction

Parsing an exception when using Event.createEventFromXML in TIBCO BusinessEvents.

Resolution

1). Pass the event payload inXML.
When using Event.createEventFromXML() to create events, the second argument XML String should adhere to the XSD schema corresponding to the event definition.
The second argument is used as shown below.

Event.createEventFromXML("<ONTOLOGY_PATH_OF_THE_EVENT>", "<EventName><payload>"+xmlpayload+"</payload></EventName>");

Example :

//Creating a orderline event from the XML argument as payload.
Events.OrderlineEvent Orderline = Event.createEventFromXML("/Events/OrderlineEvent", "<OrderlineEvent><payload>" + xmlpayload + "</payload></OrderlineEvent>");

Note : The XML header tag present in String XML might cause parsing issues. In this case, remove the XML version from the input XML string
Part to remove :<?xml version="1.0" encoding="UTF-8"?>


2). Pass the event properties and payload XML. Creating an event by passing the second argument with the event properties XML as shown below.
           
Event.createEventFromXML("<ONTOLOGY_PATH_OF_THE_EVENT>", "<EventName><property1>123</property1><property2>456</property2><property3>789</property3></EventName>");


Example: Events.TestEve TestProperty = Event.createEventFromXML("/Events/TestEve", "<TestEve><lineId>4</lineId><productId>abc</productId><qty>4</qty></TestEve>");