问题
I involved my self within a bet, our feud is about - Async WebServices and the other stuff i mentioned above.
I am thinking logically web service by default is sync, the other said that it is not correct. Who is right or wrong can any one explain it to me?
Thanks in advance.
回答1:
All of them are by default synchronous but you can write all of them asynchronously and you can call all of them asynchronously. You should always differ between synchronous/asynchronous call and between synchronous/asynchronous execution.
Calls
- Synchronous - client calls the service/page and hangs on until the service/page returns the response.
- Asynchronous - client calls the service/page and can continue in work. Client is usually notified by some event (or it can poll the result) that response has arrived. In ASPX this is typical callback or AJAX call.
Execution:
- Synchronous - service/page receives the call and process it. Every external processing (file access, calling other services, calling database) is done synchronously and the service/page block the executing thread for the whole duration of the request processing.
- Asynchronous - service/page receives the call, prepares external processing and executes it asynchronously. Processing thread is returned back to thread pool and can server other requests in the meanwhile. Once external processing ends service/page execution is again scheduled to receive a thread from thread pool and it finishes execution and returns response. This is usually only need on high traffic pages/services with intensive external communication.
These two types of asynchronous processing are completely independent. You can have asynchronous calls to synchronous services and any other combination.
来源:https://stackoverflow.com/questions/6213423/is-asmx-webservice-or-wcf-or-aspx-pages-are-async-by-default