如何在 Progress/OpenEdge ABL 中执行 HTTP GET 和 POST?
Progress 文档在 SOAP 上花费了大量的精力,但我很难找到带有 Progress ABL 的简单 HTTP GET/POST 示例。
如何从 URL 获取和发布字符串?
URL 可以是 https:// 吗?
Progress 可以提供 HTTP Basic 或 HTTP Digest 身份验证吗?
The Progress docs spill plenty of ink on SOAP, but I'm having trouble finding the example for a simple HTTP GET/POST with Progress ABL.
How do I GET and POST strings to/from a URL?
Can the URL be https://?
Can Progress provide HTTP Basic or HTTP Digest authentication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于这个问题的未来旁观者:
Openedge 现在(我相信从 11.5.1 开始)已经内置了对调用基于 REST 的 Web 服务的支持。它们包含在提供的 .pl 存档中,默认情况下该存档不在您的 PROPATH 中,因此需要首先处理(或者可以将存档移动到“更好的位置”)。
propath 可以通过多种方式设置,初始化文件、注册表、编程方式等。这就是在 ABL 中完成的方式(如果这样做,则必须为每个新会话重复)。
“tty”目录中还有一个版本,以及“src”目录中包含源代码的存档。
这是一个非常基本的示例:
11.6 的文档可以在此处找到。
For future onlookers at this question:
Openedge now (since 11.5.1 I believe) has built in support for calling REST based webservices. These are enclosed in a provided .pl archive that is not in your PROPATH by default so that needs to be handled first (or the archive can be moved to a "better location").
The propath can be set in a number of ways, init files, registry, programatically etc. This is how it can be done in ABL (if done this way it must be repeated for each new session).
There's also a version in "tty" directory, as well as an archive containing source code in the "src" directory.
Here's a very basic example:
Documentation for 11.6 can be found here.
Openedge 内置了用于处理 SOAP 服务的语句,但没有用于 GET/POST 的简单语句。然而,它确实具有一种读/写特定套接字的机制。因此,您可以使用它来构建 HTTP post 例程,或者就此而言,构建一个处理任何其他基于套接字的协议的例程。
有一个例程 - http.p - 将为您执行 GET 操作。如果没有别的事情的话,会让你看看套接字编程是如何工作的。您应该能够很容易地修改它来执行简单的 POST,但使用 SSL 或进入身份验证可能需要相当多的工作。在这种情况下,直接退出 CURL 可能会更容易。
http.p 曾经可以从 freeframework.org 获得,但我刚刚检查过,该域已过期,所以我发布了下面的代码。
Openedge has built in statements for handling SOAP services, but no simple statement for a GET/POST. What it does have, however, is a mechanism to read / write to specific sockets. So you could use this to build a HTTP post routine, or for that matter a routine to handle any other socket based protocol.
There is a routine - http.p - which will do a GET for you. Will let you see how the socket programming works if nothing else. You should be able to modify it quite easily to do a simple POST, but using SSL or getting into authentication might take quite a bit of work. You might be easier just dropping out to CURL in this case.
http.p used to be available from freeframework.org, but I've just checked and that domain has expired, so I've posted the code below.
Progress Kbase ID:20011:“使用 4GL 套接字通过 HTTP 访问网站的示例代码”也是一个很好的通用示例。
Progress Kbase ID: 20011: "Sample Code To Access a Web Site via HTTP with 4GL Sockets" is also a nice, generic example.
我建议使用上面 Gordon Roberertson 的代码示例,因为 Progress KB 文章中的“WAIT-FOR”被替换为循环。因此,如果出现任何问题,程序将在超时后终止。
请注意,更改 requestString 中的任何内容都可能导致超时。但是,如果您需要登录网络服务器,则可以添加用户代理:
感谢 Gordon 提供的代码示例。
I recommend using the code example of Gordon Roberertson above because there is the "WAIT-FOR" of the Progress KB article replaced with a loop. So the prcoedure terminates after timeout period if anything goes wrong.
Please note that changing anything in requestString can cause timeouts. But adding a User-Agent is possible if you need for logging on your webserver:
Thanks to Gordon for his code example.