如何使用 RPGLE 检索 Sharepoint 2013 文档?

How can I retrieve a Sharepoint 2013 document using RPGLE?

我需要以编程方式从 Sharepoint 2013 检索文档以用于 IBM i 上的 RPGLE 程序 运行。有没有人做过类似的事情?至少,如果我可以将文档从 Sharepoint 中取出并放到网络文件共享上,我就知道如何从那里获取它。我已经探索了许多不同的可能性,但我不了解 C# 或 .NET,而且我正在努力寻找适合我工作的东西。

如果 RPGLE 支持,您可以通过 REST API 访问 SharePoint 2013 数据。 您可能需要为此设置适当的身份验证。

可在 MSDN

上找到 REST API 的文档

假设您可以在 RPG 中解析您的文档,您可以使用 sql 函数 HTTPGETBLOB 和共享点 REST API GetFolderByServerRelativeUrl 到 retrieve a document via HTTP

在 SQLRPGLE 中使用 HTTPGETBLOB SQL 函数。这里的例子 IBM i SQL HTTP Services ,一定要在 header:

中传递共享点 authorisation/token
url: http://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')/$value
method: GET
headers:
    Authorization: "Bearer " + accessToken

如果你的文档很长,你应该用 IFS 写它,就像前面解释的那样 link,否则 RPG 变量长度可能不够。

更新: 通过在 RPG 程序中使用 Scott Klement 的开源 HTTPAPI,我能够实现我想要做的事情:

   Ctl-opt DftActGrp(*No);
   Ctl-opt BndDir('HTTPAPI');

  /include libhttp/qrpglesrc,httpapi_h

   Dcl-s rc       Int(10);
   Dcl-s url      Varchar(300);
   Dcl-s ifs      Varchar(256);
   Dcl-s pwtype   Char(1);
   Dcl-s userid   Char(50);
   Dcl-s password Char(50);

  // Turn on debugging for troubleshooting. It will write a debug log file
  // to the IFS in /tmp/httpapi_debug.txt
   http_debug(*ON);

   url = 'http://sharepoint/path/to/file/thefile.pdf';
   ifs = '/temp/myfile.pdf';

  // Set password type for SharePoint's NTLM authentication requirement
   pwtype = HTTP_AUTH_NTLM;

  // Set user and password
   userid = 'theuser';
   password = 'thepassword';

  // Set credentials for authentication
   http_setAuth(pwtype: userid: password);

  // Call HTTPAPI's routine to download the file to the IFS
   rc = http_req('GET': url: ifs);

  // End gracefully if error
   if rc <> 1;
     http_crash();
   endif;

   *inlr = *on;

可以找到更多详细信息 here