我正在编写一个winforms c#2.0应用程序,需要将XML文件放入SharePoint上的文档库中.
我想使用WebService而不是使用对象模型(这里没有sharepoint.dll引用)
我目前正在使用http://webserver/site/_vti_bin/copy.asmx webservice.
这是一些代码:
byte[] xmlByteArray;
using (MemoryStream memoryStream = new MemoryStream())
{
xmlDocument.Save(memoryStream);
xmlBytes = memoryStream.ToArray();
}
string[] destinationUrlArray = new string[] {"http://webserver/site/Doclib/UploadedDocument.xml"};
FieldInformation fieldInfo = new FieldInformation();
FieldInformation[] fields = { fieldInfo };
CopyResult[] resultsArray;
using (Copy copyService = new Copy())
{
copyService.Credentials = CredentialCache.DefaultCredentials;
copyService.Url = "http://webserver/site/_vti_bin/copy.asmx";
copyService.Timeout = 600000;
uint documentId = copyService.CopyIntoItems("", destinationUrlArray, fields, xmlByteArray, out resultsArray);
}
Run Code Online (Sandbox Code Playgroud)
当这段代码运行时,我在resultsArray out参数中得到一个结果:
DestinationURL: "http://webserver/site/Doclib/UploadedDocument.xml"
ErrorCode: UnKnown
ErrorMessage: "Object reference not set to an instance …Run Code Online (Sandbox Code Playgroud) 我正在使用SharePoint Copy Web服务将文件上载到文档库.该库正在使用包含托管元数据字段的内容类型.我无法弄清楚如何使用FieldInformation类更新此字段.我没有使用此方法设置任何其他字段的任何问题.可以在此处找到我如何使用FileInformation上传文件的示例
我试图通过其显示名称以及具有相同名称加0的"隐藏"注释字段来设置字段.
SharePointCopyWebService.FieldInformation fieldInfo = new SharePointCopyWebService.FieldInformation();
fieldInfo.DisplayName = "Internal Audit Topics_0";
fieldInfo.Type = SharePointCopyWebService.FieldType.Note;
fieldInfo.Value = "Known Term";
fieldInfoArray.Add(fieldInfo);
Run Code Online (Sandbox Code Playgroud)
附加信息:
有关如何使用FieldInformation类更新托管元数据字段的任何想法?