Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“编码”<&引用;及&燃气轮机&引用;通过HTTP Post发送XML时_Http_Ms Access_Post_Xmlhttprequest - Fatal编程技术网

“编码”<&引用;及&燃气轮机&引用;通过HTTP Post发送XML时

“编码”<&引用;及&燃气轮机&引用;通过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

我使用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-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"""

我没有看到您对输出进行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建议的内容类型会保留为发送输入的文本,但会将其放在数据字段而不是表单字段中。