sebastianmor Posted September 6, 2019 Share Posted September 6, 2019 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 orderbody 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:=0E837801E44CBEEED7EA2317528C6D5AResponse: <?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-f9ca-4c25-88da-cab221be3782/status/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-f9ca-4c25-88da-cab221be3782 (requestId)JSESSIONID:=4BC83CBDEA599E91F87BFBC351191D87Fourth request for output :http://localhost:8080/reportservice/rest_v2/reportExecutions/aa4bbbd8-f9ca-4c25-88da-cab221be3782/exports/fac30a22-dc94-4d67-a606-72528b49553c/outputResourceJSESSIONID:C613D173CE09E27982BF37A36F46E6D0I 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=/jasperserverhttps://community.jaspersoft.com/documentation/tibco-jasperreports-server-rest-api-reference/v720/authenticationWe 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now