2011-03-28 13 views
16

मैं रिपोर्टिंग सर्वर वेब सेवा का उपयोग कर कोड द्वारा एक रिपोर्टिंग सर्वर समाधान को तैनात करने की कोशिश कर रहा हूं: http://_Server_Name_/ReportServer/ReportService2010.asmx?wsdlReportingService2010 का उपयोग कैसे करें?

दुख की बात है कि मुझे ऑनलाइन कोई उदाहरण नहीं मिल रहा है। MSDN से केवल कुछ अस्पष्ट जानकारी।

जब बिजनेस इंटेलिजेंस डेवलपमेंट स्टूडियो के माध्यम से प्रकाशित होता है, तो यह साझा डेटा स्रोत प्रकाशित करता है और फिर रिपोर्ट प्रकाशित करता है। मैं बहुत सी # पर कुछ इसी तरह करने के लिए कोशिश कर रहा हूँ:

var service = new ReportingService2010(); 
service.Credentials = new NetworkCredential(username, password, domain); 

foreach(var dataSourcePath in GetDataSources()) { 
    string name = Path.GetFileNameWithoutExtension(dataSourcePath); 
    Byte[] content = GetFileContent(dataSourcePath); 
    service.CreateCatalogItem("DataSource", name, parent, true, content, null, out warnings); 
} 

लेकिन CreateCatalogItem मेरा पीछा SoapException अपवाद देता है:

The input XML does not conform to the schema. XML grammar is described in the API documentation. For XML in reports, refer to Report Definition Language syntax. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidXmlException: The input XML does not conform to the schema. XML grammar is described in the API documentation. For XML in reports, refer to Report Definition Language syntax.

वहाँ कुछ मैं गलत या किसी अन्य दृष्टिकोण मैं लेना चाहिए कर रहा हूँ है ?

+0

मुझे CreateCatalogItem का उपयोग करके डेटासोर्स को धक्का देने में एक ही समस्या है। –

+0

@ पीटर स्टीफेंस, जो रिपोर्टिंग सर्वर आप अपने विकास और अपनी उत्पादन मशीन पर उपयोग कर रहे हैं? – dcarneiro

उत्तर

2

मैंने वास्तव में कैटलॉग के माध्यम से डेटासोर्स जोड़ने की कोशिश नहीं की है, लेकिन मुझे एक तरीका पता है जो निश्चित रूप से काम करता है। आपको केवल एक डेटास्रोत बनाना है जो आपके द्वारा प्रकाशित रिपोर्ट में संदर्भित डेटासोर्स के समान नाम है। हालांकि Reportingservice2010 के लिए नहीं लिखा

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; 

    string name = "AdventureWorks.rsds"; 
    string parent = "http://<Server Name>/Docs/Documents/"; 

    // Define the data source definition. 
    DataSourceDefinition definition = new DataSourceDefinition(); 
    definition.CredentialRetrieval = 
     CredentialRetrievalEnum.Integrated; 
    definition.ConnectString = 
     "data source=(local);initial catalog=AdventureWorks"; 
    definition.Enabled = true; 
    definition.EnabledSpecified = true; 
    definition.Extension = "SQL"; 
    definition.ImpersonateUserSpecified = false; 
    //Use the default prompt string. 
    definition.Prompt = null; 
    definition.WindowsCredentials = false; 

    try 
    { 
     rs.CreateDataSource(name, parent, false, 
      definition, null); 
    } 
    catch (SoapException e) 
    { 
     Console.WriteLine(e.Detail.InnerXml.ToString()); 
    } 
} 
} 

यहाँ, एक रिपोर्ट प्रकाशित और एक डेटा स्रोत बनाने के लिए कोड है, यह यह 2010 की अवधि में कभी मुश्किल नहीं होना चाहिए: यहाँ ReportingService2010 का उपयोग कर MSDN से एक उदाहरण है:

Byte[] definition = null; 
Warning[] warnings = null; 
string parentFolder = "AdventureWorks Sample Reports"; 
string parentPath = "/" + parentFolder; 
string filePath = "D:\\Program Files\\Microsoft SQL Server\\100\\Samples\\Reporting Services\\Report Samples\\AdventureWorks Sample Reports\\"; 
public void Main() 
{ 
rs.Credentials = System.Net.CredentialCache.DefaultCredentials; 

//Create the parent folder 
try { 
    rs.CreateFolder(parentFolder, "/", null); 
    Console.WriteLine("Parent folder {0} created successfully", parentFolder); 
} catch (Exception e) { 
    Console.WriteLine(e.Message); 
} 

//Publish the sample reports 
PublishReport("EmbeddedDatasource"); 
} 

