ReportingService2010.CreateCatalogItem 方法

定义

将新项添加到报表服务器数据库或 SharePoint 库。 此方法适用于ReportModelDatasetComponentResourceDataSource项类型。

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

将包含项的父文件夹的完全限定 URL。

Overwrite
Boolean

一个Boolean表达式,该表达式指示是否应该覆盖指定位置中同名的现有项。

Definition
Byte[]

要发布到报表服务器的 .rdl 报表定义、报表模型定义或资源内容。

Properties
Property[]

一个 Property 对象的数组,该数组包含要为项设置的属性名和属性值。

Warnings
Warning[]

[out] 一个 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 标头用法 (In) TrustedUserHeaderValue

(Out) ServerInfoHeaderValue
本机模式所需的权限 取决于项类型:

- Report
创建新报表: CreateReportParent 报表数据源上的 AND ReadProperties 上,在 ReadProperties 报表的数据集上
更新现有报表: UpdateReportDefinitionItem 在 (上,如果Properties包含属性) UpdateProperties AND UpdatePropertiesItem报表的数据源和报表数据集的 AND UpdateProperties
- DataSet
创建新的共享数据集:CreateReport在数据集的数据源上的 AND ReadPropertiesParent
更新现有共享数据集:UpdateReportDefinition如果包含数据集数据源上的属性ItemUpdateProperties) AND,则 (上的 AND UpdatePropertiesPropertiesItem
- Resource, Component:
创建新项: CreateResource on Parent
更新现有项: UpdateContent on Item
更新项属性: UpdateContent AND UpdateProperties on Item
- DataSource:
创建新数据源: CreateDatasourceParent
更新现有数据源: UpdateContent
更新数据源属性: UpdateContent AND UpdateProperties
- Model: CreateModel
SharePoint 模式所需权限 取决于项类型:

- Report
创建新报表:<xref:Microsoft.SharePoint.SPBasePermissions.AddListItems>在 中定义的数据源和数据集上的 AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 上ParentDefinition
更新现有报表:<xref:Microsoft.SharePoint.SPBasePermissions.EditListItems>如果Item<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>包含属性) ,则 (更新Properties在 AND 中Definition定义的数据源和数据集上的 Item AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>
- DataSet
创建新的共享数据集:<xref:Microsoft.SharePoint.SPBasePermissions.AddListItems>在 中定义的数据源上的 AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 上ParentDefinition
更新现有共享数据集:<xref:Microsoft.SharePoint.SPBasePermissions.EditListItems>在 Item (上<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>Definition定义的数据源上的 AND <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 上Item(如果Properties包含属性)
- Resource, DataSource, Component:
创建新项: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> on Parent
更新现有项: <xref:Microsoft.SharePoint.SPBasePermissions.EditListItems> on Item
- Model: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> on Parent

此方法可以创建所有受支持的项类型的项。 若要查看支持哪些项类型,请使用 ListItemTypes 方法。

Model无法覆盖项类型。 因此,如果 为 ,Overwrite则 参数必须为 FalseModelItemType 否则,将引发 rsInvalidParameterCombination 异常。

如果 ItemTypeReport,则 XML 数据由 报表定义语言定义。 如果 ItemTypeModel,则 XML 数据由 语义模型定义语言定义

如果发生错误,则不会创建该项。

将项添加到报表服务器数据库或 SharePoint 库会 ModifiedBy 修改父文件夹的 和 ModifiedDate 属性。

如果适用的文件扩展名 (例如,从项名称中排除 .rdl) ,则将返回错误 rsFileExtensionRequired

参数的 Parent 长度不能超过 260 个字符;否则,将引发 SOAP 异常,错误代码 为 rsItemLengthExceededed

参数 Parent 不能为 null 或空,也不能包含以下保留字符: : ? ; @ & = + $ , \ * > < | . "。 可以使用 /) (正斜杠字符分隔文件夹的完整路径名称中的项目,但不能在文件夹名称的末尾使用它。

适用于