0

I'm new to Web development i want to develop simple app which receives request form mobile parse request body and give me response.

Application shouls use HTTP, JSON

My request from mobile side

Request URL = http://<server-url>/AppName/auth
Request Body = { "user_name" : "abcd", "password":"pass", "time":134124343435}

Response form Web application should be

Response Body = { "Result" : 1, "msg":"Authentication Success", "suid": "uuddi2013092121324434", "time":134124343435}

I want it to develop in C#, can i use WCF? or I there any other way? I referred these 2 links, but they are not parsing request body.

http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec

http://dotnetmentors.com/wcf/wcf-rest-service-to-get-or-post-json-data-and-retrieve-json-data-with-datacontract.aspx

Please help me with some link to refer or provide me sample code..

Thanks in Advance

Psytronic
  • 6,043
  • 5
  • 37
  • 56
Pradeep
  • 2,530
  • 26
  • 37
  • 2
    You don't need to parse the body. WCF would do it for you. See [this](http://stackoverflow.com/questions/15852859/call-subroutines-via-url-across-local-network) or [this](http://stackoverflow.com/questions/12899360/getting-a-post-endpoint-to-work-in-self-hosted-webservicehost-c-sharp-webservi) – I4V Sep 27 '13 at 07:38
  • Thanks.. I one more question, If i'm sending Json Array as a request which contain n number of user data, that need to be insert into Web application. How can achieve that. – Pradeep Sep 27 '13 at 07:51
  • Nothing different. Your parameter in WCF service will be a list or an array. – I4V Sep 27 '13 at 08:01

1 Answers1

0

Someone who has developed the utility to parse the JSON whether the format is well or not, you can find some useful example through http://sourceforge.net/projects/csjson/. Also you can implement the functionality by using JQUERY, you might need similar code like this:

var gpsinfoUrl = "http://localhost/gps/xy.json";
$.ajax({
    type: 'GET',
    url: gpsinfoUrl,
    dataType: 'json',
    async: false,
    success: function (dt) {
        json_object = $.parseJSON(dt.gpsinfo); //$.parseJSON will be used to verify the return string from url.
    }
});