none
How to Accessing reportingservice2006 asmx Web Services using Forms Based Authentication In SharePoint 2010 RRS feed

  • 問題

  • Hi every one

         I have create one webpart for import Reports.rdl files and DataSource.rsd files import in sharepoint site. Using Reportingservice2006.asmx it work fine. But when i add on forms-based authentication site it will give error. Error message is

    "     Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message: -- 401 UNAUTHORIZED<RSError xmlns="http://www.microsoft.com/sql/reportingservices"><MoreInformation><Message>An unknown error occurred with the Reporting Services endpoint on this SharePoint site. Contact the SharePoint site administrator for help.</Message></MoreInformation></RSError> "

    and my code for import report is.

     // Imports DataSource and Reports in Document Library after converting into the compatible format. (*.rds to *.rsds)
      private void ImportReportsToLibrary(SPWeb oWeb, string reportDataSource, string reportConfig) {
    
       FileStream stream = null;
       string fileName = string.Empty;
    
       try {
        SPWeb web = SPContext.Current.Web;
    
        // creates Report WebService instance. Assigns Url and credential properties to the instance.
        var reportingService06 = new ReportingService2006.ReportingService2006();
        reportingService06.Url = SPContext.Current.Web.Url + "/_vti_bin/ReportServer/ReportService2006.asmx";
        reportingService06.Credentials = System.Net.CredentialCache.DefaultCredentials;
       
        // Accesses the path of Reports and DataSource from the physical location on the basis of format.
        string featurePath = string.Format(@"{0}\FEATURES\{1}\", SPUtility.GetGenericSetupPath("Template"), @"Reports");
        string[] reportPaths = Directory.GetFiles(featurePath, "*.rdl");
        string[] dataSourcePath = Directory.GetFiles(featurePath, "*.rds");
    
        // Checks for minimum one DataSource File in Report Folder.
        if(dataSourcePath.Length != 1)
         throw new Exception("There is no datasource");
    
        // * Adds DataSource in Sharepoint Document Library. This requires the following steps.*
        // Step 1: Converts the extension from rds to rsds as Sharepoint does not accept rds format.
        // Step 2: Reads the content of the document.
        // Step 3: Creates Xml nodes and fetches the values from Step2.
        // Step 4: Creates a new datasource definition and assigns values to it.
        // Step 5: Adds the report in Sharepoint Document Library.
    
        XmlNode extensionNode = null;
        XmlNode connectStringNode = null;
        XmlNode rptDataSourceNameNode = null;
        fileName = Path.GetFileName(dataSourcePath[0]).Replace("rds", "rsds");
    
        // loads the replaced file into an XMLDocument object 
        stream = File.OpenRead(dataSourcePath[0]);
        XmlDocument dsDOM = new XmlDocument();
        dsDOM.Load(stream);
        stream.Close();
        rptDataSourceNameNode = dsDOM.SelectSingleNode("RptDataSource/Name");
        XmlNodeList connectionPropertiesNodes = dsDOM.SelectNodes("RptDataSource/ConnectionProperties");
    
        // iterates the xml to get the Nodes.
        foreach(XmlNode node in connectionPropertiesNodes) {
         extensionNode = node.SelectSingleNode("Extension");
         connectStringNode = node.SelectSingleNode("ConnectString");
        }
    
    
        ReportingService2006.DataSourceDefinition dsDefinition = new DataSourceDefinition();
        DataSource dSource = new DataSource();
        dSource.Item = dsDefinition;
    
        dsDefinition.Extension = extensionNode.InnerText;
        dsDefinition.ConnectString = connectStringNode.InnerText;
        dsDefinition.ImpersonateUserSpecified = true;
        dsDefinition.Prompt = null;
        dsDefinition.WindowsCredentials = true;
        dsDefinition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
    
    
    
        string parentDataSourceLibrary = SPContext.Current.Web.Url + "/Report Datasource";
        string fullDSUrl = string.Concat(parentDataSourceLibrary, "/", fileName);
        reportingService06.CreateDataSource(fileName, parentDataSourceLibrary, true, dsDefinition, null);
    
        // * Adds Reports in Sharepoint Document Library. This requires the following steps.*
        // Step 1: Gets File name.
        // Step 2: Opens File
        // Step 3: Creates and reads the content in Binary array.
        // Step 4: Creates Report in the allocated location (Path).
        Warning[] warnings = null;
    
        foreach(string rptPath in reportPaths) {
         fileName = Path.GetFileName(rptPath);
         stream = File.OpenRead(rptPath);
         Byte[] definition = new Byte[stream.Length];
         stream.Read(definition, 0, (int)stream.Length);
         stream.Close();
         string parentReportLibrary = SPContext.Current.Web.Url + "/" + reportConfig;
         string fullReportURL = string.Concat(parentReportLibrary, "/", fileName);
    
         CatalogItem item = reportingService06.CreateReport(fileName, parentReportLibrary, true, definition, null, out warnings);
    
         AssignDataSourceToReports(reportingService06, fullDSUrl, fullReportURL);
    
        }
       }
       catch(Exception ex) {
        this.Title = ex.Message;
       }
      }
    
      //Sets the data sources for an item in a SharePoint library
      private void AssignDataSourceToReports(ReportingService2006.ReportingService2006 reportingService06, string fullDataSourceUrl, string fullReportURL) {
       try {
        DataSource[] catalogItemDtSrcs = reportingService06.GetItemDataSources(fullReportURL);
        DataSourceReference reference = new DataSourceReference();
        DataSource dsNew = new DataSource();
    
        reference.Reference = fullDataSourceUrl;
        dsNew = catalogItemDtSrcs[0];
        dsNew.Item = reference;
    
        // Assigns datasource to Report.
        reportingService06.SetItemDataSources(fullReportURL, catalogItemDtSrcs);
       }
       catch(Exception ex) {
        this.Title = ex.Message;
       }
      }

     It will give error on line 

    reportingService06.CreateDataSource(fileName, parentDataSourceLibrary, true, dsDefinition, null);

    So how can I Access this web service in Form Based Authentication Site for import reports and datasource in document library using this reportingService2006.asmx web service?


    Navaratan Sharma
    2010年11月22日 上午 06:44

解答

  • Hi Navaratan,

         Please go through the link below which talks about  "Reporting Services custom authentication extensions are not supported for report servers that run in SharePoint integration mode."

    http://technet.microsoft.com/en-us/library/bb283324.aspx -- Security Overview for Reporting Services in SharePoint Integrated Mode

    Also what is the build number of your Reporting services?

    Build number of Microsoft.reportingservices.sharepoint.ui.webparts.dll ?

    From SPS Central Admin while you integrate with SSRS, make sure that you do it using Trusted Account and not Windows Authentication. The above article has detailed explaination.

     

    2010年11月30日 上午 10:33

所有回覆

  • Hi Navaratan,

         Please go through the link below which talks about  "Reporting Services custom authentication extensions are not supported for report servers that run in SharePoint integration mode."

    http://technet.microsoft.com/en-us/library/bb283324.aspx -- Security Overview for Reporting Services in SharePoint Integrated Mode

    Also what is the build number of your Reporting services?

    Build number of Microsoft.reportingservices.sharepoint.ui.webparts.dll ?

    From SPS Central Admin while you integrate with SSRS, make sure that you do it using Trusted Account and not Windows Authentication. The above article has detailed explaination.

     

    2010年11月30日 上午 10:33
  • Hi Smart MSFT

                 Thanks for replay.


    Navaratan Sharma
    • 已提議為解答 SMAT317 2013年3月13日 上午 11:17
    2010年12月1日 上午 10:24
  • You are welcome Navaratan.
    2010年12月7日 上午 07:57