Link to home
Start Free TrialLog in
Avatar of pbocanegra
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.ReportingService

        rs.Credentials = New System.Net.NetworkCredential(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>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>"
        Dim MyConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("conn_peic.ConnectionString")


        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.ParameterValue
        parameters(0) = New fmb_as_326771.ParameterValue
        parameters(0).Name = "Parameter1"
        parameters(0).Value = CStr(viewstate("ProyectoSessionId"))

        Dim credentials As fmb_as_326771.DataSourceCredentials() = 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.ParameterValue() = Nothing
        Dim streamIDs As String() = Nothing
        Dim sh As New fmb_as_326771.SessionHeader
        rs.SessionHeaderValue = sh

        Try
            result = rs.Render(reportPath, format, historyID, devInfo, parameters, _
            credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
            sh.SessionId = rs.SessionHeaderValue.SessionId
            Console.WriteLine("SessionID after call to Render: {0}", rs.SessionHeaderValue.SessionId)
            Console.WriteLine("Execution date and time: {0}", rs.SessionHeaderValue.ExecutionDateTime)
            Console.WriteLine("Is new execution: {0}", rs.SessionHeaderValue.IsNewExecution)

        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.pdf", 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:\reporte.pdf")
            Response.Flush()
            Response.Close()
            System.IO.File.Delete("c:\reporte.pdf")


        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub


When run this report the web page appears in blank.
ASKER CERTIFIED SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbocanegra
pbocanegra

ASKER

My code run with static URL, but when change the URL property, the report not working. I checked  that the reports is in the new direction where the URL property is appointed.
I believe that is security issues.