我收到以下错误:
服务方法的一个或多个输入参数丢失或无效。
何时
ObjectService.createDocument(repositoryId,objectPropertyCollection,rootFolderId,myContentStream,ObjectService.enumVersioningState.none,null,addAclcontrol,null,ref extType);
被调用。这就是我设置所有这些参数的方法:
//Get repositoryId, and rootFolder id.
string repositoryId = RepositoryStore[contentType];
RepositoryService.cmisRepositoryInfoType repoInfo =_controller.RepositoryClient.getRepositoryInfo(repositoryId, new RepositoryService.cmisExtensionType());
string rootFolder = repoInfo.rootFolderId;
string theActualName = filename.Substring(filename.LastIndexOf("\\") + 1);
//Create a cmisContentStreamType.
ObjectService.cmisContentStreamType fileStream = new ObjectService.cmisContentStreamType();
fileStream.stream = File.ReadAllBytes(filename);
fileStream.filename = theActualName;
fileStream.length = fileStream.stream.Length.ToString();
fileStream.mimeType = "application/pdf";
//Setting the acl objects needed to create the document.
ObjectService.cmisAccessControlEntryType homeMembers = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType owners = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType viewers = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType visitors = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlPrincipalType ownersPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
ownersPrincipalType.principalId = @"Home Owners";
owners.principal = ownersPrincipalType;
owners.permission = new string[] { "cmis:all" };
ObjectService.cmisAccessControlPrincipalType homePrincipalType = new ObjectService.cmisAccessControlPrincipalType();
homePrincipalType.principalId = @"Home Members";
homeMembers.principal = homePrincipalType;
homeMembers.permission = new string[] { "cmis:write" };
ObjectService.cmisAccessControlPrincipalType viewersPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
homePrincipalType.principalId = @"Viewers";
homeMembers.principal = viewersPrincipalType;
homeMembers.permission = new string[] { "cmis:read" };
ObjectService.cmisAccessControlPrincipalType visitorsPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
homePrincipalType.principalId = @"Home Visitors";
homeMembers.principal = visitorsPrincipalType;
homeMembers.permission = new string[] { "cmis:read" };
ObjectService.cmisAccessControlEntryType[] addAclControl = new ObjectService.cmisAccessControlEntryType[] { homeMembers, owners, viewers, visitors };
ObjectService.cmisExtensionType exttype = new ObjectService.cmisExtensionType();
ObjectService.cmisPropertiesType objectPropertyArray = MakedocumentPropertiesList(theActualName,fileStream.length);
private ObjectService.cmisPropertiesType MakedocumentPropertiesList(string fileName,string contentStreamLength)
{
List<ObjectService.cmisProperty> arrProps = new List<ObjectService.cmisProperty>();
ObjectService.cmisPropertiesType props = new ObjectService.cmisPropertiesType();
arrProps.Add(GetPropertyString("Name", "cmis:name", "mydocuemntname", "FileLeafRef"));
arrProps.Add(GetPropertyId("cmis:baseTypeId", "cmis:baseTypeId", "cmis:document", "cmis:baseTypeId"));
props.Items = arrProps.ToArray();
return props;
}
private ObjectService.cmisPropertyString GetPropertyString(string displayName, string queryName, string value, string localName)
{
ObjectService.cmisPropertyString title = new ObjectService.cmisPropertyString();
title.localName = localName;
title.displayName = displayName;
title.queryName = queryName;
title.propertyDefinitionId = displayName;
title.value = new string[] { value };
return title;
}
private ObjectService.cmisPropertyId GetPropertyId(string displayName, string queryName, string value, string localName)
{
ObjectService.cmisPropertyId id = new ObjectService.cmisPropertyId();
id.localName = localName;
id.displayName = displayName;
id.queryName = queryName;
id.propertyDefinitionId = displayName;
id.value = new string[] { value };
return id;
}
答案 0 :(得分:1)
您无法设置“cmis:baseTypeId”属性,但必须设置“cmis:objectTypeId”属性。尝试交换第二个属性的id。
除此之外,你应该看看DotCMIS。它可以为你节省很多工作。
答案 1 :(得分:0)
我拿了你的代码并且我更正了..现在它对我来说很实用..看看:
string user = txtLogin.Text;
string password = txtPwd.Text;
DemoCMISForms.RepositoryService.RepositoryServicePortClient repService = new DemoCMISForms.RepositoryService.RepositoryServicePortClient("BasicHttpBinding_IRepositoryServicePort2");
repService.ClientCredentials.UserName.UserName = user;
repService.ClientCredentials.UserName.Password = password;
DemoCMISForms.ObjectService.ObjectServicePortClient objectService = new DemoCMISForms.ObjectService.ObjectServicePortClient("BasicHttpBinding_IObjectServicePort2");
objectService.ClientCredentials.UserName.UserName = user;
objectService.ClientCredentials.UserName.Password = password;
//Get repositoryId, and rootFolder id.
RepositoryService.cmisRepositoryInfoType repoInfo = repService.getRepositoryInfo(idRep, new RepositoryService.cmisExtensionType());
string rootFolder = repoInfo.rootFolderId;
string theActualName = textBox1.Text.Substring(textBox1.Text.LastIndexOf("\\") + 1);
//Create a cmisContentStreamType.
ObjectService.cmisContentStreamType fileStream = new ObjectService.cmisContentStreamType();
fileStream.stream = File.ReadAllBytes(textBox1.Text);
fileStream.filename = theActualName;
fileStream.length = fileStream.stream.Length.ToString();
fileStream.mimeType = "text/plain";
//Setting the acl objects needed to create the document.
ObjectService.cmisAccessControlEntryType homeMembers = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType owners = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType viewers = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlEntryType visitors = new ObjectService.cmisAccessControlEntryType();
ObjectService.cmisAccessControlPrincipalType ownersPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
ownersPrincipalType.principalId = @"Home Owners";
owners.principal = ownersPrincipalType;
owners.permission = new string[] { "cmis:all" };
ObjectService.cmisAccessControlPrincipalType homePrincipalType = new ObjectService.cmisAccessControlPrincipalType();
homePrincipalType.principalId = @"Home Members";
homeMembers.principal = homePrincipalType;
homeMembers.permission = new string[] { "cmis:write" };
ObjectService.cmisAccessControlPrincipalType viewersPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
viewersPrincipalType.principalId = @"Viewers";
viewers.principal = viewersPrincipalType;
viewers.permission = new string[] { "cmis:read" };
ObjectService.cmisAccessControlPrincipalType visitorsPrincipalType = new ObjectService.cmisAccessControlPrincipalType();
visitorsPrincipalType.principalId = @"Home Visitors";
visitors.principal = visitorsPrincipalType;
visitors.permission = new string[] { "cmis:read" };
ObjectService.cmisAccessControlEntryType[] addAclControl = new ObjectService.cmisAccessControlEntryType[] { homeMembers, owners, viewers, visitors };
ObjectService.cmisExtensionType exttype = new ObjectService.cmisExtensionType();
ObjectService.cmisPropertiesType objectPropertyArray = MakedocumentPropertiesList(theActualName, fileStream.length);
objectService.createDocument(idRep, objectPropertyArray, idFolder, fileStream, ObjectService.enumVersioningState.major, null, addAclControl, null, ref exttype);
}
private ObjectService.cmisPropertiesType MakedocumentPropertiesList(string fileName, string contentStreamLength)
{
List<ObjectService.cmisProperty> arrProps = new List<ObjectService.cmisProperty>();
ObjectService.cmisPropertiesType props = new ObjectService.cmisPropertiesType();
arrProps.Add(GetPropertyString(fileName, "cmis:name", fileName, "FileLeafRef"));
arrProps.Add(GetPropertyId("cmis:objectTypeId", "cmis:objectTypeId", "cmis:document", "cmis:objectTypeId"));
props.Items = arrProps.ToArray();
return props;
}
private ObjectService.cmisPropertyString GetPropertyString(string displayName, string queryName, string value, string localName)
{
ObjectService.cmisPropertyString title = new ObjectService.cmisPropertyString();
title.localName = localName;
title.displayName = displayName;
title.queryName = queryName;
title.propertyDefinitionId = displayName;
title.value = new string[] { value };
return title;
}
private ObjectService.cmisPropertyId GetPropertyId(string displayName, string queryName, string value, string localName)
{
ObjectService.cmisPropertyId id = new ObjectService.cmisPropertyId();
id.localName = localName;
id.displayName = displayName;
id.queryName = queryName;
id.propertyDefinitionId = displayName;
id.value = new string[] { value };
return id;
}
我发现一些复制粘贴操作后保持不变的变量!我也用这个例子和一个文本文件! 希望我能帮到你!
PS:我还没处理文件类型的问题,我刚刚用文本文件制作了示例函数..而且我从SP站点调用的列表中的版本控制是一个问题所以我必须在我之前验证添加任何文件..