Professional Documents
Culture Documents
Service-oriented architecture (SOA) is a flexible set of design principles used during the
phases of systems development and integration in computing. A system based on a SOA
will package functionality as a suite of interoperable services that can be used within
multiple separate systems from several business domains.
SOA also generally provides a way for consumers of services, such as web-based
applications, to be aware of available SOA-based services. For example, several disparate
departments within a company may develop and deploy SOA services in different
implementation languages; their respective clients will benefit from a well understood,
well defined interface to access them. XML is commonly used for interfacing with SOA
services, though this is not required.
SOA P RINCIPLES
WCF is programming model that enables developer to build service solutions that are
reliable and secure, and even transacted. It simplified development of connected
application
WCF A RCHITECTURE
At the heart of WCF is a layered architecture that supports a lot of the distributed
application development style.
WCF Contracts
Contracts in WCF provide interoperability they need to communicate with the client. It is through
contracts that client and service agrees as to the types of operation and structure they will use
during the period they are communicating back and forth.
1. Service Contract: Defines the methods of a service, i.e. what operations are available on the
endpoint to the client
2. Data Contract: Defines data types used by the available service methods, i.e. defines which
data types are passed to and from the service. WCF defines implicit contracts for build-in
types such as int and string, but we can easily define explicit opt-in data contracts for
custom types.
3. Message Contract: A message contract provides additional control over the data contract in
that it controls the SOAP message sent and received by the service. In other words, it lets us
customized type formatting of parameters in SOAP message.
4. Fault Contract: Defines which errors are raised by the service and how the service handles
and propagates errors to its client.
Service Runtime
The service runtime layer is the layer that specifies and managed the behaviours of the service that
occur during service operation or service runtime (thus “Service Runtime Behaviours”).
Following are the list of various behaviours managed by the service runtime layer
The messaging layer defines what formats and data exchange patterns can be used during service
communication.
There are multiple aspects of communication with any given service and there are many
communication patterns. Messages can follow synchronous request-reply or asynchronous fired-
and-forgot pattern, messages can be bidirectional, and message can be delivered immediately or
queued. To simplify these choices and make them manageable WCF groups together sets of
communication aspects in Bindings.
Basic Binding:
offered by the BasicHttpBinding class, it designs to expose WCF service as a legacy ASMX
web service so that old client can work with new services.
TCP Binding:
offered by the NetTcpBindingclass, it uses TCP for cross machine communication in the
intranet. It support variety of features including reliability, transaction and security and is
optimized for WCF-to-WCF communication
IPC Binding:
offered by NetNamePipeBinding class, it uses name pipe as transport for same machine
communication. It’s most secure binding since it cannot accept calls from outside the
machine.
Web Service (WS) Binding:
Offered by WSHttpBinding class, the WS binding uses HTTP or HTTPS for transport and offer
a variety of features such as, reliability, transaction and security over the internet.
MSMQ Binding:
Offered by NetMsmqBinding class, it uses MSMQ for transport and offers supports for
disconnected queued calls.
WS dual Binding:
Offered by the WSDualHttpBinding class, this is similar WS Binding except it also supports
bidirectional duplex communication form the service to the client.
Each of the frequently used bindings uses a different transport schema and encoding as listed
The Activation and Hosting layer provides different options in which a service can be started as well
as can be hosted. Service can be hosted within the context of other application or they can be self-
hosted.
SERVICE CONTRACT IN WCF
[ServiceContract]
Public interface IService1
{
[OperationContract]
String GetData (int value);
SERVICECONTRACT ATTRIBUTE
Classes/Interface
- independent of visibility
- opt-in Model
OPERATIONCONTRACT ATTRIBUTE
Methods only
- No properties/indexes/events
- Independent of visibility
- opt-in Model
Default operation name is the method name
Can provide different name all names have to be unique
[OperationContract (Name="GetStringData")]
String GetData (int value);
OPERATOR OVERLOADING
Cannot overload operations in WCF
Can manually enables overloading
- use Name property in OperationContract
- need to rework in Client Proxy