1. Start visual studio and select a WCF service application
template, Name the project as WcfService1
, choose a location to save this project.
2. Delete the default service
and contract
files, Service1.svc
and IService1.cs
by default. Delete both the files.
3. Define a data contract for Employee
as below
[DataContract] public class Employee { [DataMember] public int EmployeeId { get; set; } [DataMember] public string EmployeeName { get; set; } [DataMember] public string Designation { get; set; } }
4. Define a service contract for EmployeeService
as below
[ServiceContract] public interface IEmployeeService { [OperationContract] Employee GetEmployees(int id); }
5. Define actual service EmployeeService
by inheriting IEmployeeService
[ServiceContract] public class EmployeeService : IEmployeeService { [OperationContract] Employee GetEmployees(int id) { return new Employee{ EmployeeId = id, EmployeeName = "my name", Designation = "Software Engineer" }; } }
6. Configure endpoint in web.config
- <div class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
- ...
- </ul>
- </div>