Click here to Skip to main content
15,174,182 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi geeks :-),

I am creating a desktop SMS client in VB.NET 2008. I want to POST a text message to the SMS gateway using XML. I have written the code already,but when I run it, I don't receive an HTTP OK. Please tell me what's wrong....

....................................................................................
XML
Dim url As String = "http://gateway.intellectgroup.co.ke:8080/intellectgateway/messages"
            Dim destination As String = txtRecipient.Text
            Dim message As String = txtMessage.Text
            Dim xmlString As String = "<?xml version=""1.0""encoding=""UTF-8""standalone=""yes?"">" & _
        "<messages>" & _
        "<message>" & _
        "<text>" & message & "</text>" & _
        "<destination>" & destination & "</destination>" & _
        "<gateway>" & _
        "<id>187480</id>" & _
        "</gateway>" & _
        "</message>" & _
        "</messages>"
            Dim xmlDoc As String = xmlString
            Dim request As HttpWebRequest
            Dim response As HttpWebResponse
            request = CType(HttpWebRequest.Create(url), HttpWebRequest)
            request.Credentials = New NetworkCredential("*****", "*****")
            request.Method = "POST"
            request.ContentType = "text/xml;charset=UTF-8"
            request.ContentLength = xmlDoc.Length
            Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
            writer.Write(xmlDoc)
            writer.Flush()
            writer.Close()

            response = (request.GetResponse())
            Dim reader As StreamReader = New StreamReader(response.GetResponseStream())

            MsgBox(reader.ReadToEnd)
        Catch ex As WebException
            MsgBox(ex.Message)
        End Try
Posted
Comments
   
OK, and what do you get instead?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900