Search Chirayu Software Solutions Blog

Thursday, January 24, 2013

WCF Basis-2


  1. Service Contract
    This contract describes all the available operations that a client can perform on the service.
    .Net uses "System.ServiceModel" Name space to work with WCF services.

    ServiceContract attribute is used to define the service contract. We can apply this attribute on class or interface. ServiceContract attribute exposes a CLR interface (or a class) as a WCF contract.
    OperationContract attribute, is used to indicate explicitly which method is used to expose as part of WCF contract. We can apply OperationContract attribute only on methods, not on properties or indexers. 
    [ServiceContract] applies at the class or interface level. [OperatiContract] applies at the method level.
  2. Data ContractThis contract defines the data types that are passed into and out of the service.
    [DataContract] attribute is used at the custom data type definition level, i.e. at class or structure level.[DataMember] attribute is used for fields, properties, and events.
  3. Fault Contract
    This contract describes about the error raised by the services.
    [FaultContract(<<type of Exception/Fault>>)] attribute is used for defining the fault contracts.
  4. Message Contracts
    This contract provides the direct control over the SOAP message structure. This is useful in inter-operability cases and when there is an existing message format you have to comply with.
    [MessageContract] attribute is used to define a type as a Message type. [MessageHeader] attribute is used for those members of the type we want to make into SOAP headers[MessageBodyMember] attribute is used for those members we want to make into parts of the SOAP body of the message.
Post a Comment