上传文件到SharePoint 2013在线使用Web服务 [英] Upload document to Sharepoint 2013 Online using webservices

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

问题描述

我是谁实施在Sharepoint 2013联机客户门户网站的客户端。目前的方案通过邮件分发文件给客户。现在我们要上传文件到客户门户。

I have a client who is implementing customer portals in Sharepoint 2013 Online. The current program distributes documents to the customers by mail. Now we have to upload the documents to the customer portal.

我尝试使用web服务复制SharePoint中。我创建了一个测试项目,并添加web服务的Web引用,并写了下面的testcode:

I try to use the copy webservice in sharepoint. I created a test project and added the webservice as Web Reference and wrote the following testcode:

static void Main(string[] args)
{
    string baseUrl = "https://mycustomer.sharepoint.com/sites/";
    string customer = "customerportalname";
    string serviceUrl = "/_vti_bin/copy.asmx";
    string destinationDirectory = "/folder/";
    string fileName = "uploaded.xml";

    string username = "username@outlook.com";
    string password = "password";

    XmlDocument xmlDocument = new XmlDocument();
    xmlDocument.LoadXml("<fiets><onderdeel>voorwiel</onderdeel><onderdeel>achterwiel</onderdeel><onderdeel>trappers</onderdeel><onderdeel>stuur</onderdeel><onderdeel>frame</onderdeel></fiets>");

    byte[] xmlByteArray;
    using (MemoryStream memoryStream = new MemoryStream())
    {
        xmlDocument.Save(memoryStream);
        xmlByteArray = memoryStream.ToArray();
    }

    string destinationUrl = string.Format("{0}{1}{2}{3}", baseUrl, customer, destinationDirectory, fileName);
    string[] destinationUrlArray = new string[] { destinationUrl };

    FieldInformation fieldInfo = new FieldInformation();
    FieldInformation[] fields = { fieldInfo };


    CopyResult[] resultsArray;

    using (Copy copyService = new Copy())
    {
        copyService.PreAuthenticate = true;
        copyService.Credentials = new NetworkCredential(username, password);
        copyService.Url = string.Format("{0}{1}", baseUrl, serviceUrl);

        copyService.Timeout = 600000;

        uint documentId = copyService.CopyIntoItems(destinationUrl , destinationUrlArray, fields, xmlByteArray, out resultsArray);
    }
} 

当我执行我收到以下错误的代码:

When I execute the code I recieve the following error:

The request failed with the error message:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/_forms/default.aspx?ReturnUrl=%2f_vti_bin%2fcopy.asmx">here</a>.</h2>
</body></html>
--



它看起来像我不是验证和重定向。然而,凭据是正确的。
有没有人有一个想法?在此先感谢!

It looks like I'm not authenticated and get redirected. The credentials however are correct. Does anyone have an idea? Thanks in advance!

更新

要能够连接到SharePoint 2013网上有你在的这个职位。然而,
我的问题是,有也参与了ADFS。我怎样才能autheticate对ADFS?

To be able to connect to SharePoint 2013 Online you have to attach the Office 365 authentication cookies as explained in this post. My problem however is that there is also an ADFS involved. How can I autheticate against the ADFS?

推荐答案

在我的情况下(在前提),我有一个错误。当我在改变Web应用IIS的SharePoint身份验证,并禁用窗体身份验证。现在,我不能进入由UI到SharePoint,但Web服务的工作。所以我已经恢复,我一直在寻找和...

In my case (on premise) i have that error. when i changed at iis SharePoint authentication for web application , and disable "Forms Authentication". Now, i can´t enter to SharePoint by UI, but the Web Service works... So I have revert and I have been looking and...

[保罗鹳]此网站的Web应用程序在经典模式,而不是索赔模式下运行。如果你使用PowerShell的创建Web应用程序或从2010年升级您可以使用PowerShell来改变它会发生这种情况。

[Paul stork] The Web Application for this site is running in Classic Mode rather than Claims mode. This can happen if you create the web app using Powershell or upgrade from 2010. You can use PowerShell to change it.

http://technet.microsoft.com/en-us/library/gg251985.aspx

我曾尝试通过UI管理中心创建的另一个新的应用程序的Web服务(同一个场中),它工作过。 。问题是Web应用程序

I have tried the Web Service in another new application created by UI in Central Administration (in same farm) and it had worked. The problem was the web application.

要尝试:
http://sharepointyankee.com/2011/01/04/the-request -failed与 - 的错误消息,对象移动,与SharePoint 2010的Web服务,FBA /
扩展您的混合身份验证的Web应用程序,创造只为Windows身份验证的区域,则更改Web参考网址在Web服务的属性,使用该扩展的URL和端口。你应该没有这样的问题了。

To try: http://sharepointyankee.com/2011/01/04/the-request-failed-with-the-error-message-object-moved-sharepoint-2010-web-services-fba/ Extend your mixed authentication web application, and create a zone just for Windows Authentication, then change the Web Reference URL in the properties of your web service, to use that extended URL and port. You should have no issues of this kind anymore.

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

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