通过内置 Web 服务将文件上传到 SharePoint [英] Upload a file to SharePoint through the built-in web services

查看:54
本文介绍了通过内置 Web 服务将文件上传到 SharePoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 WSS 3.0 版本公开的内置 Web 服务将文件上传到 SharePoint 服务器上的文档库的最佳方法是什么?

What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?

按照两个初始答案...

  • 我们肯定需要使用 Web 服务层,因为我们将从远程客户端应用程序进行这些调用.

  • We definitely need to use the Web Service layer as we will be making these calls from remote client applications.

WebDAV 方法对我们有用,但我们更愿意与 Web 服务集成方法保持一致.

The WebDAV method would work for us, but we would prefer to be consistent with the web service integration method.

<块引用>还有一个网络服务来上传文件,虽然痛苦但一直有效.

您指的是复制"服务吗?我们已成功使用此服务的 CopyIntoItems 方法.这是仅使用 WSS Web 服务 API 将文件上传到文档库的推荐方法吗?

Are you referring to the "Copy" service? We have been successful with this service’s CopyIntoItems method. Would this be the recommended way to upload a file to Document Libraries using only the WSS web service API?

我已经发布了我们的代码作为建议的答案.

I have posted our code as a suggested answer.

推荐答案

使用 WSS复制"Web 服务将文档上传到库的示例...

Example of using the WSS "Copy" Web service to upload a document to a library...

public static void UploadFile2007(string destinationUrl, byte[] fileData)
{
    // List of desination Urls, Just one in this example.
    string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) };

    // Empty Field Information. This can be populated but not for this example.
    SharePoint2007CopyService.FieldInformation information = new 
        SharePoint2007CopyService.FieldInformation();
    SharePoint2007CopyService.FieldInformation[] info = { information };

    // To receive the result Xml.
    SharePoint2007CopyService.CopyResult[] result;

    // Create the Copy web service instance configured from the web.config file.
    SharePoint2007CopyService.CopySoapClient
    CopyService2007 = new CopySoapClient("CopySoap");
    CopyService2007.ClientCredentials.Windows.ClientCredential = 
        CredentialCache.DefaultNetworkCredentials;
    CopyService2007.ClientCredentials.Windows.AllowedImpersonationLevel = 
        System.Security.Principal.TokenImpersonationLevel.Delegation;

    CopyService2007.CopyIntoItems(destinationUrl, destinationUrls, info, fileData, out result);

    if (result[0].ErrorCode != SharePoint2007CopyService.CopyErrorCode.Success)
    {
        // ...
    }
}

这篇关于通过内置 Web 服务将文件上传到 SharePoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