View Full Version : trying to display info from web service

11-30-2011, 08:02 PM
hey all.
I am not very familiar with .net, only been studying for a short amount of time.

I am attempting to make a simple page that will display data from a SOAP/xml web service.

I made my basic page with a literal control with an id of mydiv, and I am trying to populate the div with the string response from the example, but I dont knwo near enough to get it to work correctly.

error intellisense si giving me is :
the best overloaded method match for 'StringGet.GetPageAsString(System.Uri)' has some invalid arguments

this is my code behind:

using System;
using System.Collections.Generic;
using System.Web;
using System.IO;
using System.Net;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

mydiv.Text = StringGet.GetPageAsString("http://www.example.com");
public class StringGet
public static string GetPageAsString(Uri address)
string result = "";

// Create the web request
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;

// Get response
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());

// Read the whole contents and return as a string
result = reader.ReadToEnd();

return result;

12-01-2011, 04:28 PM
no suggestions at all?

12-01-2011, 04:51 PM
your class asks for a uri and you are sending a string; you cannot implicitly convert it

try something like

string google = @"http://www.google.com";
Uri demo = new Uri(google);
string mydiv = StringGet.GetPageAsString(demo);

should work. Also don't forget to close your stream reader when you are done

// Read the whole contents and return as a string
result = reader.ReadToEnd();

12-01-2011, 04:52 PM
or even

mydiv.Text = StringGet.GetPageAsString(new uri(@"http://www.example.com"));

might work

12-01-2011, 09:26 PM
Ill give it a shot ty