The BPEL Management API API may be used to traverse the [scope tree] of a BPEL process instance. The nodes in the scope tree are runtime incarnations of the scopes appearing in the BPEL process definition and provide access to variables, correlation sets, and partner link values.
To obtain information about the scopes of a running process instance, one must first obtain a pointer to the root instance scope, and then iteratively retrieve the ScopeInstanceDocument(s).
With Beanshell, this would look like:
bsh % importCommands("/bpel");
bsh % pxe = pxeGetBMF();
bsh % print(pxe.listInstances());
<pmap:instance-info-list xmlns:pmap="http:>
<pmap:instance-info>
<pmap:iid>1</pmap:iid>
<pmap:pid>TaskManager.taskManager.BpelService</pmap:pid>
<pmap:root-scope siid="1" status="ACTIVE" name="__PROCESS_SCOPE:TaskManager" modelId="30"/>
<pmap:status>ACTIVE</pmap:status>
<pmap:dt-started>2006-01-11T23:10:52.791-05:00</pmap:dt-started>
<pmap:dt-last-active>2006-01-11T23:10:54.522-05:00</pmap:dt-last-active>
</pmap:instance-info>
</pmap:instance-info-list>
bsh % print(pxe.getScopeInfo("1"));
<pmap:scope-info xmlns:pmap="http:>
<pmap:siid>1</pmap:siid>
<pmap:name>__PROCESS_SCOPE:TaskManager</pmap:name>
<pmap:status>ACTIVE</pmap:status>
<pmap:children>
<pmap:child-ref siid="2" status="ACTIVE" name="CreateAndCompleteTask" modelId="57"/>
</pmap:children>
</pmap:scope-info>
bsh % print(pxe.getScopeInfo("2"));
<pmap:scope-info xmlns:pmap="http:>
<pmap:siid>2</pmap:siid>
<pmap:name>CreateAndCompleteTask</pmap:name>
<pmap:status>ACTIVE</pmap:status>
<pmap:parent-scope-ref siid="1" status="ACTIVE" name="__PROCESS_SCOPE:TaskManager" modelId="30"/>
<pmap:children/>
</pmap:scope-info>
bsh %