This is part of the BI Publisher Web Service series. I have already covered ‘How to use BI Publisher Web Service with JDeveloper 11G’ and ‘How to Run a Report with BI Publisher Web Service’. If you haven’t checked the posts and are interested in please click the above links to check.
Today, I’m going to talk about how to schedule a BI Publisher report with the Web Service within a Java application.
Which Method to Schedule Report?
So which method we can use to schedule ? It’s like the ones for running a report, there are two methods. One is ‘scheduleReport() and another is ‘scheduleReportInSession()’. ‘scheduleReport() takes a username and password while scheduleReportInSession takes a session token along with a ‘ScheduleRequest’ object. And both returns a job id, which you can use to monitor and manage the scheduled job later.
Definition:
- String scheduleReport(ScheduleRequest srequest, String username, String password)
- String scheduleReport(ScheduleRequest srequest, String SessionToken)
With those methods you can do pretty much the same things you can do from the UI. I’m going to use scheduleReport() method for my example below.
How to Call scheduleReportInSession()
Before you run the scheduleReportInSession() method, first you need to create a ReportRequest object by giving a report path for the report you want to run. This is exactly the same step I mentioned in the last post with runReportInSession().
Second, you need to create a DeliveryRequest object if you need to deliver the report. You can set a delivery option and its delivery type specific information here.
Third, now you need to create a ScheduleRequest object by setting the ReportRequest and DeliveryRequest objects.
And finally you can call the scheduleReportInSession() method to schedule a report.
Here is a list of those four steps:
- Create DeliveryRequest object
- Create ReportRequest object
- Create ScheduleRequest object
- Call scheduleReportInSession() method
So, let’s take a look at the each step.
Create DeliveryRequest Object
1) Create Delivery Option to Set Delivery Information
First you need to create a DeliveryOption object. There are different types of the objects, each of which is for each delivery type. So if you want to deliver your report by email then there is a one DeliveryOption for Email called ‘EmailDeliveryOption’. And it goes the same for other delivery options. Here is a list of the delivery options available for you with BI Publisher.
- Fax
- FTP
- Local File System
- Printer
- WebDAV
And all the options are available with the Web Service. When you create the DeliveryOption you can set each of the delivery option specific information. For example, if you want to use the email delivery option then you can set the email delivery related information such as an email subject, an email address shown as ‘from’ or ‘cc’, etc.
Here is a list of the DeliveryOption types and a list of methods that you can use to set the delivery related information.
EmailDeliveryOption
Method | Description |
void setEmailTo(String) | You can set a To Email address. |
void setEmailSubject(String) | You can set a Email subject. |
void setEmailFrom(String) | You can set a Email From address. |
void setEmailCC(String) | You can set a CC Email Address. |
void setEmailBody(String) | You can set a Email body message. |
FaxDeliveryOption
Method | Description |
void setFaxNumber(String) | You can set a fax number. |
void setFaxServer(String) | You can set a fax server name which is the one that has already been registered at your BI Publisher Server. |
Printer
Method | Description |
void setPrinterName(String) | You can set a Printer name that has already been registered at your BI Publisher server environment. |
void setPrintNumberOfCopy (String) | You can set a number of copy that you want to print the report in. |
void setPrintRange(String) | You can set a range of pages of the report that you want to print. |
void setPrintSide(String) | You can set both sides printing. |
void setPrintTray(String) | You can specify which printer tray you want to use for your printing. |
FTP
Method | Description |
void setFtpServerName (String) | You can set a FTP server name that has already been registered at your BI Publisher server. |
void setFtpUserName(String) | You can set a username for the FTP server. |
void setFtpUserPassword (String) | You can set a password for the FTP server. |
void setRemoteFile(String) | You can set a file name for the report output. |
void setSftpOption(String) | You can set SFTP option. |
Local File System
Method | Description |
void setDestination(String) | You can set a full path for the report output including the report output file name so that the report can be saved on the specified location on the server’s file system. |
WebDAV
Method | Description |
void setServer (String) | You can set a WebDAV server name that is registered at your BI Publisher server. |
void setRemoteFilePath (String) | You can set a file name for the report output and the path. |
void setUserName (String) | You can set a username for the WebDAV server. |
void setPassword (String) | You can set a password for the WebDAV server. |
void setDeliveryAuthType (String) | You can set an authentication type of the WebDAV server. |
void setDeliveryAuthTypeBasic (String) | You can set Basic authentication type. |
void setDeliveryAuthTypeDigest (String) | You can set Digest authentication type. |
Note that you need to setup the delivery servers appropriately from your BI Publisher Server UI before you use the delivery options with the Web Service. For example, if you want to use the Email delivery option then you need to setup a default Email server from the UI. Only the delivery options configured appropriately at the server can be used from the Web Service.
Example:
//Create a Delivery Option for Email delivery //Set Email delivery related information |
2) Create Delivery Request
Once you have created the DeliveryOption then you can create a DeliveryRequest object by passing the DeliveryOption object.
Here is a list of the methods that you can use to set the DeliveryOption to create a DeliveryRequest.
- void setEmailOption (EMailDeliveryOption)
- void setFaxOption (FaxDeliveryOption)
- void setPrintOption (PrintDeliveryOption)
- void setFTPOption (FTPDeliveryOption)
- void setLocalOption (LocalDeliveryOption)
- void setWebDAVOption (WebDAVDeliveryOption)
Example:
|
Create ReportRequest Object
This is exactly the same process as I talked at the last post. So take a look at the post if you don’t know how to create the ReportRequest object.
Create ScheduleRequest Object
When you create the ScheduleRequest object you can set a report to schedule and the delivery information by setting the above mentioned two objects, DeliveryRequest and ReportRequest.
Also, you can set the following information to the ScheduleRequest object.
- Email Address for Notification
- Indication of Saving the Data
- Indication of Saving the Report Output
- Repeat Count
- Repeat Interval
- Start Date for the Scheduling
- End Date for the Scheduling
- Calendar for Scheduling
- Time Zone for Scheduled Time
- Job Name
- Delivery Request
- Report Request
- Indication of Public Scheduling
- Bursting Delivery
If you don’t set the Start Date then it would be the same as ‘immediately run’ option.
And here is a list of the methods that you can use to set such options.
Function | Method | Description |
Report Request | void setReportRequest (ReportRequest) | You can set a ReportRequest object to select a report that you want to schedule and run. |
Delivery Request | void setDeliveryRequest (DeliveryRequest) | You can set a DeliveryRequest object to set a delivery option. See ‘Pre-Requisite for Delivery’ section for the detail of how to set the delivery settings. |
Start Date for the Scheduling | void setStartDate(Calendar) | You can set a start date for the scheduling to start. If it’s null or not specified then the scheduled job will run immediately. |
End Date for the Scheduling | void setEndDate(Calendar) | You can set an end date for the scheduling. |
Job Name | void setUserJobName(String) | You can set a name for this scheduling job. |
Calendar | void setJobCalendar(Calendar) | You can set which calendar to use for the scheduling time. E.g. Gregorian |
Time Zone | void setJobTZ(String) | You can set an appropriate time zone that you want to use for the specified time for the scheduling. |
Repeat Count | void setRepeatCount(int) | You can set a repeat count for the scheduled job. |
Repeat Interval | void setRepeatInterval(int) | You can set an interval time for the scheduled job to run. |
Email Address for Notification | void setNotificationTo(String) | You can set an email address to send a notification of the scheduled job. |
Request to send a notification message when failed | void setNotificationWhenFailed (boolean) | You can specify whether you want to send a notification message when the scheduled job fails or not. |
Request to send a notification message when Success | void setNotificationWhenSuccess (boolean) | You can specify whether you want to send a notification message when the scheduled job runs successfully or not. |
Request to send a notification message when Warning | void setNotificationWhenWarning (boolean) | You can specify whether you want to send a notification message when the scheduled job ends with warning or not. |
Indication of Saving the Data | void setSaveDataOption(boolean) | You can specify whether you want to save the data for the scheduled job or not. The data will be saved when it’s set True and it can be accessed only through BI Publisher Enterprise UI. |
Indication of Saving the Report Output | void setSaveOutputOption(boolean) | You can specify whether you want to save the report output for the scheduled job or not. The output will be saved when it’s set True and it can be accessed only through BI Publisher Enterprise UI. |
Indication of Public Scheduling | void setSchedulePublicOption (boolean) | You can specify whether you want to make the scheduled job to be publicly accessible or not. |
Bursting Delivery | void setScheduleBurstringOption (boolean) | You can specify whether you want to use the bursting option that is pre-configured for this report or not. In order to use this option you need to make sure that the report you’re scheduling has been configured for the bursting option through BI Publisher Enterprise UI. |
Example:
//Set DeliveryRequest //Set ReportRequest //Set scheduling information |
Call scheduleReportInSession()
Now you can set the ScheduleRequest and the session token to run the scheduleReprotInSession() method. It returns a job id when it runs successfully, which you can use to monitor and manage the job. For example, in future when you need to suspend or delete the job then you will need this job id to do such.
Example:
job_id = publicReportService.scheduleReportInSession(sreq, sid); |
And that’s it! Once you run the scheduleReportInSession() successfully then you should see a new job created from the BI Publisher’s scheduler UI page.
There are more BI Publisher WebService APIs available, but these I’ve covered are the most common. If you have some other APIs that you want me to cover let me know, I can talk about that too.
Here is my whole source code for this scheduling exercise.
package project1; import com.oracle.xmlns.oxp.service.publicreportservice.AccessDeniedException; import java.io.IOException; public class BipServletTest extends HttpServlet { public void init(ServletConfig config) throws ServletException { public void doGet(HttpServletRequest request, try { public String getSessionID(String username, String password, PublicReportService publicReportService) throws AccessDeniedException_Exception { public String scheduleReportInSession(PublicReportService publicReportService, EMailDeliveryOption em = new EMailDeliveryOption(); String job_id =""; } |
Hi,
ReplyDeleteI have a question regarding scheduling in BIP. I am creating a report request not by calling API. For example let us consider that I am creating a report request called MyRequest. I am performing following steps:
1. Create a directory MyRequest
2. Copy the required rtf file
3. Copy Sample.xdo to MyRequest directory and rename it to MyRequest.xdo
4. Modify MyRequest.xdo to change the input file name to MyRequest.xml
Now, I need to schedule this job. As per my understanding, I have now two options:
1. Directly insert the job into QRTZ table in database : Is this possible? If possible how do I do that and what are the tables to be updated?
2. Use BIP APIs to achieve this. If I use BIP API to do this, how do I get the job object that need to be passed along with ScheduleRequest
Thanks and Regards
Angsuman
Hi Nishida,
ReplyDeleteGreat Job!!
You mentioned Running a report using Report Request Function, then about scheduling a report using Schedule Request Function separately, Is there a way we could Schedule and run the same same report at a time by combinign these 2 functions??
Thanks
Swathi
Hi Nishida,
ReplyDeleteI tried configuring stbeehive.oracle.com as email server. When i tried to schedule reports, I got the following exception
oracle.apps.xdo.service.delivery.DeliveryException: oracle.apps.xdo.delivery.DeliveryException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
Please help.
Regards,
Smitha
Hi,
ReplyDeleteI am using BIP 11G. I am unable to make webservice call to scheduleReportInSession it throws below error but I am able to execute other api's(runreport,getFolderContentsInSession etc )please help me
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:119)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy33.scheduleReportInSession(Unknown Source)
at PublicReportServiceClient.main(PublicReportServiceClient.java:73)
There is a bug in 11g scheduler web service API. The new release of 11g is coming up pretty soon, within a few weeks, hopefully we can announce this week. I would recommend to wait for a second.
ReplyDeleteThe Issue i have raised was solved by replacing wsdl to http://10.12.180.31:7777/xmlpserver/services/v2/ScheduleService?wsdl but fallen into other issue (it always returns null)
ReplyDeleteMay be 11G BUG.
Hi Kanichiro Nishida,
Could you please provide the link of 11G scheduler bug ?
Could please let me know which version works fine with schduleReport so that I can request our admin team to install
ReplyDeleteI don't think there is a bug filed, the scheduler WS API just not there in the first release of 11g. Good news is, we just announced the new version of 11g today, the download should be available pretty soon. oh, and this version will provide a full functionality of the scheduling through WS.
ReplyDeleteThanks Kanichiro Nishida you have saved my time a lot.
ReplyDeleteIt's really a good news.
This page looks gr8 in iphone as well :-) .
Thanks for the comments, Sarada! If not yet, please make sure you follow @bipublisher on twitter, where I'm making all the BIP related important announcements. It's a great way to keep updated.
ReplyDeleteCould you pls post a blog for lattest version 11.1.1.5 how to schdule report since I am facing few issues while excluding Delivery report
ReplyDeletehttp://forums.oracle.com/forums/thread.jspa?threadID=2216338&tstart=0
Hi Sarada, the latest release 11.1.1.5 brought all the Schedule related functionality back for the web service and the new doc covers all the APIs available too.
ReplyDeletehttp://download.oracle.com/docs/cd/E21764_01/bi.1111/e18863/toc.htm
I'll write a series of the posts with some samples soon, so stay tuned. and please make sure you follow @bipublisher, where I make announcements when I publish a new post.
ScheduleRequest sr = new ScheduleRequest();
ReplyDeletesr.setStartTime("2011-06-02T11:41:00");
Not working. Testing in eclipse & BIP 11.1.1.5.
Do we need to set dataModelUrl ?
_durga
Thanks for such informative post.
ReplyDeletescheduleReport API :
For me run now option is working fine by not specifying the start date.
Setting start date is not working by specifying following.
scheduleRequest.setStartDate("2011-10-26T11:41:00");
scheduleRequest.setRepeatCount(1);
scheduleRequest.setRepeatInterval(1);
Please help.
Thanks in advance,
Aparna
I am using OBIEE version 11.1.1.5
ReplyDeleteHi Nishida,
ReplyDeleteI am able to make a call to scheduleReportInSession but the return type never match with JOB id in the job history of BIP
Pls help.
As to the setStartDate looks there is some bug, i'm looking at the workaround, will update soon!
ReplyDeleteHi Sarada, are you using 11.1.1.3 or 11.1.1.5 ?
ReplyDeleteIt's 11.1.1.5
ReplyDeleteIn weblogic, following error is logged when scheduled through webservice.
ReplyDelete'unable to store job with name '1155'and group 'admin' because one already exists with this identification org.quartz.objectalreadyexistsexception'
If i create 2 post dated jobs through UI then it gets name as num1 and num1+1. Then with WS, WS call returns num1+2 as job name. Not sure still why this error is coming.
When created through UI no error is shown, instead the action parameters are displayed.
Hi Nishida,
ReplyDeleteprevious in 11.1.13 getFolderContentsInSession is throwing errors : http://forums.oracle.com/forums/thread.jspa?messageID=9638205�
could pls let me know is it because of the parameter "folderAbsolutePath" in 11.1.1.5 in the older version it is "reportAbsolutePath"?
as per aparna schedulereport returns improper job id is a bug right?
scheduleRequest.setStartDate("2011-06-03T10:10:00");
ReplyDeletescheduleRequest.setRepeatCount(2);
scheduleRequest.setRepeatInterval(30000);
Seem to work. Tho, the start Date was not displayed in the OBIEE GUI. Also the interval is in milliseconds (the documentation says it's seconds)
Hi Nishida,
ReplyDeleteI am running 1000 templates with bursting and I would like to know the status of the report.
I am trying to run
scheduleReportInSession() and the return type I am passing to getScheduledJobInfoInSession() for report status.
Is this the only way as scheduleReportInSession returns invalid jobid.
Can this be achived in the other way round?
Hi guys, as to the invalid job id and the getFolderContents, we're checking into now. Will get back.
ReplyDeleteHi Sharada/Kanichiro
ReplyDeleteCan you tell me which Webservice are you using -v2/scheduleservice or publicreportservice ?
Hi Sharada/Kanichiro
ReplyDeleteCan you tell me which BIP WS are you using to make scheduler work - v2/scheduleservice or publicreportservice
Sreevalli,
ReplyDeleteIt's based upon requirment. If you are looking like report to devlier or burst then v2/scheduleservice
if you just want to create a report you can go for publicreportservice .
publicreportservice doesn't have scheduleservices implemented.
Thanks for your response Sarada . We are using v2/scheduleservice and are on 11.1.1.5v . But the method jst returns null instead of job id . any idea ? do you think we need to pass deliveryinfo ? can i have your email id so that i can send my sample code .
ReplyDeleteRegards
Sreevalli
Hi Sreevalli,
ReplyDeleteThere is a bug with the JOB id scheduleReportInSession returns invalid number(actual jobid -1) and sometimes null.Hope Nishida is looking into this issue.
You can still execute with aparna comment but not 100% success.
We have raised an SR on this issue. will let you know if it is fixed.
pls find my email : sarada.taraka@gmail.com
Kanichiro, please let us know if there is a patch to fix the issue with the job_id being null or if there is a workaround, I am experiencing the same issue.
ReplyDeleteThanks!
Same here. The reportservice scheduler api returnes a null jobid.
ReplyDeleteCan anyone tell me , How can one assign existing roles to a newly created role using BI Publisher web services. I am not able to find a any such method in BI Publisher web services.
ReplyDeleteOne more question I have, Is there any way(using web services) to have control over permissions on created folders in catalog of BI Publishers.
ReplyDeleteAnd If not then Is there any other way?
Halo ..
ReplyDeleteI'm using BIP 11.1.R5 and I need to burst schedule using local filesystem. I guess, there are different methods. Can you give code snippet, for example .there is no method set* on DeliveryOption.
I need to run a BI Publisher Report when ever there is an update in source DB tables...How can we acheive this thru BI Publisher scheduler? Do we need any Java API's to implement if 'Yes' then how. We need to kick of these Jobs using our Enterprise scheduler Control M.
ReplyDeleteWith the latest BIP 11.1.1.6 now you can use the new feature of Event based job to do this. Or, you can create a db trigger and call a web service of BIP scheduler web service.
ReplyDeleteHi Nishida,
DeleteI have few questions, while creating a schedule through web service :
1. Is it possible to set the frequency like Daily, weekly through web service same as we do have option in BI Publisher scheduling screen.
2. When we use scheduler web service to set the interval and
Yes, that should be possible.
ReplyDeleteHi Kan,
DeleteThanks for your reply.
Can you please tell which property of web service to use to set the frequency like - Daily, weekly etc. And also what values to pass in the property.
Hi Nishida,
ReplyDeleteI use BI Publisher 11.5 version and I want schedule my report with dynamycal data connection and send my pdf file for example.
I try using JDBC dynamic data connection with the schedule web service.
So, I use this code :
//JDBC Config
JDBCDataSource jdbc = new JDBCDataSource();
jdbc.setDataSourceName("sourcename");
jdbc.setJDBCDriverType("drivertype");
jdbc.setJDBCDriverClass("driverclass");
jdbc.setJDBCURL("url");
jdbc.setJDBCUserName("username");
jdbc.setJDBCPassword("pass");
//BIPDataSource Config
BIPDataSource bipds = new BIPDataSource();
bipds.setJDBCDataSource(jdbc);
and on report request :
repRequest.setDynamicDataSource(bipds);
and after :
sreq.setReportRequest(repRequest);
and finish with :
String job_id ="";
job_id = myPort.scheduleReport(sreq, username, password);
System.out.println(job_id);
When I use this code I have no errors and the pdf file was send by e-mail. But the JDBC connection not works.
For example if I put a wrong password or a wrong url I've not error.
If I do the same with publicReportService web service I've got error "wrong parameter".
The JDBC code works with PublicReportWebservice, but in Publisher 11.5 it's not possible schedule report because I have not deliveryChannel or deliveryRequest method in the scheduleRequest class (It's normal ???).
It's a bug ?? why in publicReportService the JDBC dynamical connection works and why not in Schedule webservice ??
I can't schedule my report with dynamic data connection ?