Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public Json_Connection ()
  2. {
  3. // Create a request for the URL.
  4. WebRequest request = WebRequest.Create (
  5. "http://10.190.80.248/WebService/webservice.asmx/getStudentID?id=1");
  6. // If required by the server, set the credentials.
  7. request.ContentType = "application/json";
  8. request.Credentials = CredentialCache.DefaultCredentials;
  9. // Get the response.
  10. WebResponse response = request.GetResponse ();
  11. // Display the status.
  12. Console.WriteLine (((HttpWebResponse)response).StatusDescription);
  13. // Get the stream containing content returned by the server.
  14. Stream dataStream = response.GetResponseStream ();
  15. // Open the stream using a StreamReader for easy access.
  16. StreamReader reader = new StreamReader (dataStream);
  17. // Read the content.
  18. string responseFromServer = reader.ReadToEnd ();
  19. // Display the content.
  20. Console.WriteLine (responseFromServer);
  21. // Clean up the streams and the response.
  22. XmlSerializer serializer = new DataContractJsonSerializer (Json.GetType(), new Type[] { typeof(Json) });
  23.  
  24. Json flippo = (Json)serializer.Deserialize (reader);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement