Sending query via Web Services to run report

I'm at the beginning stages of trying to control my report content from my website that I'm using to dynamically run it.

Currently, I have just a simple test report that has 4 fields named line1, line2, line3, and line4.  When I try to send my own MySQL Query, it just comes back blank.  How do I send my query to the reportserver

 

Here's my code (using PHP):

 
$client = new SoapClient($wsdl, array('login' => $username, 'password' => $password, "trace" => 1, "exceptions" => 0));
$request = "<request operationName=\\"runReport\\" locale=\\"en\\">
                  <argument name=\\"RUN_OUTPUT_FORMAT\\">PDF</argument>
                  <resourceDescriptor name=\\"test\\" wsType=\\"query\\" uriString=\\"SELECT * FROM mlabels LIMIT 10\\" isNew=\\"true\\">
                </resourceDescriptor>
                  <resourceDescriptor name=\\"\\" wsType=\\"\\" uriString=\\"/reports/input_test\\" isNew=\\"false\\">
                    <label>null</label>
                 </resourceDescriptor>
            </request>";
 
 $client->runReport($request);
 

I also attached my JRXML file in case that helps.

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago

11 Answers:

Your select statement doesn't specify but what are the names of the database columns?  They have to match the names of your fields or it doesn't know how to map them and you'll end up with a blank report.



Post Edited by mmulligan03 at 08/10/2011 20:28
mmulligan03's picture
Joined: Apr 12 2011 - 7:37am
Last seen: 12 years 5 months ago

Yeah, they do, unless capitalization is a problem:

SELECT Line1, Line2, Line3, Line4 FROM `mlabels` LIMIT 10

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago
As far as I know it is case sensitive. so Line1 != line1
mmulligan03's picture
Joined: Apr 12 2011 - 7:37am
Last seen: 12 years 5 months ago

Ok, changed the JRXML file fields to the capitalized Line1, Line2, Line3, and Line4, but it still is coming up blank.  Are you sure I have the right syntax with my resource request?

 

Attached is the new version of the my JRXML file.

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago

You have two resource descriptors.

You need to specify a resource property like:

<resourceProperty name="PROP_QUERY">
      <value>SELECT * FROM mlabels LIMIT 10</value>
</resourceProperty>

Code:
$request = "<request operationName="runReport" locale="en">
                  <argument name="RUN_OUTPUT_FORMAT">PDF</argument>
                  <resourceDescriptor name="test" wsType="reportUnit" uriString="/reports/input_test" isNew="true">
                     <resourceProperty name="PROP_QUERY">
                         <value>SELECT * FROM mlabels LIMIT 10</value>
                     </resourceProperty>
                </resourceDescriptor>
 
            </request>";



Post Edited by mmulligan03 at 08/11/2011 14:41



Post Edited by mmulligan03 at 08/11/2011 14:43
mmulligan03's picture
Joined: Apr 12 2011 - 7:37am
Last seen: 12 years 5 months ago

mmulligan03, I appreciate you help A LOT!

 

Now, given that I'm sending that Resource Property, do I need to open that report in IReports and set it up to receive and apply that Property as a Query, and if so, how do I do that?  Because changing my Request code by itself is still returning that blank page.

 

Thanks again!!

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago
You shouldn't have to, one thing you can do to rule out the query part is working or not is to specify a default query in your report. When I opened the jrxml file you didn't have a query defined. Try putting one in and test to make sure the that the report returns what you expect. Then try again adding your query property to your resource descriptor.
mmulligan03's picture
Joined: Apr 12 2011 - 7:37am
Last seen: 12 years 5 months ago

well durn,

 

I added a query to the IReport and took away the resourceProperty and it printed them out just fine.  I added the resourceProperty and it used the query that was laid out in the IReport instead.  So I took the query out of the IReport and left the resourceProperty in there and it showed up blank again.

 

It's like it doesn't see the resourceProperty at all!

 

Oh, and here's the new JRXML



Post Edited by biztek at 08/11/2011 15:17
biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago
hmmm.. I'm not quite sure what it could be then. I'm running java so its hard for me to tell why its ignoring that. Looking at the web services guide I see a section where it is doing nested resource descriptors like so:

<resourceDescriptor name="test" wsType="reportUnit" uriString="/reports/input_test" >
<resourceDescriptor name="query" wsType="query" uriString="/reports/input_test/query" isNew="true">
<label>query</label>
<description>query</description>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value>com.jaspersoft.jasperserver.api.metadata.common.domain.Query</value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value>/reports/input_test</value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value>1</value>
</resourceProperty>
<resourceProperty name="PROP_HAS_DATA">
<value>false</value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value>false</value>
</resourceProperty>
<resourceProperty name="PROP_QUERY">
<value>SELECT * FROM mlabels LIMIT 10</value>
</resourceProperty>
<resourceProperty name="PROP_QUERY_LANGUAGE">
<value>sql</value>
</resourceProperty>
<resourceDescriptor name="" wsType="datasource" uriString="" isNew="false">
<label>null</label>
<resourceProperty name="PROP_REFERENCE_URI">
<value>/datasources/JServerJdbcDS</value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value>true</value>
</resourceProperty>
</resourceDescriptor>
</resourceDescriptor>
</resourceDescriptor>

If that doesn't work maybe someone else out there running php has gotten this to work
mmulligan03's picture
Joined: Apr 12 2011 - 7:37am
Last seen: 12 years 5 months ago

ahhh, no beans.

 

I'll keep trying different things.

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago

Ok, you led me to the right answer!

 

What I ended up doing was having that report read from a SQL Query in the Repository.  Then I would first send a PUT request that changes the existing Query to whatever I want it to be, and then I make a runReport request and get the specific report that I want.

 

mmulligan03, I appreciate all your help.

biztek's picture
191
Joined: Jul 25 2011 - 12:05pm
Last seen: 12 years 2 months ago
Feedback
randomness