【问题标题】:How to - XML HTTPS Post using VB.NET?如何 - 使用 VB.NET 的 XML HTTPS Post?
【发布时间】:2021-02-11 16:11:23
【问题描述】:

我正在尝试使用 VB.NET 通过 HTTP Post 提交 XML。我有用 ASP 编写的示例代码,但以下行不兼容:

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

任何人都可以更正此问题或提供示例 VB.NET 代码来完成此操作吗?谢谢。

【问题讨论】:

    标签: xml vb.net


    【解决方案1】:

    我有这个方法用于在 ASPX 中发送 XML 响应,

        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
    

    注意代码中的stackoverflow链接。

    【讨论】:

      猜你喜欢
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      • 2019-06-26
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多