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.
11 Answers:
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, 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!!
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
<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
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.