编码“<"和“>"通过HTTP Post发送XML时 [英] Encoding "<" and ">" while sending XML via HTTP Post
本文介绍了编码“<"和“>"通过HTTP Post发送XML时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用MSXML中的XMLHTTP对象通过HTTP Post从Access VBA向Web方法发送XML内容.这是代码.
I am sending an XML content via HTTP Post from Access VBA to Web Methods, using XMLHTTP object in MSXML. Here is the Code.
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
我正在使用& lt"和& gt"而不是<来获取XML.和>. 如果我尝试进行URL编码,则所有内容都将在接收方以ASCII文本的形式接收. 能否请您指导我需要做些什么才能获得有效的XML格式.
I am getting the XML with "<" and ">" instead of < and >. If I try to do URL encoding, everything is received as ASCII text in the Recipient side. Can you please guide what I need to do to get the valid XML format.
推荐答案
您需要正确设置内容类型,请尝试以下操作:
You need to set the content-type correctly, try this instead:
objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""
这篇关于编码“<"和“>"通过HTTP Post发送XML时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文