1. FaultContract
2. MessageContract
3. Duplex
4. Hosting
5. Transactions
6. Session management
7. Polymorphism
8. tcpbinding
- FaultContract
 
- FaultContract helps to do Exception handling in WCF service
 - convert .NET
      exceptions into Fault
 - Service client does not have to be built by using .NET framework
 - SOAP protocol provides a standard mechanism to report faults within SOAP message.
 - So client can recognize it as fault from the SOAP message
 
- Types of error:
 - Domain error: (eg: NoFunds)
 - Technical error: (Expected and unexpected technical errors(eg: divide by zero))
 - These errors should be mapped to one of the defined faults.
 - Structure of SOAP fault is an XML representation of error information.
 - SOAP fault contains
 
§
Code 
§
Reason
§
Detail

- Using Fault in service
 

- Typed and Untyped fault
 


- Handling service Exceptions at client
 

- MessageContract
 - WCF allow you to control SOAP message structure with MessageContract
 - You can modify message by
 
·  
Define custom header
·  
Adding elements to SOAP body
·  
Altering namespace in SOAP body
- Message exchange
     patterns
 - Request response
 - Simplex (one way)
 - Duplex
 
·        
Request 
response
o  default message exchange pattern in WCF
o Synchronous
remote procedure call(RPC)
·        
One way
o Client
send message to service, but service does not send message back
o Return
type of one-way operation must be void
o Drawback-
no way to detect operation failure
o Advantage
– performance – as client does not have to wait for response
[OperationContract(IsOneWay = true)]
void MakeDeposit(string
account, decimal amount);
·        
Duplex
o This
pattern consists of 2 separate contracts
o One
contract implemented by service, other by client
o 2
one-way messages

- Polymorphism 
 
·        
Operation
overloading - Operation with same name, but different parameters
·        
Use Name
property in OperationContract.
[OperationContract(Name="DepositLocalCurrency")]
void Deposit(string account, decimal
amount);
[OperationContract(Name="DepositAnyCurrency")]
void Deposit(string account, Currency
amount);
- Transactions
 
@server:
- Select a transaction aware binding
 
o NetTcpBinding
o NetNamedPipeBinding
o wsHttpBinding
o wsDualHttpBinding
o wsFederationHttpBinding
- Enable TransactionFlow property of binding in configuration file.
 
         transactionProtocol="WSAtomicTransactionOctober2004"/>
- Transactional requirement of operation
 

@client
1.       Enable
transaction flow on binding in configuration file.

2.       Use
TransactionScope block at client code
