编码“<"和“>"通过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 "&lt" and "&gt" 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"""