Hi,
I'm new to Jaspersoft, so my apologies in advance if my question applies more broadly and I'm posting in the wrong place. I'm trying to use a web service in Jaspersoft that needs a call to its Login function first. That function receives a username and password, and returns a temporary access token. That token can be used to issue another function call later that will return actual data for the report.
So far I've done the following:
- I created a "Login" sub-report. Use the web service data adapter, point it to the Login method, provide credentials etc. The token gets stored in the field called "token".
- I added a variable to that sub-report, called "accessToken", whose Expression is set to $F{token}. I can see that the correct value gets stored if I add a text field and set its expression to $V{accessToken}.
- I created the main report and added the sub-report to the first band. I also added an "accessToken" variable there as well. For sub-report properties, under Return Values, I set From and To to "accessToken", hoping that main report's access token varialble will be populated with the data from the sub-report.
- Lastly, in the Query Dialog of the main report, I set the Base URL to something like GetEmployees?accessToken=$V{accessToken} - this should return a JSON of a list of employees, if the access token is valid. However, when I try to get the server's response, I get an exception, and it looks like $V{accessToken} doesn't get substituted with the actual token value.
Is my approach generally correct? How can I use the data obtained from a sub-report in a call to another web service function? Thank you!
2 Answers:
Hi.
>>trying to use a web service in Jaspersoft that needs a call to its Login function first.
Jasperserver works with SSO auth, and other authentication methods.
Please read the docs:
TIBCO JasperReports Server Authentication Cookbook
TIBCO JasperReports Server Security Guide
To clarify, the authentication is not for JasperServer, but for puling data into the report, from a Web Service. I have a web service that returns JSON data I'd like to bind to a report, but before I can pull that data, I need to get an authentication token from the same web service, by calling a Login function. I think what you are referring to is authentication for the Jasper Server itself.
I also tried the following: the main report retrieves the access token and stores it in a field. The subreport is added to the main report with a parameter. That parameter is set to $F{token}. In the Base URI, I use $P{accessToken} as shown in the video, but that gives me a Bad Request error.