Ha sido un tiempo desde que hice este código, pero puede ayudar: su proyecto web tiene que ser un sitio Web, y no un proyecto de tipo "Aplicación web ASP.Net", o no podrá agregar la referencia mencionada a continuación. Haga clic con el botón derecho en el proyecto y agregue una carpeta ASP.Net - App_WebReferences. Tendrá que especificar el servidor donde está su SRS; elige el .asmx. Una vez que se agrega, la carpeta debajo de ese nivel se llama servicio RSS, y debajo de eso hay 2 cosas: reportservice.discomap & .wsdl. En mi VB, hago importaciones e importaciones RSService System.Web.Services.Protocols, entonces ...
Dim MyRS As New ReportingService
El servicio de información está en un servidor diferente que el servidor web de la aplicación está activada, por lo que puede' t hacer lo siguiente: MyRS.Credentials = System.Net.CredentialCache.DefaultCredentials
lugar:. MyRS.Credentials = New System.Net.NetworkCredential(rs1, rs2, rs3)
, donde el RS1/2/3 son el inicio de sesión a la caja de SRS, paso al rectángulo del SRS, & nombre de dominio"(. Estos se cifran en mi web.config)
Luego, una masa-pasta:
MyRS.Credentials = New System.Net.NetworkCredential(rs1, rs2, rs3)
Dim ReportByteArray As Byte() = Nothing
Dim ReportPath As String = "/SRSSiteSubFolder/ReportNameWithoutRDLExtension"
Dim ReportFormat As String = "PDF"
Dim HistoryID As String = Nothing
Dim DevInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
'Dim x As ReportParameter - not necessary
Dim ReportParams(0) As ParameterValue
ReportParams(0) = New ParameterValue()
ReportParams(0).Name = "TheParamName"
ReportParams(0).Value = WhateverValue
Dim Credentials As DataSourceCredentials() = Nothing
Dim ShowHideToggle As String = Nothing
Dim Encoding As String
Dim MimeType As String
Dim ReportHistoryParameters As ParameterValue() = Nothing
Dim Warnings As Warning() = Nothing
Dim StreamIDs As String() = Nothing
'Dim sh As New SessionHeader() - not necessary
''MyRS.SessionHeaderValue = sh - not necessary
ReportByteArray = MyRS.Render(ReportPath, ReportFormat, HistoryID, DevInfo, ReportParams, Credentials, _
ShowHideToggle, Encoding, MimeType, ReportHistoryParameters, Warnings, StreamIDs)
'(Yay! That line was giving "HTTP error 401 - Unauthorized", until I set the credentials
' as above, as explained by http://www.odetocode.com/Articles/216.aspx.)
'Write the contents of the report to a PDF file:
Dim fs As FileStream = File.Create(FullReportPath, ReportByteArray.Length)
fs.Write(ReportByteArray, 0, ReportByteArray.Length)
fs.Close()
Call EmailTheReport(FullReportPath)
If IO.File.Exists(FullReportPath) Then
IO.File.Delete(FullReportPath)
End If
¿Qué sucede si no estoy usando informes locales pero no quiero dejar valores explícitos en la url? – Leonardo