2012-10-15 34 views
0

我试图使用中间件客户端(称为内聚)将事务发布到服务器。下面是我的代码(ASP):xmlhttp POST不起作用

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> 

(长度和字符串需要更换与实际值)

我在做什么错?我怎样才能设置字符串的长度? 谢谢!

回答

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 
+0

它没有工作......你能推荐一下阅读,将可能提供帮助的?谢谢! – MariusD

+0

我相信这部分是响应,所以你发送的内容不起作用:HTTP/1.1 200 OK Content-Type:text/xml;字符集= UTF-8 的Content-Length:长度 <?XML版本= “1.0” 编码= “UTF-8”> <字符串的xmlns = “http://fidelityifs.com/webservices”>串 – MariusD

+0

@MariusD我看到了,更新超过 – Plynx