Escolar Documentos
Profissional Documentos
Cultura Documentos
WCF
indigoo.com
WINDOWS COMMUNICATION
FOUNDATION
OVERVIEW OF WCF, MICROSOFTS UNIFIED
COMMUNICATION FRAMEWORK FOR .NET APPLICATIONS
Peter R. Egli
INDIGOO.COM
1/24
Rev. 2.20
indigoo.com
Contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
What is WCF?
WCFs ABC
WCF model
The 4 layers of the WCF architecture
WCF programming model
WCF address (the 'A' in 'ABC')
WCF binding (the 'B' in 'ABC')
WCF contract (the 'C' in 'ABC')
WCF service hosting
Steps for creating and running a WCF service
WCF configuration versus programming
WCF and SOAP messages
2/24
Rev. 2.20
indigoo.com
WCF is the current and future standard for distributed .Net applications.
3/24
Rev. 2.20
indigoo.com
WCF service
(.Net program)
Message-oriented
communication
WCF
WCF
.Net FW
MSMQ
TCP/IP
DCOM
.Net FW
WS
HTTP
MSMQ
TCP/IP
DCOM
WS
HTTP
4/24
Rev. 2.20
indigoo.com
Server
WCF
MSMQ
WCF
MSMQ
MSMQ
Client
Web service
WCF
WCF
HTTP
HTTP
Client
Service proc.
WCF
WCF
Pipe
Pipe
5/24
Rev. 2.20
indigoo.com
2. WCFs ABC
The core concept of WCF is a service that is provided on an endpoint and accessible over the
network through a transport protocol.
Thus a WCF service is defined by ABC:
A = Address:
Where is the service available (the endpoint's URI in case of a web service).
B = Binding:
How can the service be accessed (what transport protocol is used).
C = Contract:
What does the service interface look like (operations, data-types).
The mapping of the ABCs to WSDL:
WCF term
Question
WSDL element
A (Address)
Where
B (Binding)
How
<binding>
C (Contract)
What
<types>
<interface>
6/24
Rev. 2.20
indigoo.com
Self-hosted
Service host
Host
Instancing
model
has
Single
Session
Per call
Message
contract
implements
WCF client
1
has
*
1
has
*
uses
Endpoint
has
Data
contract
Infrastructure
endpoint
has
Provides service
metadata
has
Address
as URI
Communication stack
Security
protocol
Channel
Message
encoding
Channel
Transport
protocol
Binding elements
Operation
contract
uses
corresponds to
Appl.
endpoint
Channel
contains
Endpoint
1
Message
Service
contract
WCF service
Text/
XML
MTOM
HTTP
TCP
Binary
has
MSMQ
Request
reply
WSDL
Message
exchange
pattern
Oneway
Duplex
7/24
Rev. 2.20
indigoo.com
Endpoint:
WCF client and service use an endpoint to connect to each other.
Application endpoint: Endpoint on which an application service is exposed / offered.
Infrastructure endpoint: Part of WCF system to offer metadata of an application service.
Message:
Unit of data exchange between WCF client and service. WCF is strictly message-based.
Address:
Physical address comprising hostname, port number and service name (=URI). The application
service is accessible under such an address.
Example.: http://localhost:8000/HSZ-TWSMW/DateTimeService
Peter R. Egli 2015
8/24
Rev. 2.20
indigoo.com
9/24
Rev. 2.20
indigoo.com
10/24
Rev. 2.20
indigoo.com
Message
Contract
Service
Contract
Policy
and
Binding
Service Runtime
Throttling
Behavior
Error
Behavior
Transaction
Behavior
Metadata
Behavior
Dispatch
Behavior
Instance
Behavior
Concurrency
Behavior
Message
Inspection
Parameter
Filtering
Messaging
WS Reliable
Messaging
Channel
WS Security
Channel
HTTP
Channel
TCP
Channel
Transaction
Flow
Channel
Encoders:
Binary/MTOM
/Text/XML
NamedPipe
Channel
MSMQ
Channel
.exe
(selfhosting)
Windows
Services
COM+
indigoo.com
A (Address)
System.Uri
B (Binding)
System.ServiceModel
E.g.
BasicHttpBinding (SOAP, non-secure, interoperable, non-duplex)
WebHttpBinding (REST-style binding, i.e. non-SOAP)
C (Contract)
E (Endpoint)
System.ServiceModel.ServiceEndpoint
12/24
Rev. 2.20
indigoo.com
Scheme /
protocol
Machine
Port #
address (IP or DNS)
URI
Reference properties and parameters
Security settings
13/24
Rev. 2.20
indigoo.com
Encoder +
Security
Encoding and securing of
application messages.
Encoder +
Security
Transport connection and protocol
14/24
Rev. 2.20
indigoo.com
Interoperability
Security
Session
Transactions
Duplex
Encoding
BasicHttpBinding
N, T, M, m
No
Text, MTOM
WSHttpBinding
WS-* standards
T, M, m
N, RS, SS
N, Yes
No
Text, MTOM
WSDualHttpBinding
WS-* standards
M, m
RS, SS
N, Yes
Yes
Text, MTOM
WSFederationHttpBinding
WS-Federation
N, M, m
RS, SS
N, Yes
No
Text, MTOM
NetTcpBinding
.NET
T, M, m, N
TS, RS, SS
N, Yes
Yes
Binary
NetNamedPipeBinding
.NET
T, N
N, TS
N, Yes
Yes
Binary
NetMsmqBinding
.NET (WCF)
M, T, N
N, TS
N, Yes
No
Binary
NetPeerTcpBinding
.NET
Yes
N/A
MsmqIntegrationBinding
MSMQ
N, Yes
No
MSMQ
BasicHttpContextBinding
N, T, M, m
No
Text, MTOM
NetTcpContextBinding
.NET
N, T, M, m
T, RS, SS
N, Yes
Yes
Binary
WSHttpContextBinding
WS-* standards
T, M, m
N, RS, SS
N, Yes
No
Text, MTOM
WebHttpBinding
HTTP (REST)
No
POX
None
Transport
Message
mixed
RS:
SS:
TS:
15/24
Rev. 2.20
indigoo.com
Exportable contract
description
SvcUtil.exe
.Net C#
code
Programmatic
definition of contract
16/24
Rev. 2.20
indigoo.com
17/24
Rev. 2.20
indigoo.com
18/24
Rev. 2.20
indigoo.com
19/24
Rev. 2.20
indigoo.com
20/24
Rev. 2.20
indigoo.com
Finally the service can be started in the WCF self-hosting environment as follows:
selfHost.Open();
21/24
Rev. 2.20
indigoo.com
22/24
Rev. 2.20
indigoo.com
23/24
Rev. 2.20
indigoo.com
24/24
Rev. 2.20