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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.