using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
namespace
Wcfm
{// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[serviceContract]
public interface IService1
{
[OperationContract]
EmployeeDetails getEmployeeDetails();
// TODO: Add your service operations here
}}
------------------------------------------------------------------------------------------------------------
now implement interface,
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
namespace
Wcfm
{// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
public class Service1 : IService1
{public EmployeeDetails getEmployeeDetails()
{EmployeeDetails obj = new EmployeeDetails();
obj.Designation = "Manager";
obj.EmpID = 101;
obj.EmpName = "Mukesh";
obj.Location = "Noida";
obj.Salary = 50000;return obj;
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------
now take class1 and do the following code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.ServiceModel;
using
System.Runtime.Serialization;
namespace
Wcfm
{
[MessageContract]
public class EmployeeDetails
{
[MessageHeader]
public int EmpID;
[
MessageBodyMember]
public string EmpName;
[MessageBodyMember]
public string Designation;
[MessageBodyMember]
public int Salary;
[MessageBodyMember]
public string Location;
}
}
and now run service and consume it...
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
namespace
Wcfm
{// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[serviceContract]
public interface IService1
{
[OperationContract]
EmployeeDetails getEmployeeDetails();
// TODO: Add your service operations here
}}
------------------------------------------------------------------------------------------------------------
now implement interface,
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
namespace
Wcfm
{// NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
public class Service1 : IService1
{public EmployeeDetails getEmployeeDetails()
{EmployeeDetails obj = new EmployeeDetails();
obj.Designation = "Manager";
obj.EmpID = 101;
obj.EmpName = "Mukesh";
obj.Location = "Noida";
obj.Salary = 50000;return obj;
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------
now take class1 and do the following code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.ServiceModel;
using
System.Runtime.Serialization;
namespace
Wcfm
{
[MessageContract]
public class EmployeeDetails
{
[MessageHeader]
public int EmpID;
[
MessageBodyMember]
public string EmpName;
[MessageBodyMember]
public string Designation;
[MessageBodyMember]
public int Salary;
[MessageBodyMember]
public string Location;
}
}
and now run service and consume it...