Problem with jsessionID for reportExecution

Hi everyone,

I have a problem with report execution from http client (4.5.9 http dependency) java, we use 7.1 version. We consume from java restAPI to jasperServer instance. This problem is about session , i think that problem occurs because the jsessionID for each request is different. this is structure from my request for export report.

request structure order

body from request:
        " <reportExecutionRequest>\n" +
        "    <reportUnitUri>"+Const.PATH_UNIT_REPORT+"</reportUnitUri>\n" +
        "    <async>true</async>\n" +
        "    <freshData>false</freshData>\n" +
        "    <outputFormat>pdf</outputFormat>\n" +
        " </reportExecutionRequest>"; 

First request: sending Request to url: http://localhost:8080/reportservice/rest_v2/reportExecutions/
JSESSIONID:=0E837801E44CBEEED7EA2317528C6D5A

Response: 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportExecution>
<exports>
<export>
<id>fac30a22-dc94-4d67-a606-72528b49553c</id>
<status>queued</status>
</export></exports>
<reportURI>/organizations/org1/fldr1/reports/CustomReports/StateProjec</reportURI>
<requestId>aa4bbbd8-f9ca-4c25-88da-cab221be3782</requestId>
<status>queued</status>
</reportExecution>

Second request for check status:
http://localhost:8080/reportservice/rest_v2/reportExecutions/aa4bbbd8-f9...

response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status>queued</status>

Third request for export :
http://localhost:8080/reportservice/rest_v2/reportExecutions/aa4bbbd8-f9... (requestId)
JSESSIONID:=4BC83CBDEA599E91F87BFBC351191D87

Fourth  request for output :
http://localhost:8080/reportservice/rest_v2/reportExecutions/aa4bbbd8-f9...
JSESSIONID:C613D173CE09E27982BF37A36F46E6D0

I send the cookie in two ways:

The documentation says: 
For optimal performance, the session ID from the cookie should be used to keep the session open. To do this, 
include the cookie in future requests to the other RESTful services. For example,
given the response to the POST request above, future requests to the repository services should include the following line in the header:

Cookie: $Version=0; JSESSIONID=52E79BCEE51381DF32637EC69AD698AE; $Path=/jasperserver
https://community.jaspersoft.com/documentation/tibco-jasperreports-serve...

We work in this ways:

1.

Const.HEADER_MODIFY_TO_HEADER_REQUEST is equivalent to : Cookie: $Version=0;
Const.PARAMETER_JSESSIONID+sessionId+Const.PARAMETER_JASPER_SESSION is equivalent to:JSESSIONID=XXXXX; $Path=/reportservice;


req.setHeader(Const.HEADER_MODIFY_TO_HEADER_REQUEST, Const.PARAMETER_JSESSIONID+sessionId+Const.PARAMETER_JASPER_SESSION);
HttpClient client =  HttpClientBuilder.create().build();
http = client.execute(req, httpContext);   


2.

 BasicCookieStore cookieStore = new BasicCookieStore();
 BasicClientCookie cookie = new BasicClientCookie("JSESSIONID", sessionId);
 cookie.setPath("Path=/reportservice; HttpOnly");
 cookie.setDomain("localhost"); (FOR TEST)
 cookie.setSecure(true);
 cookieStore.addCookie(cookie);
 HttpClient client =  HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();


But not work, the sessionID always change por each request. Maybe , i think for that issue is not working. so, somebody have idea about that. We dont use the rest client from jasper, its confuse and i cant find any example of a similar implementation.


thanks in advance
 

sebastianmor's picture
Joined: Sep 6 2019 - 5:27am
Last seen: 3 years 4 months ago

0 Answers:

No answers yet
Feedback