xmlhttp POST无效

时间:2012-10-15 19:36:56

标签: xmlhttprequest

我正在尝试使用中间件客户端(称为Cohesion)将事务发布到服务器。下面是我的代码(asp):

Dim xmlhttp 'As Object

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.Open "POST", "http://server_ip/Databox-dr/CohesionConnect.asmx/GetHostReply", False

'using only http://server_ip/Databox-dr/CohesionConnect.asmx doesn't work, either

xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
'xmlhttp.setRequestHeader "Content-Length", "128"

xmlhttp.send "50000000000MSUF"

Set xmlhttp = Nothing

我所拥有的文件(以及所有这些文件)告诉我:

HTTP POST 以下是HTTP POST请求和响应示例。显示的占位符需要替换为实际值。

POST /DATABOX-DR/CohesionConnect.asmx/GetHostReply HTTP/1.1
Host: server_ip
Content-Type: application/x-www-form-urlencoded
Content-Length: length

sTran=string



HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://fidelityifs.com/webservices">string</string>

(长度和字符串需要替换为实际值)

我做错了什么?如何设置字符串长度? 谢谢!

1 个答案:

答案 0 :(得分:0)

试试这个:

Dim xmlhttp As Object
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", "http://server_ip/Databox-dr/CohesionConnect.asmx/GetHostReply", False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

tosend = "50000000000MSUF"
s = "sTran=" & tosend

xmlhttp.setRequestHeader "Content-Length", Len(s)

xmlhttp.send s