I want to send json object from C# client (using WebRequest
or any other method .Net 3.5 support) to WCF service and read that object from there. Can anybody help?
Asked
Active
Viewed 1,017 times
-1

Nishantha
- 6,065
- 6
- 33
- 51
-
You mean to say that client want to consume WCF service using JSON psot... Right? – Amit Soni Oct 05 '15 at 06:31
-
1What have u tried so far? What error/issue you are getting while sending the JSON Object. – Mohit S Oct 05 '15 at 06:34
-
@AmitSoni No. Json request from client to WCF and deserialize it in the server. – Nishantha Oct 05 '15 at 06:35
-
@Mohit Shrivastava I haven't try so far. I only tried WCF service to client using `WebRequest ` – Nishantha Oct 05 '15 at 06:38
-
It's so easy to down vote without answering.... – Nishantha Oct 05 '15 at 06:47
1 Answers
0
You can use Newtonsoft.Json package from NuGet to help you accomplish this. To deserialize your json back to the object in WCF you can do:
List<T> data = JsonConvert.DeserializeObject<T>(jsonString);
//assuming you have a list of objects.
To convert the object to Json string you will have to do:
JsonConvert.SerializeObject(obj)
Refer to this for posting data to wcf from c#
-
Actually I'm using Json.net. I just want to know how to send data client to server through `WebRequest` and `StreamWriter`. Not how serialize or deserialize. Anyway thanks. – Nishantha Oct 05 '15 at 07:16