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

Confused on Adding parameter for Object Datasource to connect to a webservice

1 Answer 120 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 29 Aug 2012, 11:30 PM
I've looked around on the docs and threads, but I can't seem to figure out the best way to get data from a WCF webservice with parameters.  Of note, I'm using silverlight and can't bind my data to the report.

I create a Objectdatasource and it maps my return object ok when I add a service reference.  But I don't see how to add parameters to my  WCF webservice?

The examples I've seen only show web services with no parameters.

Do I need to do a binding for the datasource and then call my webservice in that?
        public static ObjectDataSource ChangeConnectionString(object reportItem)
        {
            var report = (reportItem as Telerik.Reporting.Processing.Report);
            var dataSource = (Telerik.Reporting.ObjectDataSource)report.DataSource;
MyService.MyClient client = ...
client.GetMyData(str1,str1);
//How do I bind it to my datasource?
return datasource;???


Or do I add parameters like this:
objectDataSource.Parameters.Add(new Telerik.Reporting.ObjectDataSourceParameter("productModelID", typeof(int), 23));

Are the parameters in quotes supposed to match the parmeters of the webservice?

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 03 Sep 2012, 03:28 PM
Hi Dan,

Since you are using Silverlight, the report's data-source cannot be set from outside and the only way is to consume the service from the report itself. Create an ObjectDataSource which will consume the service. The ObjectDataSource will have the same parameters as the data-retrieval method of the service. 
This article shows how to pass parameters when using Silverlight report viewer. 
You can find attached an example showing how to consume WCF service with parameters in Silverlight. 
 
Greetings,
Elian
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
danparker276
Top achievements
Rank 2
Answers by
Elian
Telerik team
Share this question
or