What is the difference between a standard void operation and a one-way operation?

 Posted by Senthilstayss on 3/19/2013 | Category: WCF Interview questions | Views: 4062 | Points: 40
Answer:

Suppose you have the following ServiceContract implemented:

[ServiceContract]
public interface IMyTask
{
[OperationContract(IsOneWay=false)]
void MyTask();
[OperationContract(IsOneWay = true)]
void MyTaskOneWay();
}

By invoking the two operations from the client side and capturing the HTTP message, we can get different response messages.

The normal void operation will return HTTP 200 status code and the complete SOAP Response in the body and the one-way operation will only return a HTTP 202 Accepted status header. This indicates that the one-way operation call gets finished as long as the
server side received the request, while the normal void operation will wait for the server side to execute and return the response data.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response