Can you show me an example in how to write a Message Contract in WCF ?

 Posted by Akiii on 4/4/2012 | Category: WCF Interview questions | Views: 2868 | Points: 40


public class EmployeeDetails
public int ID;

public string First_Name;

public string Last_Name;

Message contract can be applied to type using MessageContract attribute as shown above. We can add custom header and custom body by using MessageHeader and MessageBodyMember attribute respectively.

When EmployeeDetails type in the service operation is used as parameter then WCF will add an extra header call 'ID' to the SOAP envelope. It also add First_Name, Last_Name as an extra member to the SOAP Body.

Thanks and Regards

| Alert Moderator 

Comments or Responses

Login to post response