语言

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

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

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数据集
更新现有报告:在(包含属性)UpdateProperties上,以及在UpdatePropertiesItem报告的数据源上,以及UpdateProperties在报告的数据集上PropertiesItemUpdateReportDefinition
- DataSet
创建新的共享数据集:CreateReport在数据集ReadProperties的数据源上Parent
更新现有共享数据集:UpdateReportDefinition在 AND 上Item(如果Properties包含属性)在 AND UpdatePropertiesUpdateProperties 上 和 在数据集Item的数据源上更新
- 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>关于AND<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>中定义的数据Item<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>Definition源和数据集(如果Properties包含属性)Item
- DataSet
创建新的共享数据集: <xref:Microsoft.SharePoint.SPBasePermissions.AddListItems> 在 Parent 定义 <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems> 于 和 的数据源上 Definition
更新现有共享数据集:在 和 上定义的数据DefinitionItem<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>源(如果Properties包含属性)<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>Item<xref:Microsoft.SharePoint.SPBasePermissions.EditListItems>
- 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参数不能为空或空,也不能包含以下保留字符: : ? ; @ & = + $ , \ * > < | . "。 你可以用斜杠字符(/)分隔文件夹完整路径名称中的项目,但不能在文件夹名称末尾使用。

适用于