You must Sign In to post a response.
  • Category: .NET

    What is use of message contract? Any body has used in their project?

    What is use of message contract? Any body has used in their project?
    Please give example?
  • #763626
    Hi,

    In some critical issues, we require to control SOAP message format, so to customize our requirement as per requirement we can use MessageContract in WCF.

    If you want to know more about this then Google it and read few articles for the same.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #763628
    Thank u.

  • #763637
    Hi rajesh

    Wcf service uses SOAP standards for communication between client and service.
    Simple Object Access Protocol is a message format which has name, Header and body.
    This is the default message format for WCF , but if we want our own customized message to be sent along with SOAP message we make use of message contract attribute.

    [MessageContract] //message contract attribute
    public class sampleClass
    {
    [MessageHeader]
    public string name;
    [MessageBodyMember]
    public string email;
    [MessageBodyMember]
    public string address;
    [MessageBodyMember]
    public int mobile;
    }

    Sridhar Thota.
    Editor: DNS Forum.

  • #763646
    Hai Rajesh,
    When there is a need to format the message(SOAP) which is the default communication between the client and service, we need to create the Message Contract in WCF.
    Lets say, if we want to add some additional information to the message header or message body, we can create the message contract with these so that as a result, it will add-up with the XML SOAP message and can be extracted at the client or send to the service.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments