Wcf Message Contract

in IServcie1 :

[ServiceContract]
public interface IService1
{
[OperationContract]
void Display(Employee empobj);

[OperationContract]
Employee ModifyEmployeeDetails(Employee empobj);
}

[MessageContract]
public class Employee
{
[MessageHeader]
public int empid { get; set; }

[MessageBodyMember(ProtectionLevel = System.Net.Security.ProtectionLevel.Sign)]
public string  empname { get; set; }

}

In Service1 Class :

public class Service1 : IService1
{

#region IService1 Members

public void Display(Employee empobj)
{
Console.WriteLine(“in display… \n empid :” +empobj.empid + “\n empname :”+empobj.empname );

}

public Employee ModifyEmployeeDetails(Employee empobj)
{
Console.WriteLine(“Modify emp details… “);
return empobj;
}

#endregion
}

In the SOAP envelope we can see Message is having two parts Message Header and Message Body

By using Message Contract we can have the control over message.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s