“编码”<&引用;及&燃气轮机&引用;通过HTTP Post发送XML时
我使用MSXML中的XMLHTTP对象,通过HTTPPOST将XML内容从Access VBA发送到Web方法。这是代码“编码”<&引用;及&燃气轮机&引用;通过HTTP Post发送XML时,http,ms-access,post,xmlhttprequest,Http,Ms Access,Post,Xmlhttprequest,我使用MSXML中的XMLHTTP对象,通过HTTPPOST将XML内容从Access VBA发送到Web方法。这是代码 Dim objXmlHttp As Object Set objXmlHttp = CreateObject("MSXML2.ServerXMLHTTP") objXmlHttp.Open "POST", webServicePath, False objXmlHttp.setRequestHeader "Content-Type", "application/x-www-f
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,而不是您能指导我需要做什么来获得有效的XML格式吗 您需要正确设置内容类型,请尝试以下操作:
objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""
我没有看到您对输出进行URL编码。VBA没有URL编码机制。我只是在使用一个通用代码。函数URLEncode(strData)Dim I、strTemp、strChar、strOut、intAsc strTemp=Trim(strData)用于I=1至Len(strTemp)strChar=MID(strTemp、I、1)intAsc(strChar)如果(intAsc>=48和intAsc=97和intAsc=65和intAsc当我包含此内容类型时,我不会在reviving端获取XML内容。值得注意的是:@AndrewHare建议的内容类型会保留为发送输入的文本,但会将其放在数据字段而不是表单字段中。