19
Jan

Getting rid of the “The assign activity of the to node query is returning zero node.” error in Oracle BPEL 11g

The BPELWS 1.1 specification mandates that when an assign is made, the “to” node must evaluate to exactly one node. If it evaluates to zero nodes, a bpws:selectionFailure must be thrown. This can become quite inconvenient as you have to pre-populate your XML fields to empty elements before assigning to them.

Let’s see it in practice.

Imagine you have the following XSD defining your input (process element) and output (processResponse).


And you have a BPEL service capable of returning the rest of the person’s info based on the informed ID. Your BPEL process should look like the following:


In the enrich assign we assign hard coded values to the name and age elements (it’s just a test...). We enrich the received person and copy it to the output as shown bellow:


The following SOAP request is made to the BPEL process:


You should be willing to receive a person as response containing name and age, however, you should receive an error similar to the one bellow:

faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure} messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage} parts: {{ summary=<summary>XPath query string returns zero node. The assign activity of the to node query is returning zero node. Either the to node data or the xpath query in the to node was invalid. According to BPEL4WS spec 1.1 section 14.3, verify the to node value at line number 76 in the BPEL source. </summary>}

The reason for such error is that the xpath /client:process/client:person/client:name did not evaluate to a single node but to zero.

One option would be to create the node empty with a “XML fragment” before assigning to it but it can become quite tedious. A better option is to use the Oracle extension property bpelx:insertMissingToData. To use such property, right click the copy line and select the insertMissingToData from the menu as shown bellow:



Do the same for the age assign and click Apply. Your assign should look like the one bellow:


Now, the BPEL process run should be successful, showing the bpelx:insertMissingToData helped a long way!



free b2evolution skin

Trackback address for this post

Trackback URL (right click and copy shortcut/link location)

1 comment

Comment from: Glaucio Guerra [Visitor]
*****
Glaucio GuerraTivemos esse problema aqui, pra resolver a origem passou a enviar sempre a info correta hehehee.

Mas a dica é boa!

Abs
01/23/12 @ 11:08

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
PoorExcellent
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)