Friday, 22 September 2017

(7) Write syntax for GET & POST to call WCF service.

GET Method:


(31) Can JSON be used as a communication medium in WCF ?

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.



[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.

Thursday, 21 September 2017

INTRVW Qs

Alcatel Lucent

(1) What are the collections available in .NET?
(2) Difference btwn. Array & Array List.
(3) Disadvantages of using ArrayList.
(4) What is Generic?
(5) Write a simple application to concatenate two values if both are string, add it both are numeric.