Wednesday, July 12, 2017

Hosting WCF in IIS with WAS enabled

By default IIS  support only http protocol, To support non http protocol we have to install Windows Communication Foundation Non-HTTP Activation and WAS(Windows Process Activation). Windows 7 and above version of Windows along with IIS7 support WAS.

After installing you need to enable net.tcp protocol for WCF application hosted in IIS and now you will be able to use nettcp binding.

Message Exchange Pattern in WCF


1. Request-Reply
2. One Way
3. Duplex


Request-Reply

Request-Reply is the default pattern. In this pattern client send a message to WCF service and then wait for a reply even return type is void. Client wait to complete the WCF operation.

Except MSMQ all binding support this pattern.

In this pattern fault and exception get reported to client immediately.
If IsOneWay=false than it is Request-Reply.

One Way

In one way client does not except any response nor WCF send any reply to client. And exception also don't get reported to client. return type should be void in one way call.not out,ref param allowed.

If service has received a call when it was serving other request than the current request is queue but it it does not block the client.

One way call is different form asynchronous call.  In WCF there is a server queue limit if number of waiting  one way call is exceeded the limit than client wait for that.


Duplex

Duplex can be implemented using Request-Reply or One Way operation.

If we want to send some message from WCF service between processing in a long function than we use duplex. We use CallbackContract delegate for this.

Syntax is 

[ServiceContract (CallbackContract= typeof(IReportServiceCallback)]
public interface IReportService
{

  void DoProcessReport();
}

public interface IReportServiceCallback
{

  void Progress(int percentage);

}

Method can be called using OperationContext.

[ServiceBehavior(ConcurrencyMode = ConcuurencyMode.reentrant)]
public ReportService : IReportService
{

public void ProcessReport()
{

OperationContext.Current.GetCallbackChannel().Progress(iValue);

}
}

If we want to use Dupex  with Request Reply operation than we need to set attribute ConcurrencyMode = ConcurrencyMode.Reentrant in service and at client we have to use CallbackBehaior(UseSynchronizationContext = false)

To implement Duplex wiht One Way operation we haven't need any attribute.

No comments:

Followers

Link