您的位置:首页 > 编程语言

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

2011-11-04 17:35 459 查看
本例子已经博主测试通过.

 

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

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

 

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

















 

代码如下

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, 可以发现成功的结果.





 

参考资料

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

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