B
Bob
Hi,
I am new to using a web resource which is not a webservice and I am
spinning my wheels with the webrequest class.
I am trying to interact with a URI that has been given to me.
It is say www.bloggs.com/cgi-bin/thin-client"
My app gathers data and is supposed to pass this data to the URI which will
then respond with a result.
So some real basic questions.
1)They have given me a user name and password to use.
Where does this fit into the construction of the request? I thought it
might be using the NetworkCredential class and the CredentialCache but I
couldn't even get the basic microsoft example to work.
2) I have an example printed request which shows the header and body.
So I made an XML doc the same as the body, and tried to incorporate that
into the request using the GetRequest stream method.
I assumed that it would be rejected as I didn't have any credentials.
But it just locks up at the GetResponse
my code follows:
Thanks
Bob
WebRequest r =
WebRequest.Create(http://www.blogs.com//cgi-bin//thin-client);
r.Headers.Set("Method","POST");
r.Headers.Set("URI", "/cgi-bin/thin-client");
r.Headers.Set("HTTP-version", "HTTP/1.1");
r.Headers.Set("UserAgent", "specialagent"); // not the real agent
r.Headers.Set("ContentLength", "310");
r.Headers.Set("ContentType", "application/xml");
r.Headers.Set("Timeout", "10000");
try
{
r.Method = "POST";
Stream postStream = r.GetRequestStream();
FileStream f;
f = new FileStream("C:\\testvend.xml",System.IO.FileMode.Open);
postStream = f;
WebResponse response = r.GetResponse(); *****LOCKS UP HERE*********
Stream streamResponse = response.GetResponseStream();
I am new to using a web resource which is not a webservice and I am
spinning my wheels with the webrequest class.
I am trying to interact with a URI that has been given to me.
It is say www.bloggs.com/cgi-bin/thin-client"
My app gathers data and is supposed to pass this data to the URI which will
then respond with a result.
So some real basic questions.
1)They have given me a user name and password to use.
Where does this fit into the construction of the request? I thought it
might be using the NetworkCredential class and the CredentialCache but I
couldn't even get the basic microsoft example to work.
2) I have an example printed request which shows the header and body.
So I made an XML doc the same as the body, and tried to incorporate that
into the request using the GetRequest stream method.
I assumed that it would be rejected as I didn't have any credentials.
But it just locks up at the GetResponse
my code follows:
Thanks
Bob
WebRequest r =
WebRequest.Create(http://www.blogs.com//cgi-bin//thin-client);
r.Headers.Set("Method","POST");
r.Headers.Set("URI", "/cgi-bin/thin-client");
r.Headers.Set("HTTP-version", "HTTP/1.1");
r.Headers.Set("UserAgent", "specialagent"); // not the real agent
r.Headers.Set("ContentLength", "310");
r.Headers.Set("ContentType", "application/xml");
r.Headers.Set("Timeout", "10000");
try
{
r.Method = "POST";
Stream postStream = r.GetRequestStream();
FileStream f;
f = new FileStream("C:\\testvend.xml",System.IO.FileMode.Open);
postStream = f;
WebResponse response = r.GetResponse(); *****LOCKS UP HERE*********
Stream streamResponse = response.GetResponseStream();