你如何使用SharePoint复制Web服务的CopyIntoItems方法? [英] How do you use the CopyIntoItems method of the SharePoint Copy web service?

查看:150
本文介绍了你如何使用SharePoint复制Web服务的CopyIntoItems方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用SharePoint复制Web服务的CopyIntoItems方法加载文档文件到一个文档库中的SharePoint。

下面执行,并返回0(成功)的code。另外,CopyResult []数组返回1值与一个成功结果。但是,我找不到文档库中的任何地方。

我有两个问题:

  1. 在任何人都可以看到什么毛病我code或暗示的变化?
  2. 在任何人都可以建议我怎么能调试这在服务器端。我没有对与SharePoint体验一个巨大的数额。如果我可以跟踪哪些是通过记录或服务器端的其它方法怎么回事,它可以帮助我弄清楚到底是怎么回事。

code样品:<​​/ STRONG>

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

SPCopyWebService.FieldInformation I1 =新SPCopyWebService.FieldInformation {显示名称=名称,INTERNALNAME =名称中输入= SPListTransferSpike1.SPCopyWebService.FieldType.Text,值=Test1Name};
SPCopyWebService.FieldInformation I2 =新SPCopyWebService.FieldInformation {显示名称=标题,INTERNALNAME =标题,类型= SPListTransferSpike1.SPCopyWebService.FieldType.Text,值=Test1Title};

SPCopyWebService.FieldInformation []信息= {I1,I2};

SPCopyWebService.CopyResult []结果;

byte []的数据= File.ReadAllBytes(C:\\ SomePath \\ Test1Data.txt);

UINT RET = SPCopyNew.CopyIntoItems(,destinationUrls,信息,数据,输出结果);
 

那得到的东西的工作编辑:

://空HTTP到SourceUrl场

我加入了我的code工作。下面纳特的答案很可能因为这个原因工作。这是我改变得到它的工作就行了。

  //更改
UINT RET = SPCopyNew.CopyIntoItems(HTTP://空,destinationUrls,信息,数据,输出结果);
 

解决方案

我认为这个问题可能会在尝试使用web服务设置名称属性。我有一些失败这样做。 由于名是该文件的名称,你可能有一些成功

 字符串targetDocName =Test1Name.txt;
    字符串DESTINATIONURL = Uri.EscapeDataString(https://someaddress.com/Reports/Temp/+ targetDocName);
    字符串[] destinationUrls = {DESTINATIONURL};

    SPCopyWebService.FieldInformation I1 =新SPCopyWebService.FieldInformation {显示名称=标题,INTERNALNAME =标题,类型= SPListTransferSpike1.SPCopyWebService.FieldType.Text,值=Test1Title};
    SPCopyWebService.FieldInformation []信息= {I1};
    SPCopyWebService.CopyResult []结果;
    byte []的数据= File.ReadAllBytes(C:\\ SomePath \\ Test1Data.txt);
    UINT RET = SPCopyNew.CopyIntoItems(DESTINATIONURL,destinationUrls,信息,数据,输出结果);
 

注:我已经使用了目标的源属性。 <一href="http://stackoverflow.com/questions/787610/how-do-you-copy-a-file-into-sharepoint-using-a-webservice/791847#791847">Don't很清楚为什么,但它的伎俩。

I am attempting to load document files into a document library in SharePoint using the CopyIntoItems method of the SharePoint Copy web service.

The code below executes and returns 0 (success). Also, the CopyResult[] array returns 1 value with a "Success" result. However, I cannot find the document anywhere in the library.

I have two questions:

  1. Can anyone see anything wrong with my code or suggest changes?
  2. Can anyone suggest how I could debug this on the server side. I don't have a tremendous amount of experience with SharePoint. If I can track what is going on through logging or some other method on the server side it may help me figure out what is going on.

Code Sample:

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);

Edit that got things working:

I got my code working by adding "http://null" to the SourceUrl field. Nat's answer below would probably work for that reason. Here is the line I changed to get it working.

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

解决方案

I think the issue may be in trying to set the "Name" property using the webservice. I have had some fail doing that. Given the "Name" is the name of the document, you may have some success with

    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);

Note: I have used the "target" as the "source" property. Don't quite know why, but it does the trick.

这篇关于你如何使用SharePoint复制Web服务的CopyIntoItems方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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