VB.NET Web Reference redirect to another URL (Webservices of Reporting Services)

Posted on 2006-04-07
Last Modified: 2012-06-27
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

            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

            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
        End Try
        ' Write the contents of the report to an MHTML file.
            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.")

            Response.ContentType = "application/pdf"

        Catch e As Exception
        End Try
    End Sub

When run this report the web page appears in blank.
Question by:pbocanegra
    LVL 48

    Accepted Solution

    dim strURL as string
      strURL = ConfigurationSettings.AppSettings("WebServiceURL")
      dim a as new localhost.Service1 --> This will be the web reference in your project
      a.URL = strURL
    LVL 4

    Author Comment

    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.
    LVL 4

    Author Comment

    I believe that is security issues.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now