PROTOTYPE MESSAGE SERVER

5.2.2 HTTP GET from Client

The following code in the client sends a HTTP GET request to the Message Server

 

Private Sub GetFromQueue()
       ' Create a new string object to POST data to the Url.
       Try
            Dim myHttpWebRequest As HttpWebRequest
            Dim myWebResponse As HttpWebResponse
            Dim encoding As New ASCIIEncoding
            myHttpWebRequest = myHttpWebRequest.Create(txtServer.Text &  "/" & txtRecQueue.Text)
            ' Set the content type of the data being posted.
           
myHttpWebRequest.ContentType = "text/xml"
            myHttpWebRequest.Method = "GET"
           'myHttpWebRequest.Timeout = 5000
            myWebResponse = myHttpWebRequest.GetResponse
            Dim sr As New StreamReader(CType(myWebResponse.GetResponseStream, System.IO.Stream), encoding.ASCII)
           txtMessageOutput.Text &= sr.ReadToEnd() & vbCrLf
       Catch webex As System.Net.WebException
            If String.Compare(webex.Message, "The operation has timed out", True) Then
                GetFromQueue()
            Else
                MessageBox.Show(webex.Message)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
      End Sub