Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Json_Connection ()
- {
- // Create a request for the URL.
- WebRequest request = WebRequest.Create (
- "http://10.190.80.248/WebService/webservice.asmx/getStudentID?id=1");
- // If required by the server, set the credentials.
- request.ContentType = "application/json";
- request.Credentials = CredentialCache.DefaultCredentials;
- // Get the response.
- WebResponse response = request.GetResponse ();
- // Display the status.
- Console.WriteLine (((HttpWebResponse)response).StatusDescription);
- // Get the stream containing content returned by the server.
- Stream dataStream = response.GetResponseStream ();
- // Open the stream using a StreamReader for easy access.
- StreamReader reader = new StreamReader (dataStream);
- // Read the content.
- string responseFromServer = reader.ReadToEnd ();
- // Display the content.
- Console.WriteLine (responseFromServer);
- // Clean up the streams and the response.
- XmlSerializer serializer = new DataContractJsonSerializer (Json.GetType(), new Type[] { typeof(Json) });
- Json flippo = (Json)serializer.Deserialize (reader);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement