记一个调用_vti_bin/copy.asmx拷贝文件的代码例子

本例子已经博主测试通过.

 

注意这里的过认证的部分.

注意这里对CopyIntoItems方法的调用.

 

在Visual Studio 2010中添加Web Service的方法

clip_image002

clip_image003

clip_image004

clip_image005

 

代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebServiceCallTest
{
    class Program
    {
        static void Main(string[] args)
        {
            sps2010.FieldInformation myfieldInfo = new sps2010.FieldInformation();
            string oSourceUrl = @"http://null";
            string[] oDestinationUrls = { @"http://sps2010/lauradoc/Testing3.doc" };
            sps2010.FieldInformation[] oFields = { myfieldInfo };
            byte[] oStream = new byte[2048];
            sps2010.CopyResult[] oResults;

            using(sps2010.Copy oCopy = new sps2010.Copy())
            {
                oCopy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                oCopy.Url = "http://sps2010/_vti_bin/copy.asmx";
                oCopy.Timeout = 600000;
                uint documentid = oCopy.CopyIntoItems(oSourceUrl, oDestinationUrls, oFields, oStream, out oResults);
            }
        }
    }
}

 

打开Fiddler, 可以发现成功的结果.

image

 

参考资料

================

How do you copy a file into SharePoint using a WebService?

http://stackoverflow.com/questions/787610/how-do-you-copy-a-file-into-sharepoint-using-a-webservice

Upload a file to SharePoint through the built-in web services

http://ithoe.com/Question/31868/upload-a-file-to-sharepoint-through-the-built-in-web-services 

A POST or PUT request may fail when you use the HttpWebRequest class to send lots of data on a computer that is running the .NET Framework

http://support.microsoft.com/KB/908573

WCFTestClient The HTTP request is unauthorized with client authentication scheme 'Anonymous'

http://stackoverflow.com/questions/1044034/wcftestclient-the-http-request-is-unauthorized-with-client-authentication-scheme

posted on 2011-11-04 17:35  中道学友  阅读(1063)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上