HTTP Request

G

Guest

How do I make a HTTP request from a class?
I am writing a component that will run outside of the webserver. This
component will send xml files to another http server. I am not using SOAP.
 
A

Alvin Bruney - ASP.NET MVP

have a look at the webrequest class

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
J

Joerg Jooss

Thus wrote Arne,
How do I make a HTTP request from a class?
I am writing a component that will run outside of the webserver. This
component will send xml files to another http server. I am not using
SOAP.

Check out System.Net.WebClient or System.Net.HttpWebRequest.

Cheers,
 
G

Guest

Alvin,
I found a webclient class but no webrequest class.
--
Arne Garvander
Certified Geek



Alvin Bruney - ASP.NET MVP said:
have a look at the webrequest class

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
A

Alvin Bruney - ASP.NET MVP

WebRequest myWebRequest = WebRequest.Create(str.ToString());

// Set the 'Timeout' property in Milliseconds.

#warning timeout value was set to 10000 for testing purpose

myWebRequest.Timeout = 10000;

// This request will throw a WebException if it reaches the timeout limit
before it is able to fetch the resource.

// ProductData _data = new ProductData();

DataSet ds = new DataSet("test");


try

{

WebResponse myWebResponse = myWebRequest.GetResponse();

StreamReader reader = new StreamReader(myWebResponse.GetResponseStream());

XmlTextReader read = new XmlTextReader(reader);

ds.ReadXml(read);

}

catch(WebException ex)

{



Debug.WriteLine(ex.Message);

throw;

}


--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Arne Garvander said:
Alvin,
I found a webclient class but no webrequest class.
--
Arne Garvander
Certified Geek



Alvin Bruney - ASP.NET MVP said:
have a look at the webrequest class

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



How do I make a HTTP request from a class?
I am writing a component that will run outside of the webserver. This
component will send xml files to another http server. I am not using SOAP.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top