1.关于报表Web服务
ReportWebServer.exe 是独立的 Web 服务程序,它将调用 winface.dll, 完成报表的服务器专版的功能,而不必依赖诸如 IIS、Tomcat 这些 Web 服务容器。
使用很简单,只要把 ReportWebServer.exe 和服务器专版的那堆 DLL 放在同一个目录下即可。
ReportWebServer.exe 运行界面也很简单,只有一个侦听的 http 端口号需输入,默认是 80 端口。
ReportWebServer.exe 除了提供报表Web服务,它还提供简单的 http 文件服务,为静态网站提供 Web 服务也没有问题。
开发 ReportWebServer.exe 的目的,是为了能在 linux 服务器上单独部署 (借助 wine)。
2.调用方法
ReportWebServer.exe 只是对 winface 的 api 作了一层 http 封装,所以使用起来很简单,它并没有增加其它新的函数。
ReportWebServer.exe 通过 http GET 或 POST 向外提供服务,http 采用类似 restfull 的无状态方式。
不管是 GET 还是 POST,它的返回格式都是一样的,只是一个字符串,ContentType是 text/plain.
它对调用方没有平台或语言的要求,可以是 Java、C#甚至是网页,下面的例子就是网页,结合 winface 常用的 GetActiveServices、OpenReportService、CloseService、func 这 4 个函数,示例如何使用。
3.GetActiveServices
$.ajax({url:"/GetActiveServices"})
.then((result) => {
alert(result); // result就是返回的结果
});
4.OpenReportService
var h = "";
let para= "TempDir=@ROOTDIR\\temp; LogLevel=2; BaseDir=http://localhost:8080/";
$.ajax({url:"/OpenReportService?para=" + encodeURIComponent(para)})
.then((result) => {
console.log(result);
h = result;
});

“@ROOTDIR”是宏,表示 ReportWebServer.exe 所在的目录 ( TempDir 当然也可以指向其它目录).
4.func
let para = "105\r\ntype=pdf;filename=test.pdf";
//这是 GET 的写法 (这个 h 就是 OpenReportService 的返回值)
$.ajax({url:"/func?h=" + h + "&name=callfunc¶=" + encodeURIComponent(para)})
.then((result) => {
console.log(result);
});
//这是 POST 的写法
$.ajax({url:'/func', type:'post', data: para, processData:false, success:function(result) {
console.log(result);
}});

1.GET 对 URL 的长度有限制,如果参数太长或不确定,应该采用 POST
2.POST 相当于就是把 GET 的 URL 的 "?" 后面的内容移入 http body ;
5.closeService
$.ajax({url:"/CloseService?h=" + h})
.then((result) => {
});
6.其它说明
1.ReportWebServer.exe 的 http 服务目前没有身份认证,也没有任何安全防护措施,所以建议在内网运行;
2.ReportWebServer.exe 不支持 https;
3.几种返回的错误码:404-文件不存在;412-dll加载失败;405-请求的参数错误
4.当 ReportWebServer.exe 作为 Web 文件服务时,它只能访问 exe 所在目录、以及子目录的文件, http URL 的根所映射的目录就是该 exe 文件所在的目录;
5.内置了测试页功能,如果侦听的是8080端口,那么测试页的 URL 就是:http://localhost:8080/,您可以在浏览器中打开该URL试试;
6.ReportWebServer 支持命令行来设置端口号,例如执行: “ReportWebServer /8080” 表示运行后会立即启动侦听 8080 端口 (不需要手工交互了);
7.采用 wine 在 linux 上使用时, 注意需要配置如下的依赖项目:gdiplus、 iertutil、 vcrun6、 winhttp、 wininet、 wininet_win2k;