I'm attempting to to consume a XML webservice. The service is a asterix based PBX called switchvox. Each request should be in the form of XML, with XML being returned in the response. My code is follows, I am only able to get the API to return an error saying my request was empty.
Dim xml As String
xml = ""
xml = xml & " <request method=""switchvox.users.extensions.getInfo"">"
xml = xml & " <parameters>"
xml = xml & " <extensions>"
xml = xml & " <extension>104</extension>"
xml = xml & " </extensions>"
xml = xml & " </parameters>"
xml = xml & " </request>"
Dim url As String = "https://pbx/xml"
Dim webRequest__1 As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
webRequest__1.Method = "POST"
webRequest__1.Credentials = New NetworkCredential("user", "pass")
webRequest__1.ContentType = "text/xml"
webRequest__1.ContentLength = xml.Length
Using requestWriter2 As New StreamWriter(webRequest__1.GetRequestStream())
requestWriter2.Write(xml)
End Using
Dim resp As HttpWebResponse = DirectCast(webRequest__1.GetResponse(), HttpWebResponse)
Dim responseData As String = String.Empty
Using responseReader As New StreamReader(webRequest__1.GetResponse().GetResponseStream())
responseData = responseReader.ReadToEnd()
End Using