Hi,
I am using jasperserver 4.2. and I used PHP sample that was disturbed in package. Everything is working good, even the scheduler, but this simplified scheduler is not giving me options to choose different parameters(input controls).
I've tried to save parameters using $job->parameters = $_POST['params'] but it is not showing parameter.
Does anyone know, or can paste a code that will manage to solve this problem?
15 Answers:
Try this approach:
$params=array();
$param1= new JobParameter();
$param1->name="inputcontrol id";
$param1->value=3; // any type
$param2=new JobParameter();
$param2->name="inputcontrol id";
$param2->value="test string"; // any type
Post Edited by ogavavka at 06/27/2012 14:40
Hi again...
Do you know maybe how to call JobCalendarTrigger method, with what parameters.
If you can just put an example of parameters to store in vars.
I am getting this error....
[03-Jul-2012 07:15:42 UTC] PHP Fatal error: Uncaught SoapFault exception: [ns1:Client] Specify the month day(s) when the job should run.
in C:\\inetpub\\wwwroot\\reports\\ReportSchedulerService.php:196
Stack trace:
#0 C:\\inetpub\\wwwroot\\reports\\ReportSchedulerService.php(196): SoapClient->__soapCall('scheduleJob', Array, Array)
#1 C:\\inetpub\\wwwroot\\reports\\reportJobSave.php(55): ReportSchedulerService->scheduleJob(Object(Job))
#2 {main}
thrown in C:\\inetpub\\wwwroot\\reports\\ReportSchedulerService.php on line 196
First row of error is changing when I change data, it all depends but I can not get in touch what are the good parameters.
I am not good in PHP SOAP call so I am a bit confused.
I have this code for now...
$_POST vars are array of select input with multiple choice
Code: |
$triggerC = new JobCalendarTrigger(); $triggerC->minutes = "2"; $triggerC->daysType = "MONTH"; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = $_POST['themonths']; $triggerC->weekDays = $_POST['weekdays']; $job->calendarTrigger = $triggerC;</td></tr></tbody></table> |
this is the code....
Is this what you mean: ?
some parameters are
$triggerC->minutes = "2"; $triggerC->daysType = "MONTH"; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = "Jan, Feb"; $triggerC->weekDays = "Mon, Tue"; $job->calendarTrigger = $triggerC;
With this values, it cannot create job because of MONTH constant.
I've tried with MONTH not "MONTH" but it is the same....
do not get it....
Code: |
$triggerC = new JobCalendarTrigger(); $triggerC->minutes = "2"; $triggerC->daysType = "MONTH"; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = $_POST['themonths']; $triggerC->weekDays = $_POST['weekdays']; $job->calendarTrigger = $triggerC;</td></tr></tbody></table> |
Yes that what i mean. Thanks.
So after looking at your parameters and after analysing php file ReportSchedulerService.php (included in JS) in which JobCalendarTrigger class is defined and commented with type of parameters driving conclusion that you supply incorrect parameters
look at code section, and don`t forget to scrool there are 52 lines
Tell me if this helps.
Code: |
you supply this: $triggerC->minutes = "2"; - good $triggerC->daysType = "MONTH"; - can be but actualy bad $triggerC->hours = "2"; - good $triggerC->monthDays = ""; - good $triggerC->months = "Jan, Feb"; - bad $triggerC->weekDays = "Mon, Tue"; - bad you should supply this: $triggerC->minutes = "2"; $triggerC->daysType = CalendarDaysType::MONTH; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = array(0,1); $triggerC->weekDays = array(2,3); or can try this code to use POST data but you nedd change POST script (from which you receive data) so it supply "themonths" and "weekdays" values in integer representation $triggerC = new JobCalendarTrigger(); $triggerC->minutes = "2"; $triggerC->daysType = CalendarDaysType::MONTH; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = explode(",",$_POST['themonths']); $triggerC->weekDays = explode(",",$_POST['weekdays']); $job->calendarTrigger = $triggerC; P.S. The days are represented as java.lang.Byte values between 1 (Sunday) and 7 (Saturday). The months are specified as java.lang.Byte values between 0 (Jan) and 11 (Dec). found this in ReportJobCalendarTrigger.java so assuming when using php client representation of numbers are same used classes from ReportSchedulerService.php class JobCalendarTrigger extends JobTrigger { public $minutes; // string public $hours; // string public $daysType; // CalendarDaysType public $weekDays; // ArrayOf_xsd_int public $monthDays; // string public $months; // ArrayOf_xsd_int } class CalendarDaysType { const ALL = 'ALL'; const WEEK = 'WEEK'; const MONTH = 'MONTH'; } |
Post Edited by ogavavka at 07/04/2012 22:58
Post Edited by ogavavka at 07/04/2012 23:00
Actually I was a little stupid when displaying you the parameters that I send to server.
My parameters are just like you wrote here...because I use POST method and months and weekDays are checkboxes with
name="params[]" and they are an array.
Sorry for wrong posting here.
Now, I've tried to directly put CalendarDaysType::MONTH; and it is not working.
When I put CalendarDaysType::WEEK it is working with the same parameters. It is just like he doesn't want go thru server :/ weird
And yes, these are the classes from ReportSchedulerService.php and I already checked comments right from methods and constants and I sticked to it.
these are the values for months:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 6 [4] => 7 [5] => 10 [6] => 11 )
for days:
Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 5 )
for hours: "8"
for mins: "50"
and ofcourse daystype is:
$triggerC->daysType = CalendarDaysType::MONTH;
Now, when I saw your code and compared to mine, I think that it just some combination of parameters that has to be sent to the server, and that there are some parameters that must not be sent with $triggerC->daysType = CalendarDaysType::MONTH constant involved.
I will try to resolve and check this today and if I find solution, will post it here.
And if you have any other idea please share.
And this is the error constantly repeating when changing parameters but stick to MONTH constant
[05-Jul-2012 06:54:58 UTC] PHP Fatal error: Uncaught SoapFault exception: [ns1:Client] Specify the month day(s) when the job should run.
Specify the months when the job should run.
in C:\inetpub\wwwroot\reports\ReportSchedulerService.php:196
Stack trace:
#0 C:\inetpub\wwwroot\reports\ReportSchedulerService.php(196): SoapClient->__soapCall('scheduleJob', Array, Array)
#1 C:\inetpub\wwwroot\reports\reportJobSave.php(134): ReportSchedulerService->scheduleJob(Object(Job))
#2 {main}
thrown in C:\inetpub\wwwroot\reports\ReportSchedulerService.php on line 196
Code: |
$triggerC->minutes = "2"; $triggerC->daysType = CalendarDaysType::MONTH; $triggerC->hours = "2"; $triggerC->monthDays = ""; $triggerC->months = array(0,1); $triggerC->weekDays = array(2,3); |
Post Edited by vekkica at 07/05/2012 06:56
Code: |
PATTERN_CRON_MONTH_DAYS as Regular Expression ^((([1-9]|[012]\\d|3[01])(\\-([1-9]|[012]\\d|3[01]))?)(,(([1-9]|[012]\\d|3[01])(\\-([1-9]|[012]\\d|3[01]))?))*)|(([1-9]|[012]\\d|3[01])\\/\\d+)|(\\*)$ as a Java string "^((([1-9]|[012]\\\\d|3[01])(\\\\-([1-9]|[012]\\\\d|3[01]))?)(,(([1-9]|[012]\\\\d|3[01])(\\\\-([1-9]|[012]\\\\d|3[01]))?))*)|(([1-9]|[012]\\\\d|3[01])\\\\/\\\\d+)|(\\\\*)$"</td></tr></tbody></table> |
I have just figured it out and wanted to post it here but you already did :D
When it comes to MONTH you have to specify dates in months to schedule report and in that 1,2,3, 5 10, 30, 1-25 format.
Thank you for your help, and I hope I will manage to do everything else on my own, and not to bother you again :)
Hi again, I do not want to open another subject, I will post my new question here.
http://domain.name:7080/jasperserver/flow.html?_flowId=searchFlow
Lets say this is my adress for jasperserver reports when I click on content files.
Now.... in the content files I can create folders, but I do not want to do it manually on server, but with PHP. Is it possible to do that?
The idea is to get user who wants to create scheduler report, check if his folder exists and if not create one called by his username.
Notice that port is 7080 and my main page is not.
yes it`s possible .
Look at sample file "listReports.php" there you will find how to query server for folders list
there you can check that folder exists.
if not present then create it using code in code section modifying top variables for your server config and make sure that parent folder exists
P.S. For more information look in JasperReports-Server-Web-Services-Guide.pdf Chapter 5, sample file client.php (at bottom)
Beware this not tested by me, just create workflow in my mind
Tell me if this helped you.
Code: |
require_once('client.php'); //start session, authentificate, etc... make sure username and password is present in $_SESSION $js_url = "http://localhost:8080/jasperserver-pro/services/"; $ws_uri = $js_url . "repository"; $scheduler_folder_uri="/reports/scheduled"; $folder_name="joeUser"; $folder_uri=$scheduler_folder_uri.$folder_name; $folder_label="Joe Folder"; $folder_description="Joe scheduled reports"; global $_SESSION; $connection_params = array("user" => $_SESSION["username"], "pass" => $_SESSION["password"]); $info = new SOAP_client($ws_uri, false, false, $connection_params); $op_xml = "<request operationName=\\"put\\" locale=\\"en\\">"; $op_xml .="<resourceDescriptor name=\\"$folder_name\\" wsType=\\"folder\\" uriString=\\"$folder_uri\\" isNew=\\"true\\"><label>$folder_label</label>"; $op_xml .="<description>$folder_description</description>"; $op_xml .="<resourceProperty name=\\"PROP_PARENT_FOLDER\\"><value>$scheduler_folder_uri</value></resourceProperty></resourceDescriptor></request>"; $params = array("request" => $op_xml); $response = $info->call("put",$params,array('namespace' => $GLOBALS["namespace"])); </td></tr></tbody></table> |
now I have another question regarding the time format and time on jasperserver.
lets say I'm sending this format 2012-07-18T10:00:00.000Z on jasperserver and this is ok when he receives this format but then he transforms 10:00 into 12:00.
When I try to send 10:00 - 2 or 8:00 then the time is ok, but only when it is not pass 8:00.
What should I do? The time on server is ok when scheduling on jasperserver directly. If I put 10:00 it is 10:00 but when receiving it with PHP it adds 2 hours.
On PHP listing of jobs it is 10:00.
my timezone is Europe/Zagreb, I've changed it when it didn't work properly, but it doesn't work now either...