views:

1075

answers:

2

Hello everybody.

Following on from my previous question [link text][1] , I have a new problem.

I have a WPF application that will call a webservice. This web service will be called asynchronously by pushing the 'GO' button. The results may take 30 seconds or so to come back.

The issue is that I want the users to be able to click the 'GO' button as many times as they like to issue multiple requests.

What I dont want is for the client to open up a new connection to the webservice every time the button is pressed. The web service method is very simple:

invokeExecutionRequest(int executionID)

This method just returns a flag specfying success or failure of the execution request.

Now if possible I dont really want to queue these requests on the client, because a queue has already been established on the server. What is the most elegant way to achieve this?

+1  A: 

If you are using WCF for communication to your web service then you can control the connection open/close:

  1. Have one universal WCF connection (likely a global variable for the scope of the window)
  2. On each click of the Go button, check if the connection is open. If not open the connection, if it is then there is nothing to do.
  3. At some logical point (closing the window, doing some action that means Go wouldn't be clicked) close the connection.
Robert MacLean
Only problem is Im not using WCF, only a vanilla ASMX web service.
Alex
Sorry I worded my response badly but that's fine you can still use a WCF client to consume a SOAP web service. I'll update it to make it clearer.
Robert MacLean
A: 

I ended up just using BackGroundWorkers to fire off the web service requests. I think we are still openining multiple connections this way, however the number of requests is not large and we are considering changing our architecture so that one master request sent to the queue handler can initiate all other requests.

If I had more time to solve this I think WCF would have been the best option.

Alex