Windows Communication Foundation: Unified Framework For Rapidly Building Service-Oriented Applications
Windows Communication Foundation: Unified Framework For Rapidly Building Service-Oriented Applications
ASMX
MSMQ WSE
COM+
.NET
(Enterprise
Remoting
Services)
UNDERSTANDING WCF
PRINCIPLES
Services and Clients
Message
Endpoints
Client Service
Endpoint
Client Service
Endpoints
Endpoint A B C
C B A Message A B C
Service Contract
Client and
Dispatcher Behaviors
Protocol(s) Protocol(s)
Encoder
Binding
Encoder
Transport Transport
Address
The what
CONTRACTS
Three Types of Contracts
Client Service
Request-Reply
Duplex (Dual)
One Way:
Datagram-style delivery
Request-Reply
Immediate Reply on same logical thread
Duplex
Reply “later” and on backchannel (callback-style)
What does your service do?
SERVICE CONTRACTS
Service Contract
using System.ServiceModel;
[ServiceContract]
public interface ICalculate
{
[OperationContract]
double Add( double a, double b);
[OperationContract]
double Subtract( double a, double b);
}
Service Contract: OneWay
[ServiceContract]
public interface IOneWayCalculator
{
[OperationContract(IsOneWay=true)]
void StoreProblem (ComplexProblem p);
}
Service Contract: Duplex Asymmetric
[ServiceContract(Session=true,
CallbackContract=typeof(ICalculatorResults)]
public interface ICalculatorProblems
{
[OperationContract(IsOneWay=true)]
void SolveProblem (ComplexProblem p);
}
DATA CONTRACTS
Data Contract
[DataContract]
public class ComplexNumber
{
[DataMember]
public double Real = 0.0D;
[DataMember]
public double Imaginary = 0.0D;
MESSAGE CONTRACTS
Message Contract
[MessageContract]
public class ComplexProblem
{
[MessageHeader]
public string operation;
[MessageBody]
public ComplexNumber n1;
[MessageBody]
public ComplexNumber n2;
[MessageBody]
public ComplexNumber solution;
// Constructors…
}
BINDINGS
Bindings & Binding Elements
Binding
HTTP Text Security Reliability TX
Custom
Custom Custom
Standard Bindings
Binding Interop Security Session TX Duplex
Client Service
A B C
C B A A B C
Be A B C
Be
Bindings Insert
Claims in
Messages
Behaviors
Implement
Security Gates
Feature Overview
Security
Client Service
A B C
C B A A B C
Be A B C
Be
Bindings Flow
Transactions
Behaviors
AutoEnlist and
AutoComplete
Bindings & Behaviors: Reliable Sessions
Client Service
A B C
C B A A B C
A B C
Bindings provide
Session and
Guarantees
Feature Overview
Reliability and Transactions
<bindings>
<basicProfileBinding>
<binding configurationName="Binding1"
hostnameComparisonMode="StrongWildcard"
transferTimeout="00:10:00"
maxMessageSize="65536"
messageEncoding="Text"
textEncoding="utf-8"
</binding>
</basicProfileBinding>
</bindings>
Custom Bindings
<bindings>
<customBinding>
<binding configurationName="Binding1">
<reliableSession bufferedMessagesQuota="32"
inactivityTimeout="00:10:00"
maxRetryCount="8"
ordered="true" />
<httpsTransport manualAddressing="false"
maxMessageSize="65536"
hostnameComparisonMode="StrongWildcard"/>
<textMessageEncoding maxReadPoolSize="64"
maxWritePoolSize="16"
messageVersion="Default"
encoding="utf-8" />
</binding>
</customBinding>
</bindings>
WCF Summary
Application
Messaging … Secure
Channel
Reliable
Channel
Text/XML
Encoder