0

I'm trying to use VB.NET to submit XML via HTTP Post. I have example code written in ASP, but the following lines are not compatible:

Dim xml
Dim strXML

'omitting lines where strXML formed

set xml = CreateObject("Microsoft.XMLHTTP")
xml.setRequestHeader "Content-type", "text/html; charset=UTF-8"
xml.Open "POST", "https://site.info.com/from_somevendor", False
xml.Send strXML
Response.Write(xml.responseText)
set xml = Nothing

Can anyone correct this or provide example VB.NET code to accomplish this? Thank you.

1 Answers1

0

I have this method I use to send XML responses in ASPX,

    Public Shared Function DownLoadXML(Resp As HttpResponse,
                                       theXML As XElement) As Boolean
        'from
        ' https://stackoverflow.com/questions/543319/how-to-return-xml-in-asp-net
        Dim rv As Boolean = False
        Try
            Resp.Clear()
            Resp.ContentType = "text/xml"
            Resp.ContentEncoding = System.Text.Encoding.UTF8
            theXML.Save(Resp.Output)
            Resp.End()
            rv = True
        Catch ex As Exception
        End Try
        Return rv
    End Function
End Class

Note the stackoverflow link in the code.

dbasnett
  • 11,334
  • 2
  • 25
  • 33