in Education by
What is Message Contract in WCF?

1 Answer

0 votes
by

A Message Contract is used to control the structure of a message body and serialization process. It is also used to send / access information in SOAP headers. By default WCF takes care of creating SOAP messages according to service DataContracts and OperationContracts.

SOAP

A MessageContract controls the structure of a message body and serialization process. A MessageContract can be typed or untyped and are useful in interoperability cases and when there is an existing message format we must comply with.

The SOAP header is implemented in the namespace system.web.services.protocol.

  1. [MessageContract]  
  2. public class AutherRequest  
  3. {  
  4.    public string AutherId;  
  5. }  

Message Header

A Message Header is applied to a member of a message contract to declare the member within the message header.

  1. [MessageContract]  
  2. public class AutherRequest  
  3. {  
  4.    [MessageHeader]  
  5.    public string AutherId;  
  6. }  

Message Body Member

A Message Body Member is applied to the member of a message contract to declare the members within the message body.

  1. [MessageContract]  
  2. public class AuthorResponse  
  3. {  
  4.     [MessageBodyMember]  
  5.     public Auther Obj;  
  6. }  

Related questions

0 votes
    What is Fault Contract in WCF?...
asked Apr 2, 2021 in Education by JackTerrance
0 votes
    What is Duplex in WCF? Explain also Message Exchange Pattern?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What Message Exchange Patterns (MEPs) supported by WCF? Explain each of them briefly....
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Information cards in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Instance Management in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What you understand by Fault Exception in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is WCF Messaging Layer?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Method overloading in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is MSMQ in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    Explain bindings in WCF with description?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    Explain briefly different Instance Modes in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Transport level security in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is SOA, and Messages in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Streaming in WCF?...
asked Apr 3, 2021 in Education by JackTerrance
0 votes
    What is Security Implementation in WCF? How many are there?...
asked Apr 3, 2021 in Education by JackTerrance
...