Skip to main content

Posts

Showing posts from October, 2014

Introduction to WCF

WCF stands for Windows Communication Foundation. It is Microsoft's latest technology that enables applications in a distributed environment to communicate with each other.WCF is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing. WCF is an umbrella technology that covers ASMX web services, .NET remoting, WSE, Enterprise Service, and System.Messaging. It is designed to offer a manageable approach to distributed computing, broad interoperability, and direct support for service orientation. WCF supports many styles of distributed application development by providing a layered architecture. ABC of Windows Communication Foundation What are the ABCs of WCF? "ABC" stands for address, binding and contract. Address (Where) It specifies the location of the service means, where the service is hosted. The

Understanding various types of WCF bindings

WCF binding is a set of binding elements and each element specify, how the service and client will communicates with each other's. Each binding must have at least one transport element and one message encoding element. Different types of WCF bindings WCF has a couple of built in bindings which are designed to fulfill some specific need. You can also define your own custom binding in WCF to fulfill your need. All built in bindings are defined in the System.ServiceModel Namespace. Here is the list of 10 built in bindings in WCF which we commonly used: Basic binding This binding is provided by the BasicHttpBinding class. It is designed to expose a WCF service as an ASMX web service, so that old clients (which are still using ASMX web service) can consume new service. By default, it uses Http protocol for transport and encodes the message in UTF - 8 text for-mat. You can also use Https with this binding. Web binding This binding is provided by the WebHttpBinding class.

Understanding different types of WCF Contracts

WCF contract specify the service and its operations. WCF has five types of contracts: service contract, operation contract, data contract, message contract and fault contract. Service Contract A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service. [ ServiceContract ] int erface IMyContract { [ OperationContract ] string MyMethod (); }   class MyService : IMyContract { public string MyMethod () { return "Hello World" ; } } Operation Contract An operation contract is defined within a service contract. It defines the parameters and return type of an operation. An operation contract can also defines operation-level settings, like as the transaction flow of the op-eration, the directions of the

Understanding Message Exchange Patterns (MEP) in WCF

Message Exchange Patterns describes the way of communication between Client and Server means how client and server would be exchange messages to each other. There are three types of message exchange patterns. Request-Reply In this communication, client sends the message to the service and waits for reply from the service. Within a ReceiveTimeout period (default timeout is one minute), if the service doesn't respond to the client then the client will receive a TimeoutException. In this pattern, client waits for the reply mes-sage, even if the service operation's return type is void. This the by default message exchange pattern in WCF. All WCF bindings except MSMQ-based bindings supports this pattern. [ ServiceContract ] public int erface RequestReplyService { [ OperationContract ] string GetData ( int value );   [ OperationContract ( IsOneWay = false )] void SaveData ( string value ); } To define this pattern, you can set IsOneWay property to f