public void PublishReport(string reportName) 
{ 
try { 
    FileStream stream = File.OpenRead(filePath + reportName + ".rdl"); 
    definition = new Byte[stream.Length + 1]; 
    stream.Read(definition, 0, Convert.ToInt32(stream.Length)); 
    stream.Close(); 
} catch (IOException e) { 
    Console.WriteLine(e.Message); 
} 
try { 
    warnings = rs.CreateReport(reportName, parentPath, false, definition, null); 
    if ((warnings != null)) { 
     Warning warning = default(Warning); 
     foreach (warning in warnings) { 
      Console.WriteLine(warning.Message); 
     } 
    } else { 
     Console.WriteLine("Report: {0} published successfully with no warnings", reportName); 
    } 
} catch (Exception e) { 
    Console.WriteLine(e.Message); 
} 
try { 
    DataSourceDefinition definition = new DataSourceDefinition(); 
    definition.CredentialRetrieval = CredentialRetrievalEnum.Store; 
    DataSourceReference reference = new DataSourceReference(); 

    definition.ConnectString = "Data Source=.;Initial Catalog=AdventureWorks"; 
    definition.UserName = "username"; 
    definition.Password = "password"; 
    definition.Extension = "SQL"; 
    definition.WindowsCredentials = true; 
    DataSource[] sources = new DataSource[1]; 
    DataSource s = new DataSource(); 
    s.Item = definition; 
    s.Name = "DataSource1"; 
    sources(0) = s; 
    rs.SetItemDataSources("/AdventureWorks Sample Reports/EmbeddedDatasource", sources); 

} catch (Exception exp) { 
    Console.WriteLine(exp.Message); 
} 
} 
11

मुझे एक ही समस्या थी।

<?xml version="1.0" encoding="utf-8"?> 
<RptDataSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="DataSourceXML"> 
    <ConnectionProperties> 
     <Extension>XML</Extension> 
     <ConnectString>http://server/_vti_bin/lists.asmx</ConnectString> 
     <IntegratedSecurity>true</IntegratedSecurity> 
    </ConnectionProperties> 
    <DataSourceID></DataSourceID> 
</RptDataSource> 

सही एक है:

<?xml version="1.0" encoding="utf-8"?> 
<DataSourceDefinition xmlns="http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource"> 
    <Extension>XML</Extension> 
    <ConnectString>http://server/_vti_bin/lists.asmx</ConnectString> 
    <CredentialRetrieval>Prompt</CredentialRetrieval> 
    <WindowsCredentials>True</WindowsCredentials> 
    <Prompt></Prompt> 
    <Enabled>True</Enabled> 
</DataSourceDefinition> 

आप अपने रिपोर्टिंग से डेटा स्रोत को डाउनलोड करके इस परिभाषा प्राप्त कर सकते हैं - इस तरह तुम गलत डेटा स्रोत फ़ाइल स्वरूप का उपयोग कर रहे हैं: समाधान मैंने पाया इस प्रकार है सर्वर।

5

रिपोर्ट सर्वर से प्रत्येक आइटम के लिए एक्सएमएल प्राप्त करने का एक तरीका है, अर्थात् रिपोर्टिंग सर्वर से "डेटासोर्स" सहित किसी ऑब्जेक्ट के लिए एक्सएमएल परिभाषा को "डाउनलोड" करने का एक तरीका है (आपका रिपोर्ट सर्वर डेटाबेस मानते हुए है ReportServer):

select *, CONVERT(varchar(max),Content) as ContentText 
from 
(
     SELECT 
    ItemID,Name,[Type],TypeDescription 
    , CASE 
     WHEN LEFT(Content,3) = 0xEFBBBF 
     THEN CONVERT(varbinary(max),SUBSTRING(Content,4,LEN(Content))) 
     ELSE 
     Content 
     END AS Content 
    from 
    (
     SELECT 
     ItemID,Name,[Type] 
     , CASE Type 
      WHEN 2 THEN 'Report' 
      WHEN 5 THEN 'Data Source' 
      WHEN 7 THEN 'Report Part' 
      WHEN 8 THEN 'Shared Dataset' 
      ELSE 'Other' 
     END AS TypeDescription 
     , CONVERT(varbinary(max),Content) AS Content  
     FROM ReportServer.dbo.Catalog 
     WHERE Type IN (2,5,8) 
    ) as ItemContentBinaries 
) as ItemContentNoBOM 

एक SQL डेटा इस स्रोत के लिए परिभाषा हम था: ध्यान में रखने की

