I’m writing a Java webservice with CXF. I have the following problem: A client calls a method from the webservice. The webservice has to do two things in parallel and starts two threads. One of the threads needs some additional information from the client. It is not possible to add this information when calling the webservice method, because it is dependent from the calculation done in the webservice. I cannot redesign the webservice becuase it is part of a course assignement and the assignements states that I have to do it this way. I want to pause the thread and notify it when the client delivers the additional information. Unfortunately it is not possible in Java to notify a particular thread. I can’t find any other way to solve my problem.
Has anybody a suggestion?
I’ve edited my answer after thinking about this some more.
You have a fairly complex architecture and if your client requires information from the server in order to complete the request then I think you need to publish one or more ‘helper’ methods.
For example, you could publish (without all the Web Service annotation):
The client would then call
validateMyData()as many times as it liked, until it knew it had complete information. The server can modify (through calculation, database look-up, or whatever) the variables inMyDatain order to help complete the information and pass it back to the client (for updating the UI, if there is one).Once the information is complete the client can then call
processMyData()to process the complete request.This has the advantage that the server methods can be implemented without the need for background threads as they should be able to do their thing using the request-thread supplied by the server environment.
The only caveat to this is if
MyDatacan get very large and you don’t want to keep passing it back and forth between client and server. In that case you would need to come up with a smaller class that just contains the changes the server wants to make toMyDataand exclude data that doesn’t need correcting.