简体   繁体   English

异步调用异步Web服务和异步调用同步Web服务有什么区别?

[英]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. 在异步模式下调用异步Web服务与在异步模式下调用同步Web服务之间的区别是什么。 I know that we can make async client for sycn web-service. 我知道我们可以为sycn web-service创建异步客户端。

Also is there any difference between the wsdl of sync vs async web-services ? 同步和异步Web服务的wsdl之间是否有任何区别?

Whether a web service can be described as synchronous or asynchronous depends on its API and hence its wsdl description. Web服务是否可以描述为同步或异步取决于其API以及其wsdl描述。

byte[] GetImage()

is a synchronous web service, while 是一个同步Web服务,而

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. 无论接口的细节如何,您的代码中的API调用都可以是同步的或异步的。 The actual web service calls are identical, it's just the way that your code interacts with network layer is different. 实际的Web服务调用是相同的,它只是您的代码与网络层交互的方式不同。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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