I created in VS2005 a report with one parameter and I placed it into a folder
under Reporting Services and I can run it through RS WEB interface.
Now I want to run that report from a custom application (VB.NET 2005). I
know how to open that report in a browser in HTML (using the URL and passing
the parameter) but I want to open that report in PDF instead. I added RS as a
WEB Service to my application but how I am identifying the report and how I
pass the parameter and then how I ask for the PDF file this is what I don't
know. For simplicity let's assume the report name is Report1 and it is placed
in folder Folder1 and the requested parameter is Parameter1. Could someone
let me know how I am rendering that report and how I open the PDF file?
The second question would be about the credentials. I would prefer not
opening ReportingServices WEB server to anonymous access. But the application
I use to open a report is connecting remotely and I cannot use VPN to make it
log into the domain. What I would look for is if I can pass programmatically
the credentials for a pre-defined account (on WEB server). I saw that the
ReportingService object has a Credentials property and I found out how to
send the default credentials (System.NET.CredentialCache.DefaultCredentials)
but as I said that workstation is outside my domain and I cannot use its
credentials.
I also have a third question somehow less important. I noticed a huge
difference between the preview in VS2005 and the one on WEB. I know that
there are 2 different previewers but I am not sure if I am not doing
something wrong. Strangely the PDF image looks much more accurate (compared
with VS2005 preview) than the HTML image obtained after deploying the report
on WEB.
Thanks anticipated for any hint.On Dec 2, 6:32 pm, Adrian <abcd...@.noemail.nospam> wrote:
> I created in VS2005 a report with one parameter and I placed it into a folder
> under Reporting Services and I can run it through RS WEB interface.
> Now I want to run that report from a custom application (VB.NET 2005). I
> know how to open that report in a browser in HTML (using the URL and passing
> the parameter) but I want to open that report in PDF instead. I added RS as a
> WEB Service to my application but how I am identifying the report and how I
> pass the parameter and then how I ask for the PDF file this is what I don't
> know. For simplicity let's assume the report name is Report1 and it is placed
> in folder Folder1 and the requested parameter is Parameter1. Could someone
> let me know how I am rendering that report and how I open the PDF file?
> The second question would be about the credentials. I would prefer not
> opening ReportingServices WEB server to anonymous access. But the application
> I use to open a report is connecting remotely and I cannot use VPN to make it
> log into the domain. What I would look for is if I can pass programmatically
> the credentials for a pre-defined account (on WEB server). I saw that the
> ReportingService object has a Credentials property and I found out how to
> send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> but as I said that workstation is outside my domain and I cannot use its
> credentials.
> I also have a third question somehow less important. I noticed a huge
> difference between the preview in VS2005 and the one on WEB. I know that
> there are 2 different previewers but I am not sure if I am not doing
> something wrong. Strangely the PDF image looks much more accurate (compared
> with VS2005 preview) than the HTML image obtained after deploying the report
> on WEB.
> Thanks anticipated for any hint.
This code should help. It's written in C#.NET 2005. Converting it to
VB.NET 2005 shouldn't be very difficult. You will be able to pass the
PDF document to a user outside the domain and/or combine this process
with a report viewer control to allow a user outside the domain to
view it and have it available as a PDF download. 'SSRSExecutionSvc'
below is what I called the web reference to: http://ServerX/reportserver/reportexecution2005.asmx
Byte[] result = null;
String strReportPath = "", strFormat = "", strDeviceInfo ="", strEncoding = "",
strMimeType = "", strExt = "", strSessionId = "",
strInvoicePath = "";
String strHistoryID = null;
String[] strStreamIDs = null;
SSRSExecutionSvc.ReportExecutionService rs = new
SSRSExecutionSvc.ReportExecutionService();
//Below user must have, at a minimum, Browser rights in
the Report Manager
rs.Credentials = new
System.Net.NetworkCredential("UserName", "Password", "DomainName");
rs.Url = "http://ServerX/reportserver/
ReportExecution2005.asmx";
// Render arguments
strReportPath = "/Folder1/Report1";
strFormat = "PDF";
strDeviceInfo = @."<DeviceInfo><Toolbar>False</Toolbar></
DeviceInfo>";
// Prepare report parameter.
SSRSExecutionSvc.ParameterValue[] parameters = new
SSRSExecutionSvc.ParameterValue[1];
parameters[0] = new SSRSExecutionSvc.ParameterValue();
parameters[0].Name = "Parameter1";
parameters[0].Value = OrderID.ToString();
SSRSExecutionSvc.Warning[] warnings = null;
SSRSExecutionSvc.ExecutionInfo execInfo = new
SSRSExecutionSvc.ExecutionInfo();
SSRSExecutionSvc.ExecutionHeader execHeader = new
SSRSExecutionSvc.ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(strReportPath, strHistoryID);
rs.SetExecutionParameters(parameters, "en-us");
strSessionId = rs.ExecutionHeaderValue.ExecutionID;
try
{
result = rs.Render(strFormat, strDeviceInfo, out
strExt, out strEncoding, out strMimeType, out warnings, out
strStreamIDs);
execInfo = rs.GetExecutionInfo();
}
catch (SoapException SoapEx)
{
return SoapEx.Detail.OuterXml.ToString();
}
// Write the Contents of the Invoice to a PDF Document.
try
{
FileStream stream = File.Create(("C:\\Report1.pdf"),
result.Length);
stream.Write(result, 0, result.Length);
stream.Close();
}
catch (Exception Ex)
{
return Ex.Message;
}
Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant|||Hi,
Not sure why you want to create a custom app because if your
requirement is only to render the report in pdf then adding
"&rc:format=PDF" to the url should do the trick for you.
Anyways, if you want to use the web service , here is an msdn article
for consuming the RS web service.
http://msdn2.microsoft.com/en-us/library/aa179578(SQL.80).aspx
With regards to credentials, if you are hosting RS on a web facing
server , you have a couple of choices - windows authentication or
forms authentication . Depending on your network set up and because of
the way RS security works, windows integrated authentication can get
very tricky .This article may give you an an insight
http://www.odetocode.com/Articles/216.aspx
If you want to use forms authentication, download the SQL Server 2005
samples and that has an example of how to integrate forms
authentication into your app. You can download the sample from here
http://codeplex.com/SqlServerSamples
With regards to your third question , "Strangely the PDF image looks
much more accurate (compared with VS2005 preview) than the HTML image
obtained after deploying the report on WEB. " . I am not sure why you
are comparing the pdf to an image . The pdf being generated by studio
and the one generated through the web interface should be alike.
Cheers
Shai
On Dec 3, 9:32 am, Adrian <abcd...@.noemail.nospam> wrote:
> I created in VS2005 a report with one parameter and I placed it into a folder
> under Reporting Services and I can run it through RS WEB interface.
> Now I want to run that report from a custom application (VB.NET 2005). I
> know how to open that report in a browser in HTML (using the URL and passing
> the parameter) but I want to open that report in PDF instead. I added RS as a
> WEB Service to my application but how I am identifying the report and how I
> pass the parameter and then how I ask for the PDF file this is what I don't
> know. For simplicity let's assume the report name is Report1 and it is placed
> in folder Folder1 and the requested parameter is Parameter1. Could someone
> let me know how I am rendering that report and how I open the PDF file?
> The second question would be about the credentials. I would prefer not
> opening ReportingServices WEB server to anonymous access. But the application
> I use to open a report is connecting remotely and I cannot use VPN to make it
> log into the domain. What I would look for is if I can pass programmatically
> the credentials for a pre-defined account (on WEB server). I saw that the
> ReportingService object has a Credentials property and I found out how to
> send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> but as I said that workstation is outside my domain and I cannot use its
> credentials.
> I also have a third question somehow less important. I noticed a huge
> difference between the preview in VS2005 and the one on WEB. I know that
> there are 2 different previewers but I am not sure if I am not doing
> something wrong. Strangely the PDF image looks much more accurate (compared
> with VS2005 preview) than the HTML image obtained after deploying the report
> on WEB.
> Thanks anticipated for any hint.|||Thank you for your input. I will follow all links you mentioned.
Regarding the custom application, I am not creating it for accessing
reports. The interface is used for managing company activity and I need from
this application to open in certain cases reports. In other words I want to
give users the possibility of opening reports within the same interface they
use for all other work.
I did not know that I can specify the PDF in the URL but it would still not
be a valid solution for me if I cannot specify the credentials. I noticed
that when using the reporting from RS WEB interface, they somehow pass the
credentials through URL in some kind of an ecrypted way but I am not sure how
to do that.
Regading the differences in preview, I wanted to say that the HTML preview
in VS2005 is sometimes (for more complex reports not a simple table)
completely different from the HTML report obtained from RS WEB interface but
if from the RS WEB interface I export the report in PDF I get something
significantly closer to what I used to have in VS@.2005 HTML preview.
Thank you again for your input.
"shaikat.das@.gmail.com" wrote:
> Hi,
> Not sure why you want to create a custom app because if your
> requirement is only to render the report in pdf then adding
> "&rc:format=PDF" to the url should do the trick for you.
> Anyways, if you want to use the web service , here is an msdn article
> for consuming the RS web service.
> http://msdn2.microsoft.com/en-us/library/aa179578(SQL.80).aspx
> With regards to credentials, if you are hosting RS on a web facing
> server , you have a couple of choices - windows authentication or
> forms authentication . Depending on your network set up and because of
> the way RS security works, windows integrated authentication can get
> very tricky .This article may give you an an insight
> http://www.odetocode.com/Articles/216.aspx
> If you want to use forms authentication, download the SQL Server 2005
> samples and that has an example of how to integrate forms
> authentication into your app. You can download the sample from here
> http://codeplex.com/SqlServerSamples
> With regards to your third question , "Strangely the PDF image looks
> much more accurate (compared with VS2005 preview) than the HTML image
> obtained after deploying the report on WEB. " . I am not sure why you
> are comparing the pdf to an image . The pdf being generated by studio
> and the one generated through the web interface should be alike.
> Cheers
> Shai
>
> On Dec 3, 9:32 am, Adrian <abcd...@.noemail.nospam> wrote:
> > I created in VS2005 a report with one parameter and I placed it into a folder
> > under Reporting Services and I can run it through RS WEB interface.
> > Now I want to run that report from a custom application (VB.NET 2005). I
> > know how to open that report in a browser in HTML (using the URL and passing
> > the parameter) but I want to open that report in PDF instead. I added RS as a
> > WEB Service to my application but how I am identifying the report and how I
> > pass the parameter and then how I ask for the PDF file this is what I don't
> > know. For simplicity let's assume the report name is Report1 and it is placed
> > in folder Folder1 and the requested parameter is Parameter1. Could someone
> > let me know how I am rendering that report and how I open the PDF file?
> > The second question would be about the credentials. I would prefer not
> > opening ReportingServices WEB server to anonymous access. But the application
> > I use to open a report is connecting remotely and I cannot use VPN to make it
> > log into the domain. What I would look for is if I can pass programmatically
> > the credentials for a pre-defined account (on WEB server). I saw that the
> > ReportingService object has a Credentials property and I found out how to
> > send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> > but as I said that workstation is outside my domain and I cannot use its
> > credentials.
> > I also have a third question somehow less important. I noticed a huge
> > difference between the preview in VS2005 and the one on WEB. I know that
> > there are 2 different previewers but I am not sure if I am not doing
> > something wrong. Strangely the PDF image looks much more accurate (compared
> > with VS2005 preview) than the HTML image obtained after deploying the report
> > on WEB.
> > Thanks anticipated for any hint.
>|||Hi Enrique,
Thank you a lot for your input.
I used your code translated to VB and everything worked OK until the next
statement:
rs.SetExecutionParameters(parameters, "en-us");
where I am always getting a time-out error. I checked the report and from
the WEB interface it runs OK with the parameter value I am passing. I am not
sure how to further investigate what goes wrong at this step. Do you have any
idea what might be or should I check?
Thank you again.
"EMartinez" wrote:
> On Dec 2, 6:32 pm, Adrian <abcd...@.noemail.nospam> wrote:
> > I created in VS2005 a report with one parameter and I placed it into a folder
> > under Reporting Services and I can run it through RS WEB interface.
> > Now I want to run that report from a custom application (VB.NET 2005). I
> > know how to open that report in a browser in HTML (using the URL and passing
> > the parameter) but I want to open that report in PDF instead. I added RS as a
> > WEB Service to my application but how I am identifying the report and how I
> > pass the parameter and then how I ask for the PDF file this is what I don't
> > know. For simplicity let's assume the report name is Report1 and it is placed
> > in folder Folder1 and the requested parameter is Parameter1. Could someone
> > let me know how I am rendering that report and how I open the PDF file?
> > The second question would be about the credentials. I would prefer not
> > opening ReportingServices WEB server to anonymous access. But the application
> > I use to open a report is connecting remotely and I cannot use VPN to make it
> > log into the domain. What I would look for is if I can pass programmatically
> > the credentials for a pre-defined account (on WEB server). I saw that the
> > ReportingService object has a Credentials property and I found out how to
> > send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> > but as I said that workstation is outside my domain and I cannot use its
> > credentials.
> > I also have a third question somehow less important. I noticed a huge
> > difference between the preview in VS2005 and the one on WEB. I know that
> > there are 2 different previewers but I am not sure if I am not doing
> > something wrong. Strangely the PDF image looks much more accurate (compared
> > with VS2005 preview) than the HTML image obtained after deploying the report
> > on WEB.
> > Thanks anticipated for any hint.
>
> This code should help. It's written in C#.NET 2005. Converting it to
> VB.NET 2005 shouldn't be very difficult. You will be able to pass the
> PDF document to a user outside the domain and/or combine this process
> with a report viewer control to allow a user outside the domain to
> view it and have it available as a PDF download. 'SSRSExecutionSvc'
> below is what I called the web reference to: http://ServerX/reportserver/reportexecution2005.asmx
> Byte[] result = null;
> String strReportPath = "", strFormat = "", strDeviceInfo => "", strEncoding = "",
> strMimeType = "", strExt = "", strSessionId = "",
> strInvoicePath = "";
> String strHistoryID = null;
> String[] strStreamIDs = null;
> SSRSExecutionSvc.ReportExecutionService rs = new
> SSRSExecutionSvc.ReportExecutionService();
> //Below user must have, at a minimum, Browser rights in
> the Report Manager
> rs.Credentials = new
> System.Net.NetworkCredential("UserName", "Password", "DomainName");
> rs.Url = "http://ServerX/reportserver/
> ReportExecution2005.asmx";
> // Render arguments
> strReportPath = "/Folder1/Report1";
> strFormat = "PDF";
> strDeviceInfo = @."<DeviceInfo><Toolbar>False</Toolbar></
> DeviceInfo>";
> // Prepare report parameter.
> SSRSExecutionSvc.ParameterValue[] parameters = new
> SSRSExecutionSvc.ParameterValue[1];
> parameters[0] = new SSRSExecutionSvc.ParameterValue();
> parameters[0].Name = "Parameter1";
> parameters[0].Value = OrderID.ToString();
> SSRSExecutionSvc.Warning[] warnings = null;
> SSRSExecutionSvc.ExecutionInfo execInfo = new
> SSRSExecutionSvc.ExecutionInfo();
> SSRSExecutionSvc.ExecutionHeader execHeader = new
> SSRSExecutionSvc.ExecutionHeader();
> rs.ExecutionHeaderValue = execHeader;
> execInfo = rs.LoadReport(strReportPath, strHistoryID);
> rs.SetExecutionParameters(parameters, "en-us");
> strSessionId = rs.ExecutionHeaderValue.ExecutionID;
> try
> {
> result = rs.Render(strFormat, strDeviceInfo, out
> strExt, out strEncoding, out strMimeType, out warnings, out
> strStreamIDs);
> execInfo = rs.GetExecutionInfo();
> }
> catch (SoapException SoapEx)
> {
> return SoapEx.Detail.OuterXml.ToString();
> }
> // Write the Contents of the Invoice to a PDF Document.
> try
> {
> FileStream stream = File.Create(("C:\\Report1.pdf"),
> result.Length);
> stream.Write(result, 0, result.Length);
> stream.Close();
> }
> catch (Exception Ex)
> {
> return Ex.Message;
> }
>
> Hope this helps.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||On Dec 3, 6:55 pm, Adrian <abcd...@.noemail.nospam> wrote:
> Hi Enrique,
> Thank you a lot for your input.
> I used your code translated to VB and everything worked OK until the next
> statement:
> rs.SetExecutionParameters(parameters, "en-us");
> where I am always getting a time-out error. I checked the report and from
> the WEB interface it runs OK with the parameter value I am passing. I am not
> sure how to further investigate what goes wrong at this step. Do you have any
> idea what might be or should I check?
> Thank you again.
> "EMartinez" wrote:
> > On Dec 2, 6:32 pm, Adrian <abcd...@.noemail.nospam> wrote:
> > > I created in VS2005 a report with one parameter and I placed it into a folder
> > > under Reporting Services and I can run it through RS WEB interface.
> > > Now I want to run that report from a custom application (VB.NET 2005). I
> > > know how to open that report in a browser in HTML (using the URL and passing
> > > the parameter) but I want to open that report in PDF instead. I added RS as a
> > > WEB Service to my application but how I am identifying the report and how I
> > > pass the parameter and then how I ask for the PDF file this is what I don't
> > > know. For simplicity let's assume the report name is Report1 and it is placed
> > > in folder Folder1 and the requested parameter is Parameter1. Could someone
> > > let me know how I am rendering that report and how I open the PDF file?
> > > The second question would be about the credentials. I would prefer not
> > > opening ReportingServices WEB server to anonymous access. But the application
> > > I use to open a report is connecting remotely and I cannot use VPN to make it
> > > log into the domain. What I would look for is if I can pass programmatically
> > > the credentials for a pre-defined account (on WEB server). I saw that the
> > > ReportingService object has a Credentials property and I found out how to
> > > send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> > > but as I said that workstation is outside my domain and I cannot use its
> > > credentials.
> > > I also have a third question somehow less important. I noticed a huge
> > > difference between the preview in VS2005 and the one on WEB. I know that
> > > there are 2 different previewers but I am not sure if I am not doing
> > > something wrong. Strangely the PDF image looks much more accurate (compared
> > > with VS2005 preview) than the HTML image obtained after deploying the report
> > > on WEB.
> > > Thanks anticipated for any hint.
> > This code should help. It's written in C#.NET 2005. Converting it to
> > VB.NET 2005 shouldn't be very difficult. You will be able to pass the
> > PDF document to a user outside the domain and/or combine this process
> > with a report viewer control to allow a user outside the domain to
> > view it and have it available as a PDF download. 'SSRSExecutionSvc'
> > below is what I called the web reference to:http://ServerX/reportserver/reportexecution2005.asmx
> > Byte[] result = null;
> > String strReportPath = "", strFormat = "", strDeviceInfo => > "", strEncoding = "",
> > strMimeType = "", strExt = "", strSessionId = "",
> > strInvoicePath = "";
> > String strHistoryID = null;
> > String[] strStreamIDs = null;
> > SSRSExecutionSvc.ReportExecutionService rs = new
> > SSRSExecutionSvc.ReportExecutionService();
> > //Below user must have, at a minimum, Browser rights in
> > the Report Manager
> > rs.Credentials = new
> > System.Net.NetworkCredential("UserName", "Password", "DomainName");
> > rs.Url = "http://ServerX/reportserver/
> > ReportExecution2005.asmx";
> > // Render arguments
> > strReportPath = "/Folder1/Report1";
> > strFormat = "PDF";
> > strDeviceInfo = @."<DeviceInfo><Toolbar>False</Toolbar></
> > DeviceInfo>";
> > // Prepare report parameter.
> > SSRSExecutionSvc.ParameterValue[] parameters = new
> > SSRSExecutionSvc.ParameterValue[1];
> > parameters[0] = new SSRSExecutionSvc.ParameterValue();
> > parameters[0].Name = "Parameter1";
> > parameters[0].Value = OrderID.ToString();
> > SSRSExecutionSvc.Warning[] warnings = null;
> > SSRSExecutionSvc.ExecutionInfo execInfo = new
> > SSRSExecutionSvc.ExecutionInfo();
> > SSRSExecutionSvc.ExecutionHeader execHeader = new
> > SSRSExecutionSvc.ExecutionHeader();
> > rs.ExecutionHeaderValue = execHeader;
> > execInfo = rs.LoadReport(strReportPath, strHistoryID);
> > rs.SetExecutionParameters(parameters, "en-us");
> > strSessionId = rs.ExecutionHeaderValue.ExecutionID;
> > try
> > {
> > result = rs.Render(strFormat, strDeviceInfo, out
> > strExt, out strEncoding, out strMimeType, out warnings, out
> > strStreamIDs);
> > execInfo = rs.GetExecutionInfo();
> > }
> > catch (SoapException SoapEx)
> > {
> > return SoapEx.Detail.OuterXml.ToString();
> > }
> > // Write the Contents of the Invoice to a PDF Document.
> > try
> > {
> > FileStream stream = File.Create(("C:\\Report1.pdf"),
> > result.Length);
> > stream.Write(result, 0, result.Length);
> > stream.Close();
> > }
> > catch (Exception Ex)
> > {
> > return Ex.Message;
> > }
> > Hope this helps.
> > Regards,
> > Enrique Martinez
> > Sr. Software Consultant
You're welcome. Is you system/windows environment setup in some
language other than English? If so, this might be the problem. Also,
make sure that the parameters[0].Value = a legitimate value. Hope this
helps further.
Regards,
Enrique Martinez
Sr. Software Consultant|||It is true that while my workstation is set in EN-US the Reporting Services
server was set in Romanian. Initially I changed the "en-us" language code in
"ro" and I got the time-out error. Then, I changed server's language (at OS
level) into EN-US and changed back the language code to "en-us" and I got the
same error. I am not sure if the OS is the only repository for the language
but as far as I know at SQL Server or Reporting Services I did not see any
such setting. I am also not sure if there is a problem having the server set
in one language and the workstation retrieving the report set in a different
language. As far as I know there should not be any issue other than the fact
you see data formatted according to RS Server regional settings rather than
in your workstation settings. It is true that right now both workstation and
server are set in EN-US but I wonder if there is an issue the fact that SQL
Server was installed while the server regional setting was different.
The parameter value is just a string so it's value does not depends on
regional settings.
Thank you again,
Adrian
"EMartinez" wrote:
> On Dec 3, 6:55 pm, Adrian <abcd...@.noemail.nospam> wrote:
> > Hi Enrique,
> >
> > Thank you a lot for your input.
> > I used your code translated to VB and everything worked OK until the next
> > statement:
> >
> > rs.SetExecutionParameters(parameters, "en-us");
> >
> > where I am always getting a time-out error. I checked the report and from
> > the WEB interface it runs OK with the parameter value I am passing. I am not
> > sure how to further investigate what goes wrong at this step. Do you have any
> > idea what might be or should I check?
> >
> > Thank you again.
> >
> > "EMartinez" wrote:
> > > On Dec 2, 6:32 pm, Adrian <abcd...@.noemail.nospam> wrote:
> > > > I created in VS2005 a report with one parameter and I placed it into a folder
> > > > under Reporting Services and I can run it through RS WEB interface.
> > > > Now I want to run that report from a custom application (VB.NET 2005). I
> > > > know how to open that report in a browser in HTML (using the URL and passing
> > > > the parameter) but I want to open that report in PDF instead. I added RS as a
> > > > WEB Service to my application but how I am identifying the report and how I
> > > > pass the parameter and then how I ask for the PDF file this is what I don't
> > > > know. For simplicity let's assume the report name is Report1 and it is placed
> > > > in folder Folder1 and the requested parameter is Parameter1. Could someone
> > > > let me know how I am rendering that report and how I open the PDF file?
> > > > The second question would be about the credentials. I would prefer not
> > > > opening ReportingServices WEB server to anonymous access. But the application
> > > > I use to open a report is connecting remotely and I cannot use VPN to make it
> > > > log into the domain. What I would look for is if I can pass programmatically
> > > > the credentials for a pre-defined account (on WEB server). I saw that the
> > > > ReportingService object has a Credentials property and I found out how to
> > > > send the default credentials (System.NET.CredentialCache.DefaultCredentials)
> > > > but as I said that workstation is outside my domain and I cannot use its
> > > > credentials.
> > > > I also have a third question somehow less important. I noticed a huge
> > > > difference between the preview in VS2005 and the one on WEB. I know that
> > > > there are 2 different previewers but I am not sure if I am not doing
> > > > something wrong. Strangely the PDF image looks much more accurate (compared
> > > > with VS2005 preview) than the HTML image obtained after deploying the report
> > > > on WEB.
> > > > Thanks anticipated for any hint.
> >
> > > This code should help. It's written in C#.NET 2005. Converting it to
> > > VB.NET 2005 shouldn't be very difficult. You will be able to pass the
> > > PDF document to a user outside the domain and/or combine this process
> > > with a report viewer control to allow a user outside the domain to
> > > view it and have it available as a PDF download. 'SSRSExecutionSvc'
> > > below is what I called the web reference to:http://ServerX/reportserver/reportexecution2005.asmx
> >
> > > Byte[] result = null;
> > > String strReportPath = "", strFormat = "", strDeviceInfo => > > "", strEncoding = "",
> > > strMimeType = "", strExt = "", strSessionId = "",
> > > strInvoicePath = "";
> > > String strHistoryID = null;
> > > String[] strStreamIDs = null;
> >
> > > SSRSExecutionSvc.ReportExecutionService rs = new
> > > SSRSExecutionSvc.ReportExecutionService();
> > > //Below user must have, at a minimum, Browser rights in
> > > the Report Manager
> > > rs.Credentials = new
> > > System.Net.NetworkCredential("UserName", "Password", "DomainName");
> > > rs.Url = "http://ServerX/reportserver/
> > > ReportExecution2005.asmx";
> >
> > > // Render arguments
> > > strReportPath = "/Folder1/Report1";
> > > strFormat = "PDF";
> > > strDeviceInfo = @."<DeviceInfo><Toolbar>False</Toolbar></
> > > DeviceInfo>";
> >
> > > // Prepare report parameter.
> > > SSRSExecutionSvc.ParameterValue[] parameters = new
> > > SSRSExecutionSvc.ParameterValue[1];
> >
> > > parameters[0] = new SSRSExecutionSvc.ParameterValue();
> > > parameters[0].Name = "Parameter1";
> > > parameters[0].Value = OrderID.ToString();
> >
> > > SSRSExecutionSvc.Warning[] warnings = null;
> >
> > > SSRSExecutionSvc.ExecutionInfo execInfo = new
> > > SSRSExecutionSvc.ExecutionInfo();
> > > SSRSExecutionSvc.ExecutionHeader execHeader = new
> > > SSRSExecutionSvc.ExecutionHeader();
> >
> > > rs.ExecutionHeaderValue = execHeader;
> >
> > > execInfo = rs.LoadReport(strReportPath, strHistoryID);
> >
> > > rs.SetExecutionParameters(parameters, "en-us");
> > > strSessionId = rs.ExecutionHeaderValue.ExecutionID;
> >
> > > try
> > > {
> > > result = rs.Render(strFormat, strDeviceInfo, out
> > > strExt, out strEncoding, out strMimeType, out warnings, out
> > > strStreamIDs);
> >
> > > execInfo = rs.GetExecutionInfo();
> > > }
> > > catch (SoapException SoapEx)
> > > {
> > > return SoapEx.Detail.OuterXml.ToString();
> > > }
> >
> > > // Write the Contents of the Invoice to a PDF Document.
> > > try
> > > {
> > > FileStream stream = File.Create(("C:\\Report1.pdf"),
> > > result.Length);
> > > stream.Write(result, 0, result.Length);
> > > stream.Close();
> > > }
> > > catch (Exception Ex)
> > > {
> > > return Ex.Message;
> > > }
> >
> > > Hope this helps.
> >
> > > Regards,
> >
> > > Enrique Martinez
> > > Sr. Software Consultant
>
> You're welcome. Is you system/windows environment setup in some
> language other than English? If so, this might be the problem. Also,
> make sure that the parameters[0].Value = a legitimate value. Hope this
> helps further.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||I was trying to do the same thing this morning. I got the following to work
in vb (based on the FindRenderSave app, modified using the c# code above to
add parameters). It was on a en-us based server / pc setup, so it may not
help any.
Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ws As New rs.ReportingService2005
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
'Search for the report to use by name
Dim conditions() As SearchCondition
Dim condition As New SearchCondition()
condition.Condition = ConditionEnum.Contains
condition.ConditionSpecified = True
condition.Name = "Name"
condition.Value = "My Report Name"
conditions = New SearchCondition(0) {}
conditions(0) = condition
Dim returnedItems As CatalogItem() = ws.FindItems("/",
BooleanOperatorEnum.Or, conditions)
Dim x As CatalogItem = returnedItems(0)
'Call the save for the report
SaveAs(x)
End Sub
Private Sub SaveAs(ByVal selItem As CatalogItem)
Dim rsExec As New ReportExecutionService
rsExec.Url =System.Configuration.ConfigurationManager.AppSettings("ReportExecutionService")
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim fileName As String = Server.MapPath("") & "\export\" &
selItem.Name _
& " " & GetDateString()
Select Case Me.ExportFormatDropDownList.SelectedValue
Case "EXCEL"
fileName = fileName & ".xls"
Case "PDF"
fileName = fileName & ".pdf"
End Select
' Prepare Render arguments
Dim historyID As String = Nothing
Dim deviceInfo As String = Nothing
Dim format As String = Me.ExportFormatDropDownList.SelectedValue
Dim showHide As String = Nothing
Dim results() As [Byte]
Dim warnings As ReportExecution2005.Warning() = Nothing
Dim streamIDs As String() = Nothing
Dim encoding As String = String.Empty
Dim mimeType As String = String.Empty
Dim params(0) As ReportExecution2005.ParameterValue
params(0) = New ReportExecution2005.ParameterValue
params(0).Name = "myId"
params(0).Value = 1
Dim ei As ExecutionInfo = rsExec.LoadReport(selItem.Path, historyID)
Dim hdr As ReportExecution2005.ExecutionHeader = New
ReportExecution2005.ExecutionHeader
Dim sessionId = rsExec.ExecutionHeaderValue.ExecutionID
rsExec.SetExecutionParameters(params, "en-us")
'Exectute the report and save it into a file.
Try
results = rsExec.Render(format, deviceInfo, encoding, mimeType,
warnings, streamIDs)
' Create a file stream and write the report to it
Using stream As FileStream = File.OpenWrite(fileName)
stream.Write(results, 0, results.Length)
End Using
Catch exception As Exception
Throw exception
End Try
End Sub
"EMartinez" <emartinez.pr1@.gmail.com> wrote in message
news:fe2ede7b-c74c-41d7-96e5-69438d50ce78@.n20g2000hsh.googlegroups.com...
> On Dec 3, 6:55 pm, Adrian <abcd...@.noemail.nospam> wrote:
>> Hi Enrique,
>> Thank you a lot for your input.
>> I used your code translated to VB and everything worked OK until the next
>> statement:
>> rs.SetExecutionParameters(parameters, "en-us");
>> where I am always getting a time-out error. I checked the report and from
>> the WEB interface it runs OK with the parameter value I am passing. I am
>> not
>> sure how to further investigate what goes wrong at this step. Do you have
>> any
>> idea what might be or should I check?
>> Thank you again.
>> "EMartinez" wrote:
>> > On Dec 2, 6:32 pm, Adrian <abcd...@.noemail.nospam> wrote:
>> > > I created in VS2005 a report with one parameter and I placed it into
>> > > a folder
>> > > under Reporting Services and I can run it through RS WEB interface.
>> > > Now I want to run that report from a custom application (VB.NET
>> > > 2005). I
>> > > know how to open that report in a browser in HTML (using the URL and
>> > > passing
>> > > the parameter) but I want to open that report in PDF instead. I added
>> > > RS as a
>> > > WEB Service to my application but how I am identifying the report and
>> > > how I
>> > > pass the parameter and then how I ask for the PDF file this is what I
>> > > don't
>> > > know. For simplicity let's assume the report name is Report1 and it
>> > > is placed
>> > > in folder Folder1 and the requested parameter is Parameter1. Could
>> > > someone
>> > > let me know how I am rendering that report and how I open the PDF
>> > > file?
>> > > The second question would be about the credentials. I would prefer
>> > > not
>> > > opening ReportingServices WEB server to anonymous access. But the
>> > > application
>> > > I use to open a report is connecting remotely and I cannot use VPN to
>> > > make it
>> > > log into the domain. What I would look for is if I can pass
>> > > programmatically
>> > > the credentials for a pre-defined account (on WEB server). I saw that
>> > > the
>> > > ReportingService object has a Credentials property and I found out
>> > > how to
>> > > send the default credentials
>> > > (System.NET.CredentialCache.DefaultCredentials)
>> > > but as I said that workstation is outside my domain and I cannot use
>> > > its
>> > > credentials.
>> > > I also have a third question somehow less important. I noticed a huge
>> > > difference between the preview in VS2005 and the one on WEB. I know
>> > > that
>> > > there are 2 different previewers but I am not sure if I am not doing
>> > > something wrong. Strangely the PDF image looks much more accurate
>> > > (compared
>> > > with VS2005 preview) than the HTML image obtained after deploying the
>> > > report
>> > > on WEB.
>> > > Thanks anticipated for any hint.
>> > This code should help. It's written in C#.NET 2005. Converting it to
>> > VB.NET 2005 shouldn't be very difficult. You will be able to pass the
>> > PDF document to a user outside the domain and/or combine this process
>> > with a report viewer control to allow a user outside the domain to
>> > view it and have it available as a PDF download. 'SSRSExecutionSvc'
>> > below is what I called the web reference
>> > to:http://ServerX/reportserver/reportexecution2005.asmx
>> > Byte[] result = null;
>> > String strReportPath = "", strFormat = "", strDeviceInfo =>> > "", strEncoding = "",
>> > strMimeType = "", strExt = "", strSessionId = "",
>> > strInvoicePath = "";
>> > String strHistoryID = null;
>> > String[] strStreamIDs = null;
>> > SSRSExecutionSvc.ReportExecutionService rs = new
>> > SSRSExecutionSvc.ReportExecutionService();
>> > //Below user must have, at a minimum, Browser rights in
>> > the Report Manager
>> > rs.Credentials = new
>> > System.Net.NetworkCredential("UserName", "Password", "DomainName");
>> > rs.Url = "http://ServerX/reportserver/
>> > ReportExecution2005.asmx";
>> > // Render arguments
>> > strReportPath = "/Folder1/Report1";
>> > strFormat = "PDF";
>> > strDeviceInfo = @."<DeviceInfo><Toolbar>False</Toolbar></
>> > DeviceInfo>";
>> > // Prepare report parameter.
>> > SSRSExecutionSvc.ParameterValue[] parameters = new
>> > SSRSExecutionSvc.ParameterValue[1];
>> > parameters[0] = new SSRSExecutionSvc.ParameterValue();
>> > parameters[0].Name = "Parameter1";
>> > parameters[0].Value = OrderID.ToString();
>> > SSRSExecutionSvc.Warning[] warnings = null;
>> > SSRSExecutionSvc.ExecutionInfo execInfo = new
>> > SSRSExecutionSvc.ExecutionInfo();
>> > SSRSExecutionSvc.ExecutionHeader execHeader = new
>> > SSRSExecutionSvc.ExecutionHeader();
>> > rs.ExecutionHeaderValue = execHeader;
>> > execInfo = rs.LoadReport(strReportPath, strHistoryID);
>> > rs.SetExecutionParameters(parameters, "en-us");
>> > strSessionId = rs.ExecutionHeaderValue.ExecutionID;
>> > try
>> > {
>> > result = rs.Render(strFormat, strDeviceInfo, out
>> > strExt, out strEncoding, out strMimeType, out warnings, out
>> > strStreamIDs);
>> > execInfo = rs.GetExecutionInfo();
>> > }
>> > catch (SoapException SoapEx)
>> > {
>> > return SoapEx.Detail.OuterXml.ToString();
>> > }
>> > // Write the Contents of the Invoice to a PDF Document.
>> > try
>> > {
>> > FileStream stream = File.Create(("C:\\Report1.pdf"),
>> > result.Length);
>> > stream.Write(result, 0, result.Length);
>> > stream.Close();
>> > }
>> > catch (Exception Ex)
>> > {
>> > return Ex.Message;
>> > }
>> > Hope this helps.
>> > Regards,
>> > Enrique Martinez
>> > Sr. Software Consultant
>
> You're welcome. Is you system/windows environment setup in some
> language other than English? If so, this might be the problem. Also,
> make sure that the parameters[0].Value = a legitimate value. Hope this
> helps further.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment