Jaspersoft / jrs-rest-php-client

REST API wrapper for PHP used to interact with JasperReports Server
GNU Lesser General Public License v3.0
63 stars 59 forks source link

Current code and docs out of date #8

Closed webdevilopers closed 10 years ago

webdevilopers commented 10 years ago

I installed the client via composer to integrate it into my ZF2 vendor folder with success. The autoloading works fine.

i followed this example: http://community.jaspersoft.com/questions/822686/how-connect-jasper-reports-php-application

Which is similar to others: http://community.jaspersoft.com/wiki/php-client-sample-code http://community.jaspersoft.com/questions/819111/php-client-php-fatal-error-uncaught-exception-jasperrestrequestexception-message

Dumping the client I recognized that the parameters were not set correctely.

Looking at the constructor the method and its arguments have totally changed:

    public function __construct($serverUrl, $username, $password, $orgId = null)
    {
        $this->serverUrl = $serverUrl;
        $this->username = $username;
        $this->password = $password;
        $this->orgId = $orgId;

        $this->restReq = new RESTRequest();
        if (!empty($this->orgId)) {
            $this->restReq->setUsername($this->username .'|'. $this->orgId);
        } else {
            $this->restReq->setUsername($this->username);
        }
        $this->restReq->setPassword($this->password);
        $this->restUrl2 = $this->serverUrl . BASE_REST2_URL;
    }

I changed my code:

use Jaspersoft\Client\Client as JasperClient;

$client = new JasperClient('http://localhost:8180/JasperReportsEngine/jasper', 'tomcat', 'pw');

        $info = $client->serverInfo();
        print_r($info);exit;

This setup seems to be up to date. But it gives the following error: An unexpected HTTP status code was returned by the server.

Furthermore examples in the docs seem to use old code too e.g.:

$repository = $client->getRepository(); 

This method does (no longer) exist. Looks like it was replaced by:

$client->repositoryService()->searchResources();

What has happened to the code? How to handle the exception?

I am using Tomcat6. Is Tomcat7 and / or the REST V2 Import Web Service API required?

Actine commented 10 years ago

Hello,

The documentation on community is for the 'old' client that is bundled with JRS in samples/php-client folder. The old client is discontinued as it uses old API, but this one has not officially released yet as a stable version.

You can find the docs for this client in /docs/index_static.html

With regard to the error.. What JRS version are you using? Also to get more information about the error you can catch the exception and look into errorCode and statusCode — what is specified there?

webdevilopers commented 10 years ago

Thanks for the reply @Actine .

Actually I am new to the project that is using Jasper. At the moment is a Ruby On Rails App that uses Tomcat5.5, iReport-2.0.4 and JasperReportsEngine.war as Tomcat Servlet.

Will this actually work with any of the APIs?

Actine commented 10 years ago

@webdevilopers I'm afraid this client will not help you. This is a client for JasperReports Server, a Java-based embeddable web application for storing, scheduling and generating reports (plus enterprise features like ad hoc analysis for commercial licenses). You are using just a library for generating reports. It's the JRS that has REST API, not the library.

If you are developing your own app that incorporates our report generating lib, you'll have to build all API's yourself (and your own client, too) if you need it.

webdevilopers commented 10 years ago

Thanks for the info @Actine . Maybe I can switch to the server version.