views:

22

answers:

1

Are web service calls synchronous or asynchronous by default? How is synchronicity determined, by the service or by the client?

I have code similar to the following:

try
{
    string result = MakeWebServiceCall_1(); // this is a third party webservice
    MakeWebServiceCall_2(result); // another webservice which must happen *after* the first one is complete
}
catch()
{
    SetStatus(Status.Error); // this calls my own stored procedure
    throw;
}
SetStatus(Status.Sucess);

In the above, SetStatus is writing to the same tables that the third party web services read from. If I change the status before both web service calls have completed, it's going to make a big mess and I'm going to get fired. How do I know/ensure that the webservice calls are synchronous?

+2  A: 

According to MSDN when you add a reference to a Web Service it will implement methods to call the Web Service both synchronously and asynchronously in the proxy class. You just need to make sure you call the right one.

After you have located an XML Web service for your application to access by using the Add Web Reference dialog box, clicking the Add Reference button will instruct Visual Studio to download the service description to the local machine and then generate a proxy class for the chosen XML Web service. The proxy class will contain methods for calling each exposed XML Web service method both synchronously and asynchronously. Source

w69rdy
+1 for knowing how to use google/bing/etc ;)
TheGeekYouNeed
@Geek if that's supposed to be a dig at me, try googling "how to call webservice synchronously" and see how useless all the results are. I never post anything on SO without spending a good time trying to figure it out myself.
fearofawhackplanet