http - 通过 HTTP Post 发送 XML 时编码 "<"和 ">"

标签 http ms-access post xmlhttprequest

我使用 MSXML 中的 XMLHTTP 对象通过 HTTP Post 从 Access VBA 向 Web 方法发送 XML 内容。这是代码。

Dim objXmlHttp As Object
Set objXmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
objXmlHttp.Open "POST", webServicePath, False
objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

Dim Response As String
objXmlHttp.send wrt.output

'OK status
If objXmlHttp.Status = 200 Then
    Response = objXmlHttp.responseText
End If
Set objXmlHttp = Nothing

我正在获取带有“<”和“>”而不是 < 和 > 的 XML。 如果我尝试进行 URL 编码,所有内容都会在收件人端以 ASCII 文本形式接收。 你能指导我需要做什么来获得有效的 XML 格式吗?

最佳答案

您需要正确设置内容类型,试试这个:

objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""

关于http - 通过 HTTP Post 发送 XML 时编码 "<"和 ">",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1406470/

相关文章:

python - 如何使用标准 Python 库使用文件参数触发经过身份验证的 Jenkins 作业

python - 通过 http 连接仅获取 mp3 文件的最后 128 个字节

c- Loadbalancer.拼接时修改http header?

php - 如何检查 domain.com 或 sub.domain.com?

vba - 调用 MS Access 查询,该查询从 Delphi ADO 组件调用模块中的 VBA 函数

javascript - 在 Express 中接收 Jquery POST 数据

http - 从 Wireshark 捕获中提取 GET URI 或它们的响应到单独的文件

excel - 将数据从 Word 无缝移动到 Access

sql-server - 通过 SSIS 创建并复制 Access 表到 SQL? SQL 2008

ajax - 为什么有多种 HTTP 方法可用?