简体   繁体   中英

What is the difference between calling a asynchronous web service asynchronously and a synchronous webservice asynchronously?

What is the difference between calling an async web service in async mode versus calling a sync web service in async mode. I know that we can make async client for sycn web-service.

Also is there any difference between the wsdl of sync vs async web-services ?

Whether a web service can be described as synchronous or asynchronous depends on its API and hence its wsdl description.

byte[] GetImage()

is a synchronous web service, while

String StartImageDownload()
bool IsComplete(String token)
byte[] ReadData(String token)

describes an asynchronous interface.

No matter the details of the interface, your API calls from your code can be synchronous or asynchronous. The actual web service calls are identical, it's just the way that your code interacts with network layer is different. In a synchronous call, your calling thread blocks until the data comes back (or an error occurs). In an asynchronous call, you are notified of completion by a callback function. The actual mechanics can vary, but it might look something like:

ws.BeginGetImage(()=>{
    // this is invoked when the result has arrived
    byte[] data = ws.EndGetImage();
});
// execution arrives here before the data does - the previous call doesn't block

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM