Отправка примера, созданного мной ранее, на случай, если это поможет .....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreWebService.ServiceReference1;
namespace CoreWebService
{
class CoreWebServiceSamples
{
public static void createComponent()
{
string schemaWebDavUrl = "/webdav/020%20Content/Building%20Blocks/Content/wstest/wstest.xsd";
string folderWebDavUrl = "/webdav/020%20Content/Building%20Blocks/Content/wstest";
CoreServicesUtil coreServicesUtil = new CoreServicesUtil();
FolderData folderData = coreServicesUtil.getFolderData(folderWebDavUrl);
ComponentData componentData = folderData.AddComponentData();
componentData.Title = "This is a Test ..... ";
componentData.Schema = coreServicesUtil.getLinkToSchemaData(schemaWebDavUrl);
SchemaData schemaData = coreServicesUtil.getSchemaData(schemaWebDavUrl);
componentData.Content = xmlUtil.GetNewXmlNode("Content", schemaData.NamespaceUri);
componentData.Metadata = xmlUtil.GetNewXmlNode("Metadata", schemaData.NamespaceUri);
componentData.AddSingleField("singlefield", "singlefield sample", schemaData.NamespaceUri);
componentData = (ComponentData)coreServicesUtil.coreServiceClient.Save(componentData, coreServicesUtil.readOptions);
coreServicesUtil.coreServiceClient.CheckIn(componentData.Id, coreServicesUtil.readOptions);
coreServicesUtil.coreServiceClient.Close();
}
}
}
CoreServicesUtil .....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreWebService.ServiceReference1;
using CoreWebService.Properties;
using System.Xml;
using System.Xml.Serialization;
namespace CoreWebService
{
public class CoreServicesUtil
{
public CoreService2010Client coreServiceClient;
public ReadOptions readOptions;
/// <summary>
///
/// </summary>
public CoreServicesUtil()
{
this.coreServiceClient = new CoreService2010Client("basicHttp_2010");
this.readOptions = new ReadOptions();
}
public FolderData getFolderData(string tcmuri)
{
FolderData folderData = (FolderData)coreServiceClient.Read(tcmuri,ReadOptions);
return folderData;
}
public LinkToSchemaData getLinkToSchemaData(string tcmuri)
{
LinkToSchemaData linkToSchemaData = new ServiceReference1.LinkToSchemaData();
linkToSchemaData.IdRef = getSchemaData(tcmuri).Id;
return linkToSchemaData;
}
public SchemaData getSchemaData(string tcmuri)
{
SchemaData schemaData = (SchemaData)coreServiceClient.Read(tcmuri, readOptions);
return schemaData;
}
}
}
XMLUtil ....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace CoreWebService
{
public class xmlUtil
{
/**
* <summary>
* Name: enumeration
* </summary>
**/
public enum Scope
{
Content,
Metadata
}
/**
* <summary>
* Name: AddItemLinkFieldGeneric
* Description: basic method for add component links, multimedia links, keyword field to an XmlElement
* </summary>
**/
/**
* <summary>
* Name: getXMLElementData
* Description: adds a single field to an XmlElement
* </summary>
**/
public static XmlElement getXMLElementData(string dataNode)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(dataNode);
return doc.DocumentElement;
}
/**
* <summary>
* Name: GetNewXmlNode
* Description: returns an xml element based on the name and schema
* </summary>
**/
public static string GetNewXmlNode(string Name, string Namespace)
{
XmlDocument doc = new XmlDocument();
XmlElement xmlElem = doc.CreateElement(Name, Namespace);
doc.AppendChild(xmlElem);
return doc.FirstChild.OuterXml;
}
}
}