J
James
Hi,
I am new to .NET framework. I am trying to get data from the third
party web application using WebHTTPRequest and Response class. I am
getting TimeOut exception at GetResponse Method..
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
tried out different solutions but still problem persist. Here is the
code from my test applicaiton
Thanks,
--James
=============================================================================
Private Function readHtmlPage(ByVal Url As String)
Dim result As String = ""
Dim strPost As String = txtRequest.Text
Dim myWriter As StreamWriter
Dim objRequest As HttpWebRequest = WebRequest.Create(Url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
Dim c As X509Certificates.X509Certificate
Try
c = X509Certificates.X509Certificate.CreateFromCertFile("C:\MyFolder\xyz.cer")
objRequest.ClientCertificates.Add(c)
Debug.Write("Client cert added. Name: " & c.GetName)
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write(strPost, 0, strPost.Length)
Catch e As Exception
Return e.Message
txtResponse.Text = e.Message
Finally
'myWriter.Close()
End Try
'
Try
Dim objResponse As HttpWebResponse =
objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd()
sr.Close()
txtResponse.Text = result
Return result
Catch e As Exception
Return e.Message
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
txtResponse.Text =
readHtmlPage("https://mywebpage.com/myApplicaiton.exe")
End Sub
I am new to .NET framework. I am trying to get data from the third
party web application using WebHTTPRequest and Response class. I am
getting TimeOut exception at GetResponse Method..
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
tried out different solutions but still problem persist. Here is the
code from my test applicaiton
Thanks,
--James
=============================================================================
Private Function readHtmlPage(ByVal Url As String)
Dim result As String = ""
Dim strPost As String = txtRequest.Text
Dim myWriter As StreamWriter
Dim objRequest As HttpWebRequest = WebRequest.Create(Url)
objRequest.Method = "POST"
objRequest.ContentLength = strPost.Length
objRequest.ContentType = "application/x-www-form-urlencoded"
Dim c As X509Certificates.X509Certificate
Try
c = X509Certificates.X509Certificate.CreateFromCertFile("C:\MyFolder\xyz.cer")
objRequest.ClientCertificates.Add(c)
Debug.Write("Client cert added. Name: " & c.GetName)
myWriter = New StreamWriter(objRequest.GetRequestStream())
myWriter.Write(strPost, 0, strPost.Length)
Catch e As Exception
Return e.Message
txtResponse.Text = e.Message
Finally
'myWriter.Close()
End Try
'
Try
Dim objResponse As HttpWebResponse =
objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd()
sr.Close()
txtResponse.Text = result
Return result
Catch e As Exception
Return e.Message
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
txtResponse.Text =
readHtmlPage("https://mywebpage.com/myApplicaiton.exe")
End Sub