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

WCF Service multivalue parameters

2 Answers 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Accok5
Top achievements
Rank 2
Accok5 asked on 20 Mar 2013, 12:46 PM
Hello,

At the moment, I'm setting up a reporting WCF service. I'll be using it for generating invoices. Right now, I can pass an invoicenumber as report parameter and it generates the correct invoice.

This problem is however, I'd like to generate one document with multiple invoices. For this, I think I need to pass multiple values for the reportparameter "OrderNumbers".

The first thing I came up with was the following:

var ordernumbers = new [] { "0123456""9876543" };
var parameters = new Dictionary<stringobject>(){{"OrderNumbers",ordernumbers}};
 
var docxReport = reportService.Render("DOCX", "FULL name of report", new Dictionary<stringobject>(),parameters);

reportService is a ReportServiceClient.

When I try this, I receive the following error message:
"Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer."

My question is, is it possible to add a known type to the default datacontractserializer and how can this be done?
I suppose I have to create an instance of the ReportServiceBase class, so I can add a known type here somehow.
Or is there any other way to pass multiple values for this parameter?

With kind regards.

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 22 Mar 2013, 04:15 PM
Hi Acco,

Generally the Telerik Reporting WCF service is rather complex because it is made to serve the Silverlight report viewer. Thus if your purpose is only to render and transfer reports, our suggestion is to implement a simpler WCF service. For rendering the report you can use the ReportProcessor.Render methods.

About the error make sure that you have set the definition report parameters MultiValue to true. Additionally the ReportServiceBase.Render Method expects the parameters arguments of type NameValueDictionary.

Regards,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Accok5
Top achievements
Rank 2
answered on 25 Mar 2013, 10:10 AM
Hello Peter,

Thank you very much for your response.

I've implemented a simpler WCF service, which uses a reportProcessor. Everything is working fine now.
Tags
General Discussions
Asked by
Accok5
Top achievements
Rank 2
Answers by
Peter
Telerik team
Accok5
Top achievements
Rank 2
Share this question
or