<?xml version="1.0" encoding="utf-8"?> 
<DataSourceDefinition xmlns="http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource"> 
    <Extension>SQL</Extension> 
    <ConnectString>Data Source=MyDatabaseServer;Initial Catalog=MyDatabase</ConnectString> 
    <CredentialRetrieval>Integrated</CredentialRetrieval> 
    <Enabled>True</Enabled> 
</DataSourceDefinition> 

एक बात है कि हम .rds फ़ाइलों को बदलने के तरीके नहीं मिल सका है और इसे रिपोर्टिंग आईडीई और स्वचालित डिप्लो दोनों के साथ काम करने के लिए मिलता है yment। हम विजुअल स्टूडियो 2008 के साथ .rptproj का उपयोग कर रहे हैं (विजुअल स्टूडियो 2010 एसक्यूएल सर्वर 2008 आर 2 रिपोर्टिंग सर्वर परियोजनाओं के साथ काम नहीं कर सकता)। विजुअल स्टूडियो 2008 को पुरानी स्कीमा प्रारूप में डेटासोर्स फ़ाइलों (* .rds फ़ाइलों) की आवश्यकता होती है, जो rs.exe और CreateCatalogItem के साथ काम नहीं करेगा।

यदि हम .rds फ़ाइल को CreateCatalogItem के साथ काम करने वाले प्रारूप में रूपांतरित करते हैं, तो SQL Server 2008 R2 रिपोर्टिंग सर्वर प्रोजेक्ट खोलने का प्रयास करते समय निम्न त्रुटि देता है।rptproj:

Microsoft SQL Server Report Designer The report definition failed to load: There is an error in XML document (2, 2).. Verify the report definition conforms to the correct schema. There is an error in XML document (2, 2). (System.Xml)

<DataSourceDefinition xmlns='http://schemas.microsoft.com/sqlserver/reporting/2006/03/reportdatasource'> was not expected. (wp6bqrt3) 
2

बस कुछ मार्गदर्शन प्रदान करते हैं करना चाहते थे। मैंने रिपोर्टिंग सेवा सेवाओं के साथ एक साल पहले कुछ मुद्दों के माध्यम से भाग लिया था और ऑनलाइन छोटी जानकारी भी मिली, इसलिए मैंने इससे क्या सीखा, मैंने यहां पोस्ट किया - उम्मीद है कि इससे मदद मिलती है।

http://www.ericwitkowski.com/2013/05/an-introduction-to-querying-and.html

3

मैं बस पता चला है कि CreateCatalogItem के लिए msdn documentation भ्रामक है।

मैं देशी मोड (नहीं शेयरप्वाइंट) वेब सेवा का उपयोग करने में एक नई रिपोर्ट को तैनात करने की कोशिश कर रहा था, और एक त्रुटि मिली जब मैं जनक पैरामीटर के लिए मार्गदर्शन का पालन किया:

Parent

Type: System.String

The fully qualified URL for the parent folder that will contain the item.

पृष्ठ पर कोड उदाहरण यह दिखाता है:

string parent = "http://<Server Name>/<FolderPath>/"; 

मैं:

string parent = "http://<Server Name>/Docs/Documents/"; 

तो मैं इस प्रारूप का उपयोग करने की कोशिश की

Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException: 
The path of the item 'http://<Server Name>/<FolderPath>/' is not valid. 
The full path must be less than 260 characters long; other restrictions apply. 
If the report server is in native mode, the path must start with slash. 

तो मैं टिप्पणी में यह देखा है (उदाहरण के जो अंत में एक स्लेश है विरोधाभासी):

The Parent parameter cannot be null or empty or contain the following reserved characters: : ? ; @ & = + $ , \ * > < | . ". You can use the forward slash character (/) to separate items in the full path name of the folder, but you cannot use it at the end of the folder name.

परीक्षण और त्रुटि के बाद मैं अंत में तैनात करने के लिए कर रहा था निम्न त्रुटि मिला शुरुआत में फॉरवर्ड स्लैश के साथ, पैर पथ पर पैरेंट पथ को सेट करके रिपोर्ट करें:

string parent = "/<FolderPath>"; 
+0

बहुत बहुत धन्यवाद। मैंने जो भी उदाहरण देखे हैं, वे वास्तव में माइक्रोसॉफ्ट प्रलेखन से पथ को कॉपी और पेस्ट कर चुके हैं, वास्तव में अभ्यास में 'पैरेंट' पथ का उपयोग कैसे करें। –

संबंधित मुद्दे