[英]What is the difference between calling a asynchronous web service asynchronously and a synchronous webservice asynchronously?
在异步模式下调用异步Web服务与在异步模式下调用同步Web服务之间的区别是什么。 我知道我们可以为sycn web-service创建异步客户端。
同步和异步Web服务的wsdl之间是否有任何区别?
Web服务是否可以描述为同步或异步取决于其API以及其wsdl描述。
byte[] GetImage()
是一个同步Web服务,而
String StartImageDownload()
bool IsComplete(String token)
byte[] ReadData(String token)
描述了一个异步接口。
无论接口的细节如何,您的代码中的API调用都可以是同步的或异步的。 实际的Web服务调用是相同的,它只是您的代码与网络层交互的方式不同。 在同步调用中,调用线程将阻塞,直到数据返回(或发生错误)。 在异步调用中,通过回调函数通知您完成。 实际的机制可能会有所不同,但它可能看起来像:
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.