Monday, July 30, 2012

SOA 11g XML Literal Uninitialized Variable XPath Error

Often while using the XML literal option within a XPath expression builder the following XPath error is encountered at runtime;

<dataObject name="FaultMessage" detailId="55029" isBusinessIndicator="false">
<value> oracle.bpm.bpmn.engine.model.runtime.microinstructions.TrappableException: faultName: {{}uninitializedVariable} messageType: {{}RuntimeFaultMessage} cause: {XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is oraext:parseXML('<Employees><Employee><Name>John Doe</Name><Dept>AE</Dept></Employee><Employee><Name>Cathy Poe</Name><Dept>BES</Dept></Employee></Employees>'). The XPath expression failed to execute; the reason was: internal xpath error. Check the detailed root cause described in the exception message text and verify that the XPath query is correct. }

From the error message although it is clear that the XML literal that is assigned to the XML element is not initialized, the question is how to initialize the XML literal variable?

The following is how the expression builder XML literal assignment looks;

To overcome the initialization issue, we should ensure that the XML fragment/literal that is assigned conforms to the schema along with valid namespace. Namespace declaration is the key here. The XML literal is treated as a variable by the SOA processor and hence would expect the proper namespace for initialization.

Review the XSD (schema) of the target to which you are trying to assign this XML literal. The sample schema used in this example is shown below;

All elements in this 'employees' schema are referenced with the targetNamespace ''. We have to qualify the XML literal elements with this namespace as shown in screenshot below;

This will ensure that the XML literal is successfully initialized and there should be no more 'Uninitialized Variable' errors at runtime.

One other thing which might be of interest with XML literal assignments is that the XML literal should always have a wrapper root element. For example if you have to assign values to the unbounded 'Employee' element as in our example, the XML literal should wrap/enclose all the 'Employee' elements with the 'Employees' root element. Otherwise there will be an error during parsing.

No comments:

Post a Comment