WCF : Stands For
Window Communication Foundation
How to make
changes to WCF Service without breaking
client ?
Use Name
property ServiceContract Attribute
Serialization is
the process of converting an Object into an XML
Deserialization
is the process of converting XML into Object
By Default WCF Uses : DataContractSerialization
If you expect the service to accept and return inherited
types then use KnowTypesAttributes
With DataContract we have very limited control over SOAP XML
Request and response but MessageContracts for full control over the generated
XML SOAP messages
MessageContracts only
if there is reason to tweak the structure of SOAP XML
Ex : SOAP Header, User credentials and license keys
ExtensionDataObject
: Use IExtensionDataObject to preserve unkown elements during serialization and
deserialization
When an exception occurs in wcf service serializes the
exception into a SOAP Fault and then send to client
For debugging purpose IncludeExceptionDetailsInfaults
settings.
SOAP Faults are
in XML Format contains : Fault code, Fault Reason and Detail elements
Endpoint consists of
3 things :
A - Address ( where the service available)
B - Binding (how
the client needs to communicate with service)
C - Contract (what the service can do)
Binding that you
choose determines the following
1.
Transport Protocol (Http,tcp,Namepipes …)
2.
Message Encoding (text/XML, Binary)
3.
Protocols (reliable messaging transaction
support)
Hosting WCF Service :
·
Self hosting :
using window app
·
Window service :
using window service
·
Internet Information service : only Http
bindings
·
Window activation service : it supports all
bindings including Non – Http
Message Exchange
Patterns in wcf
How client and wcf service exchange messages
1.
Request-reply
: client sends a message to wcf service
and the waits for reply
2.
One-way
: client make a call to the service method,
but does not wait for response
3.
Duplex :
can be implemented using Request/Reply or OneWay operations
Default Message encoding mechanisms in wcf is text which is
Base64 encodes
The preferred approach to send large binary messages in wcf
is to use MTOM
Instancing Modes in
WCF :
1.
PerCall :
new instance of service object is created for every request irrespective
of whether the request comes from the same client or different client
2.
Persession : A new instance of the service
object is created for each new client session and maintained for the duration
of that session.
3.
Single : A single instance of the service object
is created and handles all request for the lifetime of the application.
Multiple threads executing the application code
simultaneously is called as concurrency.
The default concurrency mode in wcf is Single Concurrency Mode
WCF handles client request concurrently or not depends on 3
things
·
Service instance context mode
·
Service concurrency mode
·
Binding support
Multiple Concurrency
mode an exclusivelock is not acquired on the service instance. This means
multiple threads are allowed to access the service instance simultaneously and
we get better throughput
Reentrant Concurrency
mode allows the WCF service to issue callbacks to the client application
Thoughput : amount of
work done in a given time
WCF Throttling : Throttling settings also influence the
throughput of a wcf service and can be specified either in config or in code.
·
MaxConcurrentCalls=
·
MaxConcurrentInstancs=
·
MaxConcurrentSessions=

