Serializing web service access

I've got a web service (created with the Agile Platform) running locally that provides access to an external service for retrieving data (unfortunately not a web service itself). The problem is that the external service needs a strict sequence of login -> retrieve -> logoff, while each of these commands are sent separately in a request-response fashion. So if two local clients access the web service at nearly the same time, the sequence is messed up, as two instances of the web service are firing requests simultaneously. So my question is whether there is some standardized way of serializing access to a web service, or do I need to code something myself?
Hi Killian,

What you seem to be describing could be fixed by the following (and this is just a suggestion, probably people with different experiences have better ways to doing it):

- When you Login, generate a GUID that you return as a response;
- After that do send the GUID in your subsequent requests, so that the Retrieve command knows which request it belongs to;

Would this solve your problem? It might not be the simplest way to do it, but if I got your question right, it should address it for the most part...

Let us know how it goes!

Regards, and have a great weekend.

Paulo Tavares
Hi Paulo,

I think you did not fully comprehend the situation, so I'll try to reexplain:

The webservice is built by us, so we control it and the way it communicates with the application. The external service is not controlled by us, so its interface is fixed (it is a http/URL driven request/response system, that internally keeps track of request status by IP address). The external service requires us to send it a sequence of commands as parameters in the URL, to which it responds with an XML-formatted webpage, like this:

reply: <respons><command><name>logon</name></command><status><code>0</code></status></respons>

reply: <respons><command><name>lookup</name></command><status><code>0</code></status><result><streetname>Dorpsstraat</streetname><location>Achterkarspelerberg</location></result></respons>


These commands, from logon through inquiry to logoff must be performed in sequence. If two instances of the webservice try to access the external service at the same time, errors occur, e.g. the logon will fail with an "already logon" respons, and replies to lookup requests could get intermingled. Therefore all request made to the webservice must be serialized for accessing the external service.

I hope this makes it a bit clearer,

Hi Kilian,
from what i've understood, if you cannot control that webservice, maybe if you could do some control on requests, something like a lock/unlock method and a queue stack.
When you call the webservice, lock the following requests and put them on a queue, as soon as you finish, unlock it and process to the next request in queue.
Again, ensuring i have understood your problem this would be my way to do it.
Give some feedback about this idea!
Have a nice weekend,
Miguel Antunes
Hi Miguel,

I think indeed that's what I need to do. Can you give me some pointers as to what's the easiest way to lock/unlock a request stack, and how you would store the request stack?

Thanks in advance,