记一个调用_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   中道学友  阅读(1065)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2010-11-04 解决SharePoint 2003的爬网性能问题- 之二
2010-11-04 解决SharePoint 2003的爬网性能问题- 之一
2009-11-04 汇编语言基础之八- 动手练习,将前面的知识用于实践
2009-11-04 汇编语言基础之七- 框架指针的省略(FPO)

导航

< 2011年11月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

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

点击右上角即可分享
微信分享提示