Web services and methods with array parameters
I'm trying to wrap ReportExecution2005 from SQL Reporting Services so that I can domain authenticate on behalf of a Windows Auth Services login.
SetExecutionParameters(ParameterValue Parameters, string ParameterLanguage)
But when I put an array of any sort, even string, in a method signature, the service compiles fine yet when I try to set up a service reference in the Silverlight project, VS2010 has a hissy fit and doesn't generate the code for Reference.cs
Clearly you can use array parameters, ReportExecution2005 does so and VS2010 manages to reference that.
As soon as I remove the array member from the parameter list it stops moaning and works. Can anyone explain to me what is going on here?
If I can get this part sorted I have everything else I need to provide ReportViewer equivalent functionality in a SL4 RIA app - I've figured out dynamically creating an IFRAME in the parent web page, determining the pixel bounds of a placeholder control and dynamically adjusting the position and Z-order of the IFRAME so that it renders HTML as though it were "in" the placeholder panel.
I plan to wrap it all up as a control and release it for general use until Microsoft gets around to producing a ReportViewer control for Silverlight. The remaining part is to manipulate reporting services and return the bytes of a rendered report. I can reference ReportingServices directly in the client but there is no need for the credentials to do a round trip.
In the process of determining the nature of the fault I built a simplified service with a do-nothing method, and progressively added a parameter, built the service and tried adding it, until the problem occurred.
The problem occurred as soon as an array parameter was specified. I am certain it was the fact that it was an array, rather than the type of the array, because the problem occurrs even when the array type is a built-in type like string, which is definitely known to both server and client.
This is extremely puzzling, since array parameters are clearly supported - other services use them successfully. This is the error message:
Custom tool error: Failed to generate code for the service reference 'ServiceReference1'. Please check other error and warning messages for details.
There are no other error messages. There are half a dozen warnings, but most of them also occur for the successful import of web service.
Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Exception has been thrown by the target of an invocation. XPath to Error Source: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name='RS2010'] C:\...\ServiceReference1\Reference.svcmap Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. C:\atom\Silverlight\Argent\Service References\RS2005\Reference.svcmap Custom tool warning: Cannot import wsdl:binding Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on. XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name='RS2010'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_RS2010'] C:\atom\Silverlight\Argent\Service References\ServiceReference1\Reference.svcmap Custom tool warning: Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_RS2010'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='RS2010']/wsdl:port[@name='CustomBinding_RS2010'] C:\atom\Silverlight\Argent\Service References\ServiceReference1\Reference.svcmap
If you use Configure Service Reference... on the failed reference, and change from Reuse types in all referenced assemblies to Reuse types in specified referenced assemblies, then deselect System.ComponentModel.DataAnnotations and System.Windows.Browser you will find that the problem goes away.
At least it does for my trivial example. Things may be more subtle for more elaborate services.
You can specify these exclusions while setting up the reference in the first place, using the Advanced button. I always forget, and use Configure later when I get errors.
You need to define an array of ParameterValue, then pass this in. Not a string array.
Something like this...
ParameterValue paramarray = new ParameterValue[n]; --set them paramarray = new ParameterValue(); paramarray.Label = "Text"; paramarray.Name = "Key"; paramarray.Value = "1"; ... paramarray[n] = new ParameterValue(); paramarray[n].Label = "Text"; paramarray[n].Name = "Key"; paramarray[n].Value = "100"; ...SetExecutionParameters(paramarray, "en-us");