I also have a series of web based services which need to be called in order. I solved the issue with AJAX. The key is having a callback mechanism to perform the recursion, forcing synchronization.
Something like this ([jQuery][1])
function Recurse(params)
{
$.get(url,
{params},
function (data) {Recurse(data)}//callback does recursive call, also passes in variable data received from the web service
,'html');
}
You should check the API in question to see if it is a tree data structure like the [DOM][2]. Usually recursion is a good approach to iterate trees. If it's just a flat, linear API then a Queue/Stack can be used to push/pop your way through the API recursively.
Here's how to recursively iterate the DOM. Code for another Tree based API structure will be similar (javascript)
function walk(node, func) {
//walk the height of the tree
func(node);
node = node.firstChild;
while(node, func) {
//walk siblings
walk(node, func);
node = node.nextSibling;
}
}
[1]: http://api.jquery.com/jQuery.get/
[2]: http://en.wikipedia.org/wiki/Document_Object_Model