This is a migrated thread and some comments may be shown as answers.

Correct way to pass a parameter in URL to a WCF Service

3 Answers 916 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 25 Oct 2011, 02:46 PM
I am new to Telerik Reports  and have created a WCF service with parameters and would like to pass values to it. Below is the URL -

http://serverName/ReportService.svc/resources/export?format=PDF&report=MyReports.PurchaseReport,MyReports&parameterValues={"fileID":81}

This works if I have the actual report "fileID" param set to a default value like 82. After making the call the Report uses the default 82 value and not "81"?

Do I need to add code inside the Report class? even though my DataSource param is bound to my Report Param?

Is there an example of this anywhere? I have only found the Telerik example w/out parameters. 

3 Answers, 1 is accepted

Sort by
0
IvanDT
Telerik team
answered on 28 Oct 2011, 02:15 PM
Hello James,

Based on the provided information we cannot understand what exactly you're trying to do. A runnable sample will give us more clear information about your situation and help us advise you accordingly. Please open a support thread and attach it there.

You can use the "Programmatic Initialization of Report Parameter Values in Telerik Reporting Silverlight Viewer" KB help article where you can see a sample on how to initialize the report parameter in Silverlight ReportViewer.

Regards,
IvanDT
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Steve
Top achievements
Rank 1
answered on 04 Nov 2011, 05:01 PM
Hi Ivan,

I am using the WCF Service to call for a report (See the title of this thread) successfully without parameters. I would like to now pass parameters and have yet to find a way to do this.

I am NOT using the "Silverlight Report Viewer" or any other viewer.

I get that you can pass parameters programatically in C#. What I am hoping is that since the Telerik Team has taken the time to wrap the report functionality and created an easy to use WCF Service that there is an easy way to call for a Report and have it use the Parameters that are passed?

thanks for any help you can give on the WCF side of things...

- SD
0
IvanDT
Telerik team
answered on 04 Nov 2011, 06:35 PM
Hello Steve,

Our suggestion is to utilize the SilverlightClient proxy provided interface. You can use the RenderAsyncmethod NameValueDictionary to provided the parameter. By doing so you can fully access the Report engine and export a report. Here is an example that illustrates the suggested approach:

Stream file;
private void button1_Click(object sender, RoutedEventArgs e)
{
var fileDlg = new SaveFileDialog();
fileDlg.Filter = "PDF files|*.pdf|All files|*.*";
NameValueDictionary repParams = new NameValueDictionary();
repParams.Add("OrderNumber", "SO51111");
if (fileDlg.ShowDialog() == true)
{
this.file = fileDlg.OpenFile();
var serviceClient = new ReportServiceClient(new Uri(App.Current.Host.Source, "../ReportService.svc"));
serviceClient.RenderAsync("PDF",
"Telerik.Reporting.Examples.CSharp.Invoice, CSharp.ReportLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
null,
repParams);
serviceClient.RenderCompleted += new EventHandler<RenderEventArgs>(serviceClient_RenderCompleted);
}
}
void serviceClient_RenderCompleted(object sender, RenderEventArgs e)
{
var result = e.RenderingResult;
if (this.file != null)
{
this.file.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
this.file.Close();
this.file.Dispose();
this.file = null;
}
}

The HTTP GET request located in our "How to: Create Self-Hosted Telerik Reporting WCF Service" help article is about testing the resource endpoint availability of the WCF service. All officially supported methods are listed in the Reporting API.

Greetings,
IvanDT
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
IvanDT
Telerik team
Steve
Top achievements
Rank 1
Share this question
or