I've been hacking on a BPEL-process between the labs (during the lectures that is...). The scenario is that I'm trying to convert the end-to-end lab we did yesterday morning to a "pure" BPEL-process in order to get rid of the Java components that were included in that lab, and of course to learn the process modelling tool as well.
The lab setup was a simple "customer has a portfolio with N different stocks" and there's a stock quote service which gets called to calculate the total value of a given users portfolio.
So, in order to call the quote service once for each stock I created a simple while loop activity, which then of course needed a loop condition. That's when I got into Xpath. The customer SDO looks something like this:
<customer>
<name>Foo Bar</name>
<stocks>
<symbol>IBM</ibm>
<numberofshares>200</numberofshares>
</stocks>
<stocks>
<symbol>XYZ</symbol>
<numberofshares>50</numberofshares>
</stocks>
</customer>
So I happily tried to get a count of the stocks elements using the Xpath expression count(/customer/stocks)....which didn't work. Here I learned the first really useful thing, don't try to get a hold of the actual SDO using the debugger, it'll only give you the nice view of the object (quite obvious when you think about it). The quickest way (that I know of) is to put a Java snippet activity that dumps the serialized SDO representation to stdout. This showed that it's much better to do count(//customer/stocks) since the SDO actually adds a top level element and my personal guess is that certain changes/refactorings in your infterfaces or import/export might change this top level element, so depending on it in your Xpath expression may be unwise.
Regarding scoping in BPEL I got bitten by the fact that my loop variables were declared on the while activity and hence got re-initialiyed for every iteration resulting in an infinite loop. Declaring an outer scope and putting the variables there seems to have solved the problem but I've not had time to test it.