Professional Documents
Culture Documents
Shubhangi Shinde
What is WCF?
Windows Communication Foundation (Code named
Indigo) is a programming platform and runtime
system for building, configuring and deploying
network-distributed services.
It is the latest service oriented technology;
Interoperability is the fundamental characteristics
of WCF.
It is unified programming model provided in .Net
Framework 3.0. WCF is a combined features of Web
Service, Remoting, MSMQ and COM+. WCF provides
a common platform for all .NET communication.
Advantage
WCF is interoperable with other services when
compared to .Net Remoting,where the client and
service have to be .Net.
WCF services provide better reliability and security in
compared to ASMX web services.
In WCF, there is no need to make much change in
code for implementing the security model and
changing the binding. Small changes in the
configuration will make your requirements.
WCF has integrated logging mechanism, changing the
configuration file settings will provide this functionality.
In other technology developer has to write the code.
Disadvantage
Making right design for your
requirement is little bit difficult.
Advantages:
WCF is interoperable with other services when
compared to .Net Remoting where the client and
service have to be .Net.
WCF services provide better reliability andsecurity
incompared to ASMX web services.
In WCF, there is no need to make much change in
code for implementing the security model and
changing the binding. Instead it requires small
changes in theconfiguration.
WCF has integrated logging mechanism, changing
theconfigurationfile settings will provide this
functionality. In other technology developer has to
write the code.
WCF
ServiceContract and
OperationContract attributes are
used for defining WCF service.
WCF
Supports multi-threading by
using ServiceBehaviour class
WCF Architecture
Contracts Layer
It's an agreement between 2 machines defining the
terms and conditions for the messages to be exchanged.
Data Contract:Agreement between a service and a
client on the data that has to be exchanged. Also defines
what data structures and parameters to be used by
services in order to interact with the client.
Message Contract:Provides control over the SOAP
messages that are produced and consumed by WCF. It
also provides direct access to message header & body to
alter the SOAP message as per the requirement. Usually
developers don't pay much heed to message contracts in
normal scenarios, but there arises a need for message
contracts and their use when interoperability is important
or security needs to be maintained at the message level.
Messaging Layer
Messaging Layer is responsible for the
pattern of exchanges and its format.
WS-Security Channel: Enables message
security by implementing the WS-Security
specifications.
WS Reliable Messaging Channel:
Guarantees delivery of messages.
Encoders: Provides the number of encoders for
messages, such as Binary, XML, Text, MTOM.
HTTP Channel: States that HTTP is used to
deliver messages.
Features of WCF
Endpoint Support: An endpoint is basically a
resource or an entity in the network to which
messages can be sent. Endpoints are responsible
for the communication between a client and the
service. Elements of endpoints are:
Addresses to locate the service
Bindings to communicate with the service
Contracts to specify the functionalities to be
performed while communicating with the service.
Endpoint behaviors to specify the runtime behavior of
the service endpoint.
Bindings:
Facilitate the communication between the client
and the service. Specify the communication
protocol used to access the service. Below is the
list of pre-defined binding elements:
basicHttpBinding
wsHttpBinding
wsDualHttpBinding
wsFederationHttpBinding
netTcpBinding
netNamedPipeBinding
netMsmqBinding
msmqIntegrationBinding
netPeerTcpBinding
Contracts
Agreements between the client and
services. 3 basic contracts are:
Service Contracts: Defines the
methods of the service.
Data Contract: Defines the data types
used by the service methods.
Message Contract: Ability to control
the message headers during the
creation of the message.
WCF Contracts
Contracts arecategorized as behavioral
or structural.
Behavioral Contracts
ServiceContractattribute is used to mark
a type as Service Contract that contains
operations.
OperationContractattribute is used to
mark the operations that will be exposed.
FaultContractdefines what errors are
raised by the service being exposed.
Structural Contracts
DataContractattribute defines types
that will be moved between the parties.
MessageContractattribute define the
structure of the SOAP message.
WCFHosting
Web services that was used earlier was
hosted inside web server such as IIS
using http or wsHttp protocols. But WCF
(Windows Communication Foundation)
supports four types of hosting.
IIS
WAS (Windows process activation services)
Self-hosting
Windows services