WCF can be consumed using javascript or jquery.
When client makes the call to the WCF, JSON or XML is used for mode of communication.
WCF has option to send the response in JSON object. This can be configured with WebGet or WebInvoke attribute.
When client makes the call to the WCF, JSON or XML is used for mode of communication.
WCF has option to send the response in JSON object. This can be configured with WebGet or WebInvoke attribute.
[ServiceContract()] public interface IEmployeeService { [WebGet(UriTemplate = "Employee", ResponseFormat=WebMessageFormat.Json )] [OperationContract] List < Employee > GetAllEmployeeDetails(); [WebGet(UriTemplate = "Employee?id={id}", ResponseFormat = WebMessageFormat.Json)] [OperationContract] Employee GetEmployee(int Id); [WebInvoke(Method = "POST", UriTemplate = "EmployeePOST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] [OperationContract] void AddEmployee(Employee newEmp); [WebInvoke(Method = "PUT", UriTemplate = "EmployeePUT", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] [OperationContract] void UpdateEmployee(Employee newEmp); [WebInvoke(Method = "DELETE", UriTemplate = "Employee/{empId}", ResponseFormat = WebMessageFormat.Json)] [OperationContract] void DeleteEmployee(string empId); }
WebGet --> Used for Getting result
WebInvoke --> Used in POST, PUT, DELETE methods.
No comments:
Post a Comment