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

Passing parameters to a WCF service

4 Answers 226 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ranjit
Top achievements
Rank 1
Ranjit asked on 24 Oct 2011, 09:41 PM
Firstly, I think Telerik reporting is amazing! A great product...

I'm currently having some issues.. I created a WCF service that returns a report using SOAP. 
Using the example "self-hosted-telerik-reporting-wcf-service.html" my URL looks like this:

http://localhost:54321/reportservice/resources/export?format=PDF&report=YourNameSpace.Report1,YourNameSpace&parameterValues={"FileID":21} When I go into the report designer and setup parameters, my call to this service no longer works. However, when clearing all parameters or hard setting the parameter as a certain value, the call works perfect (returning the report with FileID of the hard coded value) Could really use some help on this... Thanks

4 Answers, 1 is accepted

Sort by
0
IvanDT
Telerik team
answered on 27 Oct 2011, 05:09 PM
Hello Ranjit,

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
Ranjit
Top achievements
Rank 1
answered on 04 Nov 2011, 04:02 PM
Okay, I'm not sure what is unclear but I will try to explain further.

We are not trying to use a telerik report viewer, nor are we trying to assign parameters to a report programatically.
We are using a WCF service to return the telerik report. Your documentation on this was pretty scarce, but the example we used was this one:

http://www.telerik.com/help/reporting/self-hosted-telerik-reporting-wcf-service.html

Once we install the service on our server, we are able to call the service as long as the Report Parameters are given a hard coded value within the report. We have tried everything trying to pass our parameters in the URL call to the service. See the URL example below.

http:/ourserver/ReportService.svc/resources/export?format=HTML&report=SOVReports.Report,SOVReports&parameterValues={"FileID":82} 

However this call doesn't work at all when the &parameterValues={"FileID":82} part of the URL is being used.

Can someone on the Telerik team please help us with this? We're leaning towards purchasing a number of Telerik products, but could really use some support to help get this issue resolved so that we can showcase your software and get clearance to purchase it.




0
IvanDT
Telerik team
answered on 04 Nov 2011, 06:34 PM
Hello Ranjit,

Our suggestion is to utilize the SilverlightClient proxy provided interface. You can use the RenderAsync method 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.

Regards,
IvanDT
the Telerik team

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

0
Regi
Top achievements
Rank 1
answered on 08 Nov 2012, 08:46 PM
Ranjit, if you just want to use the Telerik WCF service without using Silverlight and pass in parameters, which is what I wanted to do, you could add a service reference to the Telerik WCF service.


HostedReportService.ReportServiceClient rsc = new HostedReportService.ReportServiceClient();
 
Dictionary<string, object> parms = new Dictionary<string, object>();
parms.Add( "plastName", "Jones" );
var res = rsc.Render( "PDF", "TelerikWCFSample.Report1,TelerikWCFSample", new Dictionary<string, object>(), parms );
System.IO.File.WriteAllBytes( @"c:\files\pdf1.pdf", res.DocumentBytes );

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IReportService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147000000" maxBufferPoolSize="524288" maxReceivedMessageSize="2147000000"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147000000"
                        maxBytesPerRead="4096" maxNameTableCharCount="2147000000" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:54321/ReportService" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IReportService" contract="HostedReportService.IReportService"
                name="BasicHttpBinding_IReportService" />
        </client>
    </system.serviceModel>




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