語言

ReportingService2010.CreateCatalogItem 方法

定義

將新項目加入報表伺服器資料庫或 SharePoint 文件庫。 此方法適用於 Report、 Model、 ResourceDatasetComponent及 DataSource 項目類型。

public:
 ReportService2010::CatalogItem ^ CreateCatalogItem(System::String ^ ItemType, System::String ^ Name, System::String ^ Parent, bool Overwrite, cli::array <System::Byte> ^ Definition, cli::array <ReportService2010::Property ^> ^ Properties, [Runtime::InteropServices::Out] cli::array <ReportService2010::Warning ^> ^ % Warnings);
[System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateCatalogItem", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")]
[System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)]
public ReportService2010.CatalogItem CreateCatalogItem(string ItemType, string Name, string Parent, bool Overwrite, byte[] Definition, ReportService2010.Property[] Properties, out ReportService2010.Warning[] Warnings);
[<System.Web.Services.Protocols.SoapDocumentMethod("http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer/CreateCatalogItem", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, RequestNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", ResponseNamespace="http://schemas.microsoft.com/sqlserver/reporting/2010/03/01/ReportServer", Use=System.Web.Services.Description.SoapBindingUse.Literal)>]
[<System.Web.Services.Protocols.SoapHeader("TrustedUserHeaderValue")>]
[<System.Web.Services.Protocols.SoapHeader("ServerInfoHeaderValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)>]
member this.CreateCatalogItem : string * string * string * bool * byte[] * ReportService2010.Property[] * Warning[] -> ReportService2010.CatalogItem
Public Function CreateCatalogItem (ItemType As String, Name As String, Parent As String, Overwrite As Boolean, Definition As Byte(), Properties As Property(), ByRef Warnings As Warning()) As CatalogItem

參數

ItemType
String

項目類型。

Name
String

新項目名稱,包括 SharePoint 模式下的副檔名。

Parent
String

包含該項目的父資料夾的完全限定網址。

Overwrite
Boolean

一個 Boolean 表示在指定地點中同名的現有項目是否應該被覆寫的表達式。

Definition
Byte[]

.rdl 報表定義、報表模型定義,或是發佈到報表伺服器的資源內容。

Properties
Property[]

一個包含物件名稱與值的物件陣列 Property ,需為該項目設定。

Warnings
Warning[]

[出]一個物件陣列 Warning ,描述在項目驗證時出現的任何警告。

傳回

一個 CatalogItem 新創造物品的物件。

屬性

範例

using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Text;  
using System.Web;  
using System.Web.Services;  
using System.Web.Services.Protocols;  

class Sample  
{  
    static void Main(string[] args)  
    {  
        ReportingService2010 rs = new ReportingService2010();  
        rs.Url = "http://<Server Name>" +  
            "/_vti_bin/ReportServer/ReportService2010.asmx";  
        rs.Credentials =   
            System.Net.CredentialCache.DefaultCredentials;  

        Byte[] definition = null;  
        Warning[] warnings = null;  
        string name = "MyReport.rdl";  

        try  
        {  
            FileStream stream = File.OpenRead("MyReport.rdl");  
            definition = new Byte[stream.Length];  
            stream.Read(definition, 0, (int)stream.Length);  
            stream.Close();  
        }  
        catch (IOException e)  
        {  
            Console.WriteLine(e.Message);  
        }  

        try  
        {  
            string parent = "http://<Server Name>/Docs/Documents/";  
            CatalogItem report = rs.CreateCatalogItem("Report", name, parent,  
                        false, definition, null, out warnings);  

            if (warnings != null)  
            {  
                foreach (Warning warning in warnings)  
                {  
                    Console.WriteLine(warning.Message);  
                }  
            }  

            else  
                Console.WriteLine("Report: {0} created successfully " +  
                                  " with no warnings", name);  
        }  
        catch (SoapException e)  
        {  
            Console.WriteLine(e.Detail.InnerXml.ToString());  
        }  
    }  
}  
Imports System  
Imports System.IO  
Imports System.Text  
Imports System.Web.Services  
Imports System.Web.Services.Protocols  

Class Sample  

    Public Shared Sub Main()  

        Dim rs As New ReportingService2010()  
        rs.Url = "http://<Server Name>" + _  
            "/_vti_bin/ReportServer/ReportService2010.asmx"  
        rs.Credentials = _  
            System.Net.CredentialCache.DefaultCredentials  

        Dim definition As [Byte]() = Nothing  
        Dim warnings As Warning() = Nothing  
        Dim name As String = "MyReport.rdl"  

        Try  
            Dim stream As FileStream = File.OpenRead("MyReport.rdl")  
            definition = New [Byte](stream.Length - 1) {}  
            stream.Read(definition, 0, CInt(stream.Length))  
            stream.Close()  

        Catch e As IOException  
            Console.WriteLine(e.Message)  
        End Try  

        Try  
            Dim parentPath As String = _  
                "http://<Server Name>/Docs/Documents/"  
            rs.CreateCatalogItem("Report", name, parentPath, False, _  
                definition, Nothing, warnings)  

            If Not (warnings Is Nothing) Then  
                Dim warning As Warning  
                For Each warning In warnings  
                    Console.WriteLine(warning.Message)  
                Next warning  

            Else  
                Console.WriteLine("Report: {0} created " + _  
                    "successfully with no warnings", name)  
            End If  

        Catch e As SoapException  
            Console.WriteLine(e.Detail.InnerXml.ToString())  
        End Try  

    End Sub  

End Class  

備註

下表顯示此操作的標頭與權限資訊。

SOAP 標頭的使用 (在) TrustedUserHeaderValue

(出局) ServerInfoHeaderValue
原生模式所需權限 這取決於物品類型:

- Report
建立新報告:CreateReport關於ParentReadProperties報告的資料來源ReadProperties與資料集
更新現有報告:UpdateReportDefinition在(包含Properties屬性)上,以及UpdateProperties在報告的資料來源上,UpdatePropertiesItem以及UpdateProperties在Item報告的資料集上
- DataSet
建立新的共享資料集: CreateReport 在 Parent AND ReadProperties 資料集的資料來源上
更新現有共享資料集:UpdateReportDefinition在 Item AND UpdateProperties 上Item(若Properties包含屬性)在資料集的資料來源上 AND UpdateProperties
- Resource, : Component
建立新物品: CreateResource 開啟 Parent
更新現有項目: UpdateContent 關於 Item
更新項目屬性: UpdateContent AND UpdateProperties on Item
- DataSource:
建立新資料來源: CreateDatasource on Parent
更新現有資料來源: UpdateContent
更新資料來源屬性: UpdateContent AND UpdateProperties
- Model: CreateModel
SharePoint 模式 必要權限 這取決於物品類型:

- Report
建立新報告:<xref:Microsoft.SharePoint.SPBasePermissions.AddListItems>關於Parent<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>定義於Definition
更新現有報告: <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> 關於 Item AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 的資料來源與資料集,定義於 Definition AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>Item (若 Properties 包含屬性)
- DataSet
建立新的共享資料集: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> 在 Parent 定義於 的 和 <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 資料來源上 Definition
更新現有的共享資料集:<xref:Microsoft.SharePoint.SPBasePermissions.EditListItems>在 Item AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 上定義於<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>Definition(Item如果Properties包含屬性) 的資料來源
- Resource, DataSource, : Component
建立新物品: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> 開啟 Parent
更新現有項目: <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> 關於 Item
- Model: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> on Parent

此方法可建立所有支援項目類型的項目。 要查看支援哪些物品類型,請使用該 ListItemTypes 方法。

Model項目類型無法被覆寫。 因此,Overwrite若 ItemType 是 Model,則參數必為 False 。 否則,會拋出 rsInvalidParameterCombination 例外。

若 ItemType 為 Report,則 XML 資料由 報表定義語言定義。 若 ItemType 為 Model,則 XML 資料由 語意模型定義語言定義。

若發生錯誤,該項目將不再被建立。

將項目加入報表伺服器資料庫或 SharePoint 文件庫 會ModifiedBy修改父資料夾的 和 ModifiedDate 屬性。

若項目名稱 rsFileExtensionRequired 中排除了適用的副檔名(例如 .rdl),則會回傳錯誤。

參數長度 Parent 不得超過 260 個字元;否則會拋出帶有錯誤碼 rsItemLengthExceed 的 SOAP 例外。

Parent參數不能為空或空,或包含以下保留字元: : ? ; @ & = + $ , \ * > < | . "。 你可以用斜線字元(/)來分隔資料夾完整路徑名稱中的項目,但不能用在資料夾名稱的末尾。

適用於