如何使用SharePoint Copy Web服务的CopyIntoItems方法?

Mat*_*ley 4 .net c# sharepoint web-services

我正在尝试使用SharePoint Copy Web服务的CopyIntoItems方法将文档文件加载到SharePoint中的文档库中.

下面的代码执行并返回0(成功).此外,CopyResult []数组返回1个带有"Success"结果的值.但是,我无法在库中的任何位置找到该文档.

我有两个问题:

  1. 任何人都可以看到我的代码有什么问题或建议更改?
  2. 任何人都可以建议我如何在服务器端调试它.我没有大量的SharePoint经验.如果我可以通过日志记录或服务器端的其他方法跟踪正在发生的事情,它可以帮助我弄清楚发生了什么.

代码示例:

string[] destinationUrls = { Uri.EscapeDataString("https://someaddress.com/Reports/Temp") };

SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Name", InternalName = "Name", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Name" };
SPCopyWebService.FieldInformation i2 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };

SPCopyWebService.FieldInformation[] info = { i1, i2 };

SPCopyWebService.CopyResult[] result;

byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");

uint ret = SPCopyNew.CopyIntoItems("", destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)

编辑让事情有效:

我通过在SourceUrl字段中添加" http:// null "来使我的代码正常工作.Nat的答案可能就是出于这个原因.这是我改变它以使其工作的线.

// Change
uint ret = SPCopyNew.CopyIntoItems("http://null", destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)

Nat*_*Nat 6

我认为问题可能在于尝试使用webservice设置"Name"属性.我做了一些失败.鉴于"名称"是文档的名称,您可能会取得一些成功

    string targetDocName = "Test1Name.txt";
    string destinationUrl = Uri.EscapeDataString("https://someaddress.com/Reports/Temp/" + targetDocName);
    string[] destinationUrls = { destinationUrl };

    SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
    SPCopyWebService.FieldInformation[] info = { i1};
    SPCopyWebService.CopyResult[] result;
    byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
    uint ret = SPCopyNew.CopyIntoItems(destinationUrl, destinationUrls, info, data, out result);
Run Code Online (Sandbox Code Playgroud)

注意:我使用"目标"作为"源"属性.不太清楚为什么,但它确实可以解决问题.