Thursday, April 26, 2012

WCF - Questions - 1


  1. What are the contracts WCF provides?
    • ServiceContract
    • OperationContract
    • DataContract
    • MessageContract
    • FaultContract 
  2. How the contracts are implemented?
    • All the above contracts are implemented using Attributes
  3. What are the Message Exchange Patterns in WCF
    • Request-Response
    • Oneway
    • Duplex
  4. What is the different between Request-Response and Oneway Message exchange?
    • OneWay - fire and forget. Message is sent and no reply is received
      • HTTP status code: 202 - Accepted, protocol level ACKnowledgement, which indicates that the request has reached the service. That's it. No information after that.
    • Request-Response - Message is sent and reply is received
      • HTTP status code: 200 - OK
  5. What is Duplex Message Exchange Pattern? When do you really use it? any real time example?
    • Client sends arbitrary number of messages and it is received in any order at server.
  6. What is the first step in writing a service?
    • Define the Contract
  7. Can a method which is exposed via [OperationContract(IsOneWay=true)], return values?
    • No. While hosting the service exception will be thrown, at runtime.
    • Unhandled Exception: System.InvalidOperationException: Operations marked with IsOneWay=true must not declare output parameters, by-reference parameters or return values.
  8. What Serialization engine WCF uses?
    • DataContractSerializer - to serialize and de-serialize data.