locked
Send Request and get Response from server RRS feed

  • Question

  • User-1755390364 posted
    <color="#6633cc">Edited by SomeNewKid. Please post code between </color><color="#000000"><</color>code><color="#6633cc"> and </color><color="#000000"><</color>/code><color="#6633cc"> tags.</color>
    Hi...! Im using the below code to send a XML Request to a secured server and get the response. Using this, getting an error of "Connection could not authenticate with the remote server". Pls help me in solving my problem My Code: string lcUrl = "https://sxxx.com/REQUEST"; HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl); // *** Send any POST data string lcPostData = "Name=" + HttpUtility.UrlEncode("Rick Strahl") + "&Company=" + HttpUtility.UrlEncode("West Wind "); loHttp.Method="POST"; byte [] lbPostBuffer = System.Text. Encoding.GetEncoding(1252).GetBytes(lcPostData); loHttp.ContentLength = lbPostBuffer.Length; Stream loPostData = loHttp.GetRequestStream(); loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length); loPostData.Close(); HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse(); Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc); string lcHtml = loResponseStream.ReadToEnd(); loWebResponse.Close(); loResponseStream.Close(); Instead of sending some data, i want to send the complete file. It is an XML Request file and the output is also an XML Response. The new code must be able to handle the XML Response. Providing Code is appreciated. Pls solve my problem. ThanX a lot in advance.
    Saturday, December 11, 2004 3:49 AM

All replies

  • User-1029435529 posted
    Is this an XML Web Service with which you're communicating? If so, I'll move this post to the XML Web Services forum.
    Saturday, December 11, 2004 4:12 AM
  • User-1755390364 posted
    Upto my knowledge wht i hv thought that it could be handled by HttpHandlers. So I placed this Post. Pls suggest me wht to do and whr i hv to post this Forum.
    Wednesday, December 15, 2004 1:38 AM
  • User-1029435529 posted
    <color="#6633cc;width:550px;">> Upto my knowledge wht i hv thought that it could be handled by HttpHandlers. So I placed this Post.</color> <color="#000000;width:550px;">It is a reasonable guess as to where to place a post about making HTTP connections. However, ASP.NET's HttpHandlers and HttpModules are not actually involved in making HTTP connections. A good guess, but wrong in this instance. So, I was not criticizing your choice as to where to place this question. Rather, I am asking for more information. You haven't specified what is at the other end of the request. That is, what is at https://sxxx.com/REQUEST? Are you sure it is not an XML Web Service??? If it is an XML Web Service, then we can move your question to the XML Web Services forum. However, if it is a normal webpage, then you'll need to post your request. Normally this is fairly easy, and the code you've shown will do this sort of thing. However, your sample address uses the https protocol, yet your code is not creating an SSL-secured connection. If this is the case, we can move your post to the Security forum, because you'll need an expert's advice about generating an SSL-secured HTTP connection.</color>
    Wednesday, December 15, 2004 3:59 AM