How do I access two separate methods of same class publishing multiple operations in a webservice with the state being maintained?
The answer to this question, put in the newsgroup, is making use of transaction techniques. What you are trying to say is that I would like to have operations being done successfully to indicate that my job is done.
Strictly speaking, the problem does not make a concrete sense in the realm of web services since multiple operations at an end-point may or may not be implemented by a single class. So, let me rephrase the problem so that it becomes technically correct w.r.t. Web Services.
How to do I share information across two operations in one or more web services?
There are multiple ways in which this can be achieved. For extreme cases, you may want to look into the WS-Transactions Web Services Transactions Specification @IBM
For simple cases as the original query above, one may want to use simple techniques of server side caching.
Let us assume that there are two classes involved in the complete transaction. One is WebService and another is InternalData. Let us also say that WebService class publishes two operations PerformTaskOne and PerformTaskTwo. And also that execution of PerformTaskTwo require some information of PerformTaskOne, and PerformTaskOne is to return DataOne.
What we do is a simple trick. Along with DataOne, we also return a Token when PerformTaskOne is executed. On the server side, we cache DataOne and InternalData with the key as Token. Note that the Token has to be generated randomly and must be unique for each visit to PerformTaskOne.
For PerformTaskTwo, apart from other inputs may be required, we also ask another parameter as Token.
In PerformTaskTwo, before starting execution, we rebuilt InternalData and DataOne using the Token from the cache.
Now that we have rebuilt the previous state, we can go ahead and complete our PerformTaskTwo.
We have put a small working demo at CodeProject. You may download the code and play with it. Please note that if the article gets approved, the URL may change. Please do vote for the article if you like it.