0

我正在尝试使用中间件客户端(称为 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>

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

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

4

1 回答 1

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
于 2012-10-15T19:47:47.780 回答