2012-04-09 99 views
4

我正在使用SDL Tridion 2011 SP1中的核心服務創建架構。在架構的創建中,我使用了架構的自定義名稱空間URI。一般來說,當我們直接創建通過外表套上CME一個架構,我們將得到一個命名空間URI自動生成與uuid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX使用SDL中的核心服務創建架構Tridion 2011 SP1

開始我已經使用這個代碼來創建一個架構:

Tridion.ContentManager.CoreService.Client.SchemaData schemas = new SchemaData 
{ 
    Title = "coreservicesschema3", 
    Description = "coreservicesschema", 
    Id = "tcm:0-0-0", 
    LocationInfo = new LocationInfo 
    { 
     OrganizationalItem = 
      new LinkToOrganizationalItemData { IdRef = "tcm:7-18-2" } 
    }, 

    RootElementName = "Content", 
    NamespaceUri = "customnamespaceuri", 
    Xsd = xsd.ToString(SaveOptions.None) 
}; 
schemas = (SchemaData)client.Create(schemas, new ReadOptions()); 
Response.Write("<BR>" +"new schema id"+ schemas.Id); 
Response.Write("<BR>" + "new schema Name" + schemas.Title); 
//schema created 

任何人都可以說明如何創建具有默認名稱空間URI的模式?

謝謝

回答

6

你爲了創建核心服務架構所需要的最少的代碼如下:

using (var client = new SessionAwareCoreServiceClient(netTcpBinding, remoteAddress)) 
{ 
    SchemaData schemaData = client.GetDefaultData(ItemType.Schema, folderId) as SchemaData; 
    schemaData.Description = "description"; 
    schemaData = client.Save(schemaData, readOptions) as SchemaData; 
    schemaData = client.CheckIn(schemaData.Id, readOptions) as SchemaData; 

    Console.WriteLine("Schema: " + schemaData.LocationInfo.WebDavUrl); 
} 

的模式將與默認命名空間創建。在這個例子中,它也不包含任何字段,但這不是你要求的。

相關問題