• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1175
  • Last Modified:

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.
0
pbocanegra
Asked:
pbocanegra
  • 2
1 Solution
 
Mikal613Commented:
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
0
 
pbocanegraAuthor Commented:
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.
0
 
pbocanegraAuthor Commented:
I believe that is security issues.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now