Is it possible to pass an array of values, or a custom type as a parameter?
I am using a web service as a datasource. When I create my report I would like to pass a string array to this web method to retrieve the data for the report. Is this possible or is there a similar way to do this such as passing a custom type? thanks, buckaroov
October 25th, 2010 7:22pm

Hi bucaroov, You can pass your array of values to the web service as defined by WSDL. Here is an msdn reference which discusses web service querying: http://msdn.microsoft.com/en-us/library/aa964129(SQL.90).aspx#repservxmlds_topic4 After you know what the web service expects, you may construct your query using XML Data Provider Query Language which is also discussed in the above reference. Let me know if you have any further questions. SteveThis posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
October 25th, 2010 8:58pm

Steve, I looked at the article you had mentioned. I have previously gone through this process mentioned in the article and am able to get my report to work with primitive parameters. But it is with an array that I am having problems. When I use visual studio and try to add a parameter of type Array from within the Report Data window, the array type is not displayed. So I am not able to add an array parameter to my report. So I tried to make the changes directly to the report’s .rdl file, without using Visual Studio. Is that what you suggested? Also, I am not sure how to deal with data of type ArrayOfString. I have also included some of the web service .wsdl and the report .rdl file. thanks, Lloyd This is a portion of code from the web service wsdl. <s:element name="Get_Data"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="Codes" type="tns:ArrayOfString" /> <s:element minOccurs="0" maxOccurs="1" name="OrgCode" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="PointInTime" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="BYear" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Fund" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="Conservancies" type="s:string" /> <s:element minOccurs="0" maxOccurs="1" name="StatusID" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:complexType name="ArrayOfString"> <s:sequence> <s:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="s:string" /> </s:sequence> </s:complexType> This is code from the report .rdl file. The code within the ????? is where I have questions as far as the format. <CommandText>&lt;Query&gt; &lt;SoapAction&gt; http://tempuri.org/Get_Data &lt;/SoapAction&gt; &lt;Method Namespace="http://tempuri.org/" Name="Get_Data" &gt; &lt;Parameters&gt; ????????????????????????????????????????????????? &lt;Parameter Name="Codes" &gt; &lt;string &gt;0650&lt;/string&gt; &lt;string &gt;0651&lt;/string&gt; &lt;string &gt;0652&lt;/string&gt; &lt;/Parameter&gt; ????????????????????????????????????????????????? &lt;Parameter Name="OrgCode" Type="String"&gt; &lt;DefaultValue&gt;3540&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;Parameter Name="PointInTime" Type="String"&gt; &lt;DefaultValue&gt;166&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;Parameter Name="BYear" Type="String"&gt; &lt;DefaultValue&gt;2011&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;Parameter Name="Fund" Type="String"&gt; &lt;DefaultValue&gt;G&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;Parameter Name="Conservancies" Type="String"&gt; &lt;DefaultValue&gt;Include&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;Parameter Name="StatusID" Type="String"&gt; &lt;DefaultValue&gt;4&lt;/DefaultValue&gt; &lt;/Parameter&gt; &lt;/Parameters&gt; &lt;/Method&gt; &lt;/Query&gt;</CommandText>
October 26th, 2010 1:41pm

Hi Lloyd, May I ask how you are passing the multiple values to the Query? In your response, you have static string values but I assume that was just as an example? If you pass in the parameters to your DataSet via a Multi-Valued ReportParameter in the QueryParameters collection, it will automatically get mapped to the appropriate Soap Request. In this case, you won't need to specify them in the Query text for the DataSet. Also, would version of RS are you using? This will help in trying to find a solution for you. Thanks, SteveThis posting is provided "AS IS" with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
October 26th, 2010 6:18pm

Steve, I set up a test web method and report to test a report using a Multi-Valued ReportParameter. I have displayed it below. I have an OrgIDs report parameter and data parameter. When I click on the Previw tab I am able to type in numerous OrgIDs such as 350, 234, 345. Will these values be sent to the web method and automatically be passed to the web method as a string[] since I have defined the web method parameter to be a string[]? I tried this but somehow data results are not being returned to the report. Have I set up the text query correctly since I am passing the parameters through the QueryParameters collection? Is there some way to test that the values are being passed correctly to the web method? Thanks, Lloyd <Query> <SoapAction> http://tempuri.org/TestMultiValueParameter </SoapAction> <Method Namespace="http://tempuri.org/" Name="TestMultiValueParameter" > </Method> <ElementPath IgnoreNamespaces="True">TestMultiValueParameterResponse{}/TestMultiValueParameterResult/diffgram{}/NewDataSet{}/Table{ProjectID,PointInTimeID,OrgID}</ElementPath> </Query> [WebMethod] public DataTable TestMultiValueParameter(string[] OrgIDs) { DataSet ds1 = new DataSet(@"NewDataSet"); ds1.Tables.Add(new DataTable(@"Table")); DataTable allProjectsForAllOrgs = ds1.Tables[0]; DataTable dt; for (int i = 0; i < OrgIDs.Length; i++ ) { object[] paramArray = new object[1]; paramArray[0] = Convert.ToInt32(OrgIDs[i]); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCmd = db.GetStoredProcCommand(@"[Test_MultiValueParameters]", paramArray); DataSet ds = db.ExecuteDataSet(dbCmd); dt = ds.Tables[0]; for (int j = 0; j < 1; j++) { if (dt.Rows.Count > 0) { allProjectsForAllOrgs.Merge(dt); } } } return allProjectsForAllOrgs; }
October 27th, 2010 6:56pm

Steve, I set up a test web method and report to test a report using a Multi-Valued ReportParameter. I have displayed it below. I have an OrgIDs report parameter and data parameter. When I click on the Previw tab I am able to type in numerous OrgIDs such as 350, 234, 345. Will these values be sent to the web method and be passed to the web method as a string[] since I have defined the web method parameter to be a string[]? I tried this but somehow the results are not being returned to the report. Have I set up the query correctly since I am passing the parameters through the QueryParameters collection? How do I know that the values are being passed correctly? Thanks, Lloyd <Query> <SoapAction> http://tempuri.org/TestMultiValueParameter </SoapAction> <Method Namespace="http://tempuri.org/" Name="TestMultiValueParameter" > </Method> <ElementPath IgnoreNamespaces="True">TestMultiValueParameterResponse{}/TestMultiValueParameterResult/diffgram{}/NewDataSet{}/Table{ProjectID,PointInTimeID,OrgID}</ElementPath> </Query> [WebMethod] public DataTable TestMultiValueParameter(string[] OrgIDs) { DataSet ds1 = new DataSet(@"NewDataSet"); ds1.Tables.Add(new DataTable(@"Table")); DataTable allProjectsForAllOrgs = ds1.Tables[0]; DataTable dt; for (int i = 0; i < OrgIDs.Length; i++ ) { object[] paramArray = new object[1]; paramArray[0] = Convert.ToInt32(OrgIDs[i]); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCmd = db.GetStoredProcCommand(@"[Test_MultiValueParameters]", paramArray); DataSet ds = db.ExecuteDataSet(dbCmd); dt = ds.Tables[0]; for (int j = 0; j < 1; j++) { if (dt.Rows.Count > 0) { allProjectsForAllOrgs.Merge(dt); } } } return allProjectsForAllOrgs; }
Free Windows Admin Tool Kit Click here and download it now
October 27th, 2010 6:57pm

Hi Lloyd, Yes, the XML Data Provider Extension should be mapping it to the ArrayOfString SOAP parameter type that you expected. What version of RS are you using? I was informed that some behaviour changed, so if you could provide that info, I can dig deeper. There is a tool called Fiddler, you should be able to see the SOAP request and response. Give that a shot. It'll allow you to determine if there is anything wrong with your ElementPath as well since you can see how the DataTable was serialized. (diffgram and NewDataSet may not be necessary etc) Thanks, SteveThis posting is provided "AS IS" with no warranties, and confers no rights.
October 29th, 2010 2:40pm

Steve, We are using SQL Server 2008. In running my report and using the Visual Studio debugger on the web service I found that the web method parameter string[] OrgIDs did not have any value. Thanks, Lloyd
Free Windows Admin Tool Kit Click here and download it now
October 29th, 2010 5:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics