http://<server_ip>:<server_port>/nextreports-server/api
If users need to access these services using java code, then a client for these services already exists and can be found in ro.nextreports.server.api.client. Inside designer installation folder in lib there is nextreports-server-client-8.0.jar library which can be used. To see how it is used in designer you can look in ro.nextreports.designer.wizpublish . Here is the code used to publish/download report/charts to/from server. (it involves also how to authenticate, to get list of entities from server, create a folder in server structure and more)
For example to authenticate you have to do the following with the root url previously shown:
WebServiceClient client = new WebServiceClient();
client.setServer(url);
client.setUsername(userTextField.getText());
client.setPassword(new String(passField.getPassword()));
client.setPasswordEncoder(new Md5PasswordEncoder());
boolean authorized = false;
try {
authorized = client.isAuthorized();
} catch (Exception e) {
// connection error
e.printStackTrace();
return false;
}
To get entities from server:
List<EntityMetaData> entities = client.getEntities(folderPath);
This method sets the server url path by appending to base api url "storage/getEntities/" and then the folder path. There are some root constants used to create folderPath like /reports, /charts, /dataSources.
If you want to call Next web services from Javascript/JQuery and get reports from a path, you have also to be authenticated. Next example uses two javascript libraries:
Base64 encoder (jquery.base64.js) : https://github.com/carlo/jquery-base64/archive/master.zip
MD5 generation (core-min.js and md5-min.js) : https://code.google.com/p/crypto-js/#MD5
This example does an ajax get to obtain the list of reports from root /reports path. Request header contains an Authorization object. On success the list of entities (path and type) is shown in a html list.
<html>
<head>
<title>NextReports Server JQuery Test</title>
<script src="jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="jquery.base64.js" type="text/javascript"></script>
<script src="core-min.js" type="text/javascript"></script>
<script src="md5-min.js" type="text/javascript"></script>
<script>
var serverPath = "/reports";
var username="admin";
var password="1";
var passwordHash = CryptoJS.MD5("1");
var base64 = $.base64.encode( username + ":" + passwordHash );
$.ajax( {
type: "GET",
url : 'http://localhost:8081/nextreports-server/api/storage/getEntities?path=' + serverPath,
dataType : "xml",
beforeSend : function(xhr) {
console.log(base64);
xhr.setRequestHeader('Authorization', 'Basic ' + base64);
},
error : function(xhr, ajaxOptions, thrownError) {
console.log("error");
alert(thrownError);
},
success : function(data) {
console.log("success");
console.log(data);
$('#title').append(serverPath);
var paths = data.getElementsByTagName("path");
var types = data.getElementsByTagName("type");
var root = $("#list");
for (var i=0; i<paths.length; i++) {
var type = "";
if (types[i].textContent === "1") {
type = "folder";
} else if (types[i].textContent === "3") {
type = "next-report";
} else if (types[i].textContent === "4") {
type = "jasper-report";
}
root.append('<li>'+paths[i].textContent+ ' (' + type + ')</li>');
}
}
});
</script>
</head>
<body>
<div>
<span id="title">List of reports from path: </span>
<ul id="list"></ul>
</div>
</body>
To be able to run this example you must be in the same domain as server, otherwise a cross domain exception will be seen in console. From NextReports Server 8.1 inside web.xml for jersey.springServlet you can uncomment the following to allow for cross domain testing calls (please be sure to comment it back after you make your tests):
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>ro.nextreports.server.web.core.ResponseCorsFilter</param-value>
</init-param>
Weabers Inc. is focused on the future of the web. We are a fully integrated design and technology company that transforms ideas into future-proof digital experiences, and help our clients reach the next step in their digital evolution.
ReplyDeletelet know here > weabersinc
IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes. IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble.Final Year Projects for CSE
DeleteSpring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining .
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai
The Angular Training covers a wide range of topics including Angular Directives, Angular Services, and Angular programmability.Angular Training
This is not just a mere piece of work. This is ART.
ReplyDeletesoftware development company in delhi
This particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… best web development usa
ReplyDelete
ReplyDeleteReally it is a piece of good conversation information, I never see like this blog it's awesome, keep sharing like this, Thank you so much!!!
Best Aviation Academy in Chennai
Best Air hostess Training in Chennai
Pilot Training in Chennai
Airport Ground staff Training in Chennai
Airport Flight Dispatcher Trainee in Chennai
RTR - Aero Training in Chennai
Cabin Crew Training in Chennai
Aviation Academy in Chennai
Aviation training institute in Chennai
Aviation Course Training in Chennai
Ground staff Training institute in Chennai
Airhostess Training institute in Chennai
Cabin Crew Course
PRIVATE PILOT LICENCE (PPL) Training in Chennai
COMMERCIAL PILOT LICENCE (CPL) Training in Chennai
This comment has been removed by the author.
ReplyDeleteThanks for sharing. We would like to be able to call the runReport method of the api via jQuery. Im looking for input on how to formulate the query for the ajax call. The method accepts an object of type runReportMetaData.
ReplyDelete@Path("runReport")
public String runReport(RunReportMetaData runReportMetaData) { ... }
I would assume the call would be similar to as follows:
.ajax( {
type: "POST",
dataType : "xml",
url : 'http://localhost:8081/nextreports-server/api/report/runReport?reportId=123&reportFormat=HTML¶metersValues=listofvalues
etc...
Would appreciate confirmation on the url.
Thank you