Jump to content
We've recently updated our Privacy Statement, available here ×

SOAP runReport call - using alternate datasource


halfer

Recommended Posts

Hi all

 

I am currently writing a PHP plugin for the symfony web development framework to integrate with JasperServer. I'd like to do this across SOAP, rather than using the PHP-Java bridge. I've downloaded the PHP examples, and the Web Services guide, and have come to an impasse. We can generate a PDF report nice and easily using the following SOAP request:

 

Code:
<request
operationName="runReport">
<resourceDescriptor
name=""
wsType="reportUnit"
uriString="/reports/test/hamp-test-0.1"
isNew="false">
<label></label>

</resourceDescriptor>

<argument
name="USE_DIME_ATTACHMENTS"><![CDATA[1]]></argument>

</request>

 

However we would like to specify a datasource URI to go with that, so that we can run the report against several databases (dev, uat, prod etc). The WS Guide seems to suggest we need a resourceDescriptor with a wsType of "datasource", so we have tried this:

 

Code:
[code]<request
operationName="runReport">
<resourceDescriptor
name=""
wsType="reportUnit"
uriString="/reports/test/hamp-test-0.1"
isNew="false">
<label></label>

</resourceDescriptor>

<resourceDescriptor
name=""
wsType="datasource"
uriString="/datasources/logweb_prod"
isNew="false"></resourceDescriptor>

<argument
name="USE_DIME_ATTACHMENTS"><![CDATA[1]]></argument>

</request>

 

This comes back with an error: Error message from report server: /datasources/logweb_prod is not a valid report so clearly it hasn't worked. Substantial searching in this forum hasn't revealed any examples. Can anyone shed any light? :S

 

Thanks!

Link to comment
Share on other sites

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

I've also tried running Wireshark on the TCP stream between iReport and the server, and tried what I believe iReport is sending to the server:

 

Code:
<request
operationName="runReport">
<resourceDescriptor
name=""
wsType="reportUnit"
uriString="/reports/test/hamp-test-0.1"
isNew="false">
<label></label>

</resourceDescriptor>

<resourceDescriptor
name=""
wsType="datasource"
uriString=""
isNew="false"><![CDATA[/datasources/logweb_prod]]></resourceDescriptor>

<argument
name="USE_DIME_ATTACHMENTS"><![CDATA[1]]></argument>

</request>

 

Sadly that doesn't work either. I'll leave the project for a day and see if anyone here can give me the right syntax. Thanks again.

Link to comment
Share on other sites

I'm afraid that what you are trying to do is not currently supported. The runReport operation always executes the report using the data source which is specified as part of the report unit definition, and you cannot run the report other data sources.

 

Dynamically switching between report data source could be achieved at this moment only via a custom data source implementation that uses a report parameter to delegate to arbitrary data sources.

 

Regards,

Lucian

Link to comment
Share on other sites

Edit: I forgot to thank you for your assistance - thanks very much. Your time is appreciated :D

 

Oh dear, that's one of our biggest bugbears with Crystal that we're trying to fix! I'm glad there's a workaround though. Would you be so kind as to give me an idea how to set up such a custom datasource implementation in iReport, or is this more involved than adding special kinds of parameters to a report?

 

If I get really stuck here, I think my alternative may run as follows (comments from all welcome). I'll have two main folders on the server: "reports" and "reports-compiled". Whenever I add a new report to the server, I will run a script to copy them to the compiled file, duplicating each one across the various connections I will need to use it with. The name of each can be set to "<report><connection>" so that the connection is easily specified in a SOAP call.

Post edited by: halfer, at: 2008/05/02 17:23

Link to comment
Share on other sites

halfer wrote:

Oh dear, that's one of our biggest bugbears with Crystal that we're trying to fix! I'm glad there's a workaround though. Would you be so kind as to give me an idea how to set up such a custom datasource implementation in iReport, or is this more involved than adding special kinds of parameters to a report?

 

This would not be a trivial task. One would have to write JasperServer data source service implementation that reads the value of a specific report parameter, (somehow) resolves a different data source service based on this value and delegates to this data source service. A custom/bean data source object would be created in the repository and used as report unit data source. Further details depend on how exactly you expect this mechanism to work (both via web service and via the web UI).

 

Regards,

Lucian

Link to comment
Share on other sites

Righty-ho, thanks for the clarification. Its strange, though, as my Java colleague says that he can pass a "connection object" to a Jasper library, so that an arbitrary JDBC connection can be used in preference to the datasource in the report, on the Jasper server.

 

I'm not a Java person, but wonder whether studying the source code of whatever library he is using might yield some results? I am not keen to dig into this in too much detail, though, given that you have told me that what I'm trying to do would be very difficult.

Link to comment
Share on other sites

I think you're right, Lucian. I grilled him on it later, and extracted a confession that he may have been using the libraries locally, not via the web service.

 

Meanwhile readers may be interested to see how I've solved this problem. My concern was that my reports would proliferate versions across each connection I want to use them with, and that I would have to write a script to delete old copies and to recreate new ones with a new JRXML file. In fact, the solution was easier than that.

 

I created a JRXML file on Jasper Server, with a pathname like this:

 

/reports/web/common/project/my-report

 

Then, for each connection, I create report units that cross-reference this file, with each having the correct pre-defined data source set:

 

/reports/web/conn1/project/my-report

/reports/web/conn2/project/my-report

/reports/web/conn3/project/my-report

 

Now all I need to do is to refer to the correct pathname, which contains the connection name, and also if I need to update the core JRXML file, I can just republish the one file. Easy when you discover how B)

Link to comment
Share on other sites

  • 10 months later...
  • 3 weeks later...
  • 3 months later...

yaroslav
Wrote:

Can you describe more detail how can I create report units that cross-reference to main file. Thanks

I guess that would involve uploading the JRXML as an independent resource in the repository, and then creating several report units that use the repository resource as main JRXML (chose From Content Repository in the report unit wizard).

Regards,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...