您可以使用 IWElite 组件包中的互操作 Web 模块。
本质上,您将使用 XMLHTTPRequest (XHR) 对象编写一些 Javascript 来调用您的 IW 应用程序的 Web 模块操作,该操作在处理完成时返回。如果您需要 IW 应用程序在进程运行时继续正常运行,您的 Javascript 可以打开一个进度窗口并从那里进行 XHR 调用。
IW 精英可以在这里找到:
http ://code.google.com/p/iwelite/
XHR 请求看起来像这样:
function NewXHR() {
if (typeof XMLHttpRequest == "undefined") {
try { return new ActiveXObject('Msxml2.XMLHTTP.6.0');} catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP.3.0');} catch(e) {}
try { return new ActiveXObject('Msxml2.XMLHTTP');} catch(e) {}
try { return new ActiveXObject('Microsoft.XMLHTTP');} catch(e) {}
throw new Error('AJAX not supported in this browser.');
} else {
return = new XMLHttpRequest();
}
var xhr = NewXHR();
xhr.open("get", '/mywebaction', false);
xhr.send(null);
window.alert(xhr.responseText);
上面的代码将阻塞并等待响应。如果您希望它异步执行,您可以改为执行以下操作:
var xhr = NewXHR();
xhr.open("get", '/mywebaction', true);
xhr.onreadystatechange = function() {
if(xhr.readyState == 4) {
if ((xhr.status == 200) || (xhr.status == 304) || (xhr.status === 0)) {
window.alert('Success: '+xhr.responseText);
} else {
window.alert('Error: ('+xhr.status+') '+xhr.statusText;
}
}
};
xhr.send(null);