0% found this document useful (0 votes)
12 views26 pages

WCF Introduction

Uploaded by

prinsbhuva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views26 pages

WCF Introduction

Uploaded by

prinsbhuva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Windows Communication

Foundation
(WCF)
Introduction
• WCF is a unified programming model for
building service oriented application.
• It is used to build
– Secure
– Reliable
• applications that integrate across platforms
and interoperate with existing applications.
Features of WCF
• Service orientation
• Loosely coupled
• Interoperability
• Multiple message patterns
– Request-reply, one-way, duplex
• Publishing service metadata
– WSDL, XSD, WS-Policy
• Data Contract
– Classes
Features of WCF
• Security
– SSL, WS-SecureConversation
• Multiple Transports and Encodings
– HTTP, TCP, named Pipe
– Text, binary encoding (MTOM-Message Transmission
Optimization Mechanism)
• Reliable and Queued Messages
– WS-Reliable messaging and MSMQ
• Durable Messages
Features of WCF
• Transactions
– WS-AtomicTransaction, API, MS Distributed
Transaction Coordinator
• AJAX and REST support
– XML, JSON
• Extensibility
• Multiple service hosting options
– IIS, app-hosting
The Challenge
Radically Simplifying Distributed Application Development

Development of connected systems


remains costly and frustrating

Different programming models for different tasks


Need for security and reliable messaging
Interoperability with applications on other platforms
Productive service-oriented programming model needed
Windows Communication Foundation

Unified framework for


rapidly building
service-oriented applications
What Does WCF Replace?

ASMX

MSMQ WSE

COM+
(Enterprise .NET Remoting
Services)
UNDERSTANDING WCF PRINCIPLES
Services and Clients
Endpoints

Endpoint

Endpoint Endpoint
Address, Binding, Contract

Service

B
WCF Architecture

Contract
and
Behaviors

Protocol(s) Protocol(s)

Encoder
Binding
Encoder

Transport Transport
Address
CONTRACTS
Three Types of Contracts

Service Data Message


Contract Contract Contract
Allows defining
Defines Operations,
Defines Schema and application-specific
Behaviors and
headers and
Communication Versioning Strategies
unwrapped body
Shape
content

Allows control over


What does your What object data is
the SOAP structure of
service do used
messages
Ways to Talk
One Way

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);
}
What object data needs to flow back and forth?

DATA CONTRACTS
Data Contract
[DataContract]
public class ComplexNumber
{
[DataMember]
public double Real = 0.0D;
[DataMember]
public double Imaginary = 0.0D;

public ComplexNumber(double r, double i)


{
this.Real = r;
this.Imaginary = i;
}
}
Defines the mapping between the type and a SOAP envelope

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…
}
How?

BINDINGS
Bindings & Binding Elements

Binding
HTTP Text Security Reliability TX

Transport Encoders Protocol


TCP HTTP Text Security Reliability

MSMQ IPC Binary TX .NET

Custom
Custom Custom
Standard Bindings
Binding Interop Security Session TX Duplex

BasicHttpBinding BP 1.1 N, T N N n/a

WSHttpBinding WS M, T, X N, T, RS N, Yes n/a

WSDualHttpBinding WS M RS N, Yes Yes

WSFederationBinding Federation M N, RS N, Yes No

NetTcpBinding .NET T, M T ,RS N, Yes Yes

NetNamedPipeBinding .NET T T, N N, Yes Yes

NetPeerTcpBinding Peer T N N Yes

NetMsmqBinding .NET T, M, X N N, Yes No

MsmqIntegrationBinding MSMQ T N N, Yes n/a

N = None | T = Transport | M = Message | B = Both | RS = Reliable Sessions

You might also like