问题描述
尝试从基本脚本(VBScript / VBA脚本语言 - SummitSoftware)将HTTP发布到Web服务,并希望实现超时。
显然,XmlHttpRequest对象有一个timeout属性(http://msdn.microsoft.com/en-us/library/ms535874%28v=vs.85%29.aspx),但尝试使用它返回一个属性或方法未找到错误。
例如:
Dim obj As Object
Set obj = CreateObject(MSXML2.XMLHTTP.3.0)
obj.timeout = 123
这也适用于Microsoft.XMLHTTP和任何其他版本的MSXML2变体。
我迄今为止唯一的想法是踢另一个进程,运行vbscript请求。如果它运行超过给定时间,则kill该进程。
有关这方面的任何想法,或如何以不同的方式实现?
编辑(可能的解决方案):
- WShell.Run VBScript在另一个进程中运行并完成异步操作。如果运行超过n个
- 使用HTTP / 1.1 Keep-Alive标头。 您是使用VBA / VB6还是VBScript? 在VBScript中,
- WShell.Run a VBScript to run in another process and complete the operation async. Kill if runs for more than n.
- Use HTTP/1.1 Keep-Alive header. Would rather implement this on the client.
Dim obj As Object
无效,因为没有静态类型。 看错了对象引用。 MSXML2.XMLHTTP
对象具有 IXMLHTTPRequest
接口,其定义和是为 XmlHttpRequest
支持的对象Internet Explorer 7 +。
Attempting to make an http post to a web service from a basicscript (VBScript/VBA scripting language - SummitSoftware) and want to implement a timeout.
Apparently the XmlHttpRequest object has a timeout property (http://msdn.microsoft.com/en-us/library/ms535874%28v=vs.85%29.aspx), but attempting to use it returns me a "property or method not found" error.
Eg:
Dim obj As Object
Set obj = CreateObject("MSXML2.XMLHTTP.3.0")
obj.timeout = 123
This also applies to Microsoft.XMLHTTP and any other versions of the MSXML2 variant.
My only thought so far is to kick of another process which runs a vbscript to make the request. If it runs for more than a given time, kill the process. Not exactly ideal however.
Any ideas on this, or how this might be implemented differently?
Edit (possible solutions):
Are you using VBA/VB6 or VBScript? In VBScript, Dim obj As Object
is not valid as there is no static typing.
I think you might be looking at the wrong object reference. The MSXML2.XMLHTTP
object has the IXMLHTTPRequest
interface which is defined here and the reference you mention is for the XmlHttpRequest
object supported by Internet Explorer 7+.
这篇关于XmlHttpRequest超时 - 找不到属性或方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!