2017-03-03 72 views
1

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

回答

0

更新: 我能够实现我试图通过在RPG程序中使用斯科特·克莱门特的开源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

1

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

为REST API的文档可以在MSDN

1

找到假设你可以在RPG解析您的文档,你可以使用SQL函数HTTPGETBLOB与SharePoint REST API GetFolderByServerRelativeUrl到retrieve a document via HTTP

使用HTTPGETBLOB SQLRPGLE中的SQL函数。例如这里IBM i SQL HTTP Services,一定要通过的SharePoint授权/令牌头:

url: http://site url/_api/web/GetFileByServerRelativeUrl('/Folder Name/file name')/$value 
method: GET 
headers: 
    Authorization: "Bearer " + accessToken 

如果您的文档很长,你应该把它写在IFS,作为解释它的一个链接,否则RPG可变长度可能是不足够。

+0

这听起来像一个很棒的解决方案,Dam。我会给它一个镜头,让你知道它是如何工作的。谢谢! – evawebrez

+0

大坝,任何想法如何获得SQLRPGLE授权标题的accessToken? – evawebrez

+0

我已经成功地将这种方法用于Alfresco而不是Sharepoint。 auth令牌非常容易通过Alfresco获得。我目前不使用sharepoint,我认为它很简单,但获得令牌似乎很棘手,我搜索了一点但找不到明确的答案,请参阅[how-can-i-get-an-oauth-接入令牌在-SharePoint的2013](http://stackoverflow.com/questions/11804624/how-can-i-get-an-oauth-access-token-in-sharepoint-2013)。 – Dam

相关问题