pbocanegra
asked on
VB.NET Web Reference redirect to another URL (Webservices of Reporting Services)
I have two reports created in Reporting Services. And I use the webservices of reporting services for create a export in PDF.
My question is: How Do I change the WebReference url for that appoint to different Reporting Services depending if a production or preproduction Reports.
Example of my code now:
Private Sub Reportes
Dim rs As New fmb_as_326771.ReportingSer vice
rs.Credentials = New System.Net.NetworkCredenti al(USUARIO , CLAVE, DOMINIO)
' Render arguments
Dim result As Byte() = Nothing
Dim reportPath As String = "/FM/FMB/SISPRE"
Dim format As String = "PDF" '"HTML4.0"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>Fals e</Toolbar ><HTMLFrag ment>True< /HTMLFragm ent></Devi ceInfo>"
Dim MyConnectionString As String = System.Configuration.Confi gurationSe ttings.App Settings(" conn_peic. Connection String")
If InStr(MyConnectionString, "TORTI") <> 0 Then
rs.Url = "http://imcd-fsw-30/ReportServer/ReportService.asmx" ' The change of URL
Else
rs.Url = "http://imcd-fsw-10/ReportServer/ReportService.asmx" ' The Change of URL
End If
' Prepare report parameter.
Dim parameters(0) As fmb_as_326771.ParameterVal ue
parameters(0) = New fmb_as_326771.ParameterVal ue
parameters(0).Name = "Parameter1"
parameters(0).Value = CStr(viewstate("ProyectoSe ssionId"))
Dim credentials As fmb_as_326771.DataSourceCr edentials( ) = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String
Dim mimeType As String
Dim warnings As fmb_as_326771.Warning() = Nothing
Dim reportHistoryParameters As fmb_as_326771.ParameterVal ue() = Nothing
Dim streamIDs As String() = Nothing
Dim sh As New fmb_as_326771.SessionHeade r
rs.SessionHeaderValue = sh
Try
result = rs.Render(reportPath, format, historyID, devInfo, parameters, _
credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
sh.SessionId = rs.SessionHeaderValue.Sess ionId
Console.WriteLine("Session ID after call to Render: {0}", rs.SessionHeaderValue.Sess ionId)
Console.WriteLine("Executi on date and time: {0}", rs.SessionHeaderValue.Exec utionDateT ime)
Console.WriteLine("Is new execution: {0}", rs.SessionHeaderValue.IsNe wExecution )
Catch e As SoapException
Console.WriteLine(e.Detail .OuterXml)
End Try
' Write the contents of the report to an MHTML file.
Try
Dim stream As FileStream = File.Create("c:\reporte.pd f", result.Length)
Console.WriteLine("File created.")
stream.Write(result, 0, result.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Response.ContentType = "application/pdf"
Response.WriteFile("c:\rep orte.pdf")
Response.Flush()
Response.Close()
System.IO.File.Delete("c:\ reporte.pd f")
Catch e As Exception
Console.WriteLine(e.Messag e)
End Try
End Sub
When run this report the web page appears in blank.
My question is: How Do I change the WebReference url for that appoint to different Reporting Services depending if a production or preproduction Reports.
Example of my code now:
Private Sub Reportes
Dim rs As New fmb_as_326771.ReportingSer
rs.Credentials = New System.Net.NetworkCredenti
' Render arguments
Dim result As Byte() = Nothing
Dim reportPath As String = "/FM/FMB/SISPRE"
Dim format As String = "PDF" '"HTML4.0"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>Fals
Dim MyConnectionString As String = System.Configuration.Confi
If InStr(MyConnectionString, "TORTI") <> 0 Then
rs.Url = "http://imcd-fsw-30/ReportServer/ReportService.asmx" ' The change of URL
Else
rs.Url = "http://imcd-fsw-10/ReportServer/ReportService.asmx" ' The Change of URL
End If
' Prepare report parameter.
Dim parameters(0) As fmb_as_326771.ParameterVal
parameters(0) = New fmb_as_326771.ParameterVal
parameters(0).Name = "Parameter1"
parameters(0).Value = CStr(viewstate("ProyectoSe
Dim credentials As fmb_as_326771.DataSourceCr
Dim showHideToggle As String = Nothing
Dim encoding As String
Dim mimeType As String
Dim warnings As fmb_as_326771.Warning() = Nothing
Dim reportHistoryParameters As fmb_as_326771.ParameterVal
Dim streamIDs As String() = Nothing
Dim sh As New fmb_as_326771.SessionHeade
rs.SessionHeaderValue = sh
Try
result = rs.Render(reportPath, format, historyID, devInfo, parameters, _
credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
sh.SessionId = rs.SessionHeaderValue.Sess
Console.WriteLine("Session
Console.WriteLine("Executi
Console.WriteLine("Is new execution: {0}", rs.SessionHeaderValue.IsNe
Catch e As SoapException
Console.WriteLine(e.Detail
End Try
' Write the contents of the report to an MHTML file.
Try
Dim stream As FileStream = File.Create("c:\reporte.pd
Console.WriteLine("File created.")
stream.Write(result, 0, result.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Response.ContentType = "application/pdf"
Response.WriteFile("c:\rep
Response.Flush()
Response.Close()
System.IO.File.Delete("c:\
Catch e As Exception
Console.WriteLine(e.Messag
End Try
End Sub
When run this report the web page appears in blank.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I believe that is security issues.
ASKER