Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http client to get data from server

Status
Not open for further replies.

robUK2

Programmer
Mar 10, 2008
57
0
0
TH
Hello,

VS 2008

I want to retrieve some data using the HTTP protocol. The server has already been setup to recieve a customer ID. However, I am not sure about the http request in C#.

I have been looking into the WebClient and the httpWebRequest clients. But I am not sure of the complete syntax.

Below is the format of the GET REQUEST.

HTTP GET /billing/servlet/comm.billing.GetBalance?Date=17:54:24&CustomerID=8057 HTTP/1.1

However, I am not sure how to write the client to retrieve the data. The data returned is a float value.

Many thanks,
 
Hello,

Thanks for the response.

However, I am getting an error message with the code I am using below: "Invalid URI: The URI scheme is not valid."

From what I can make out by using wireshark is that the server expects a customerID and the balance will be returned. I am not sure that the data is another parameter that the server expects.

So how can I write the URL that expects a parameter like the customer ID?

Many thanks for any extra help,

Code:
private void btnGetBalance_Click(object sender, EventArgs e)   
{   
try  
{   
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("000.000.00.00:8080/billing/servlet/comm.billing.GetBalance?Date=17:54:24&CustomerID=8057");   
HttpWebResponse res = (HttpWebResponse)wr.GetResponse();   
StreamReader sr = new StreamReader(res.GetResponseStream());   
string balance = sr.ReadToEnd();   
}   
catch(UriFormatException ex)   
{   
MessageBox.Show(ex.Message);   
}   
catch(Exception ex)   
{   
MessageBox.Show(ex.Message);   
}   
}
 
Problem solved.

I missed of the http://
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top