Saturday, March 12, 2011

Share and Deliver BI Publisher Reports in Multiple Languages

global flags

When you share your reports with someone who speak and read in different languages you want your reports to be shown in their language, right ? Well, translating reports with BI Publisher is not only easy but also reduces the maintenance cost a lot.

Many of us in the BI Publisher product development team used to work in Globalization and Multi Lingual support, which enables Oracle products and applications to be used in many different languages and countries and territories.  And we have a lot of experience in this area. In fact, being a strategic reporting platform for Oracle EBS, PeopleSoft, JD Edwards, Siebel, and many other Oracle application products, our customers from all over the world are generating thousands of thousands of reports, including out-of-the-box pre-developed reports from Oracle and customer created or customized reports, in their own local language everyday as they operate and manage their business.

Today, I’m going to talk about this very topic, how to translate my reports with BI Publisher 11G.

Translation Grows, not the Numbers of the Reports

Most of the reporting tools, regardless if it’s traditional or new, always take this translation on the back burner. They require their users to copy an original report and translate the whole thing. So when you want to support additional10 languages you will need to have 10 copies of the original. Imagine when you have 50 reports then you will end up having 500 reports (50 x 10) ! Now you need to maintain these 500 reports, whenever you need to make a change in a report you need to apply the same change to the other 10 reports. And as you imagine this is not only a nightmare for IT managements but not acceptable especially for the applications like Oracle EBS that supports over 30 languages.

So first thing we did was, very simple, we separated the translation out of the report and marry it to the report only at the report generation. This means, regardless of how many languages you need to support you need to have only one report and translation files for the 10 languages, which would contain the translated letters and words. So let’s say you have 50 reports and need to support 10 languages for those reports you still have only 50 reports and each report now has 10 language translation files. Yes, translation is the one should grow as you add more languages to support, not the report itself!

And second, we provide the translation files in XLIFF format, which is an international standard XML based format to exchange and maintain translation strings. So once you generate the XLIFF files for your reports with BI Publisher then you can work with any translation vendors in the world to make a mass translation or you can translate the XML files by yourself by manually updating the translatable strings presented in this text file.

Lastly, we made it easier to manage the translation process starting from generating the XLIFF files to uploading the translated XLIFF files back to the BI Publisher server. You can generate, download, upload the XLIFF files from the BI Publisher’s Web interface with your browser and you can see the translated reports right away without needing to shutdown or restart your server. While the translated reports are displayed based on your language preference setting you can also specify a different language when you schedule or deliver the reports so that they can be generated in your customer’s preferred language.

What Can I Translate?

When it comes to translation there are three things.

First, report content translation. When you receive a report you like to see the content like report title, section title, comments, annotation, table column header, and anything that are static and embedded in the report. in your preferred language. We call this Reports Content translation.

Second, when you open a report online you might want to see not only the report content being translated but also the report UI, such as report name, parameter name, layout name, and anything that would help you to navigate around the reports, to be translated in your language. We call this Reports UI translation. And this separation of the Reports Content and Reports UI translation makes it very useful especially when you want to navigate through the reports in your preferred language UI but want to generate the reports in your customer’s preferred language. Imagine you are English native speaker and need to generate and send a report to your customers in China. You like to see the report name, parameter name in English so that you can comfortably navigate to the report and generate the report output, but like to see the report generated in Chinese so that the your customers in China can understand the report when they receive it.

And lastly, you might want to see even the data presented in the report to be translated. For example, you might want to see product names in an Order Status report to be translated based on the report viewer’s language preference. We call this Reporting Data translation. Since this Reporting Data translation is maintained at the data source level such as Database tables along with the main data, you need to prepare the translation at the data source level first. Then, you want to make sure that your query is switched accordingly based on the language preference setting so that the translated data will be retrieved.

How to Translate BI Publisher Reports?

Now when it comes to ‘how to translate BI Publisher reports?’ the main focus here is about the translation for the Report Content and Report UI. And I just created this video to show you how to create and manage the translation with BI Publisher 11G. Please take a look at the clip below.

 

In today’s business world, customers and suppliers are from all over the world regardless of the size of the company or organization. Supporting multiple languages for your reports is no longer something ‘nice to have’, it’s mandatory. BI Publisher is designed to support multi lingual reports from the beginning without any extra hidden cost of license or configuration like other reporting tools such as Crystal Reports. You can support additional languages translation at any time with the very simple steps shown in the video above. Happy translation!

Please share your translation experience with us! 

Thursday, September 2, 2010

Oracle BI Publisher 11G Installation

Have you already installed BI Publisher 11G and started playing around ? Well, as much as I was excited about the release news when I came back from my big vacation, I had a bit of bumps on the road of installing until logging into the initial home page. First, I couldn’t proceed on the installer wizard steps more than step 4, then after having fixed the problem I still couldn’t start some BI services and then couldn’t open BI Publisher login window.

Well, finally figured out the root cause of the issue and its solution. Basically, that my PC environment was Windows XP on a VM (Parallel/Mac) and it’s running on DHCP. And the installer and some components (it’s BI Cluster Controller Server) don’t like it. So I needed to install a Loopback Adaptor and setup a static IP address, and then register that with machine name in Window’s etc/host file properly.

After that is done and cleared up the failed installation completely, the installation worked like a charm. It took about one hour or so and was so smooth that I don’t even remember what I was frustrated about! Anyway, hope your installation went smooth without hassle like the ones I had. But if it didn’t you might want to proceed reading and hope this helps you to get going.

Installation

In order to install BI Publisher 11G you need to get the BIEE 11G installation  package either from OTN or eDelivery. Then you create a repository in your database by using RCU (Repository Configuration Utility) before you start installing the BIEE 11G.  I’m not going to talk about the detail steps of the installation here, you can find many posts on other blogs out there or the installation guide about such detail steps with screenshots. The installation steps itself is pretty simple. However, if your network is not configured well then you will get in trouble big time. So make sure your network configuration before you start installing BI 11g.

Network Configuration

This is mandatory and really critical thing to do especially when you are trying to install onto your laptop or PC desktop with DHCP setting.

Basically there are three things to do before the installation in terms of the network setting.

  1. Make sure if you have installed MSFT loopback adapter.
  2. Set a static IP address to the loopback adapter network.
  3. Set the C:\WINDOWS\system32\drivers\etc\host file with a computer name and the static address you set to the loopback adapter.

All the detail can be found in this Oracle Database 11GR2 Installation guide. Click the link, it gets you directly to the network configuration section.

But one tricky thing is a domain name for your machine name such as ‘us.oracle.com’. If you are not sure about the domain name then don’t include it in the etc/host file. My example is below.

# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

127.0.0.1       .psf

10.10.10.10   knishida-vm1 

Make sure you reboot your machine once you have set the network configuration, then start the BI11g installation. Without this proper setting you will hit the following issues:

1. You can't proceed the installation steps after where you type username/password for weblogic user.
2. Your ClusteringControler or PSServer doesn't start
3. You can't login to Answers or any other BI apps
4. You can't even open BI Publisher login window
5. You can't open RPD online

I’ve already installed, Any workaround to fix it manually ?

If you have already installed BI11g and having the above issues you can workaround by setting up the etc/host file properly. If there is still a problem starting up the BI Clustering Controller Server then remove a domain name, which is 'us.oracle.com' in my case, from NQClusterConfig.INI located under C:\biee11\instances\instance1\config\OracleBIApplication\coreapplication (I installed the BI11g under C:\biee11.) if any. After removing all the domain name restart only the cluster control server manually from the Fusion Control (EM) then you should be able to start the cluster control server, and then you will be able to open BI Publisher page and login, or login to BI first then access to BI Publisher page. However, this workaround might be wiped out the next time you stop and start all the BI services. As you have realized by this time, regardless of whether you select ‘Simple Install’ or ‘Enterprise Install’ at the installation the BI Clustering Control Server gets installed. And you need that to access to the BI Server even if there is only one, and hence you need that to login to BI Publisher.

Need to Reinstall or Cleanup ?

So, while you can workaround the network issue as mentioned above I still strongly recommend that you review the network configuration and do a fresh install again. The issue like above can be work around temporally, but the workaround will be needed to perform every time you start the BI servers, which is not going to make you a happy camper.

When you do try another fresh installation then make sure you completely delete the original one by following the sequence mentioned in the installation guide. If you have something still left over from the previous installation you will get an error message during the installation. Here is a brief highlight of the steps in the order.

  1. Run the deinstall script and select the Deinstall instances managed by a WebLogic domain option.

  2. Stop all Oracle Business Intelligence processes and servers, including all OPMN-controlled components and JEE components.

  3. Drop the Metadata Services (MDS) and Business Intelligence Platform (BIPLATFORM) schemas using RCU.

  4. Run the deinstall script and select the Deinstall the Oracle home option.

  5. Deinstall the Oracle Common home manually or by running the deinstall script that it contains.

  6. Use the Oracle WebLogic Server uninstaller to uninstall WebLogic Server.

  7. Remove the Oracle home (if necessary).

  8. Remove the Middleware home and any other homes (Domain home, Applications home, and Instance home) that might have been installed outside of the Middleware home.

After following the steps documented in the installation guide to delete everything, make sure you don’t have any entry in the registry if you are installing onto Windows system. Especially the following stuff.

1. Remove all the registry entries that contains the Oracle - OHxxxxx. (e.g. HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\coreapplicatin_OH868503665)
2. If you have followed the steps mentioned above you shouldn’t see this. But if you still see this Oracle Common Home menu (‘Oracle – OHxxxxx’) from the Start –> Program File menu then remove it by going to ‘C:\Documents and Settings\All Users\Start Menu\Programs’ in the registry then delete such.
3. Even If you have followed the steps above you might still see the OPMN and Node manager windows services, you can do this by deleting these entries from registry, HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services

Share Your Experience!

Well, hope you have installed BI Publisher 11G successfully and start playing around and getting excited about the new features and products as I do now. But if you have found any issue and workaround during the installation and configuration please share!

Wednesday, September 1, 2010

Here Comes BI Publisher 11G!

It’s been long since the last post. I’ve been on vacation plus leave of absence and traveling around northern Europe with my bike ‘Surley’. It was the best trip in my life and maybe the best thing I’ve ever done. But now back to work, another thing I love!

Well, first thing I found when I came back is the news of BI EE 11G being released finally! This is the long waited and much needed release with a lot of innovative new features and products. It provides much winder solutions and functionalities and it is the most competitive product in today’s BI and Reporting market. It’s Complete, Integrated, and Open.

And sure enough it goes the same for BI Publisher too. This is the most anticipated and the most innovative release with a lot of new offereings. Let me go through briefly.

Data Model Editor

image

This is a new product targeted for the reports developers. Well, probably I don’t need to explain how this product improve your development productivity. Now you don’t need to see or edit the Data Template XML files anymore! You can build queries, create calculations and define the data structure all in the Data Model Editor Web UI. Along with this, now the data model you create is completely separate from reports. That means you can choose any existing data model when you create a report. This makes the report maintenance much easier and improve the data quality and governance.

Layout Editor

image image

This is another new product targeted for both Business Users and Reports Developers. This is a tool that you can use to create from a simple report to a management report to a pixel perfect report within the Web UI. You don’t need to install anything, not even need an add-ins or anything. The Web UI is similar to the MS Office 2007 , it’s very intuitive so the business users don’t need to have any special training. You can open the Layout Editor with your browser, select data columns you want to display, format and layout as if you use MS-Word, then boom, you get your report output the way you want and many different formats.

Interactive Viewer

 image

This is personally the most excited new product in this release for me. Finally BI Publisher brought your reporting experience complete and rich. You can not only generate the reports in a pixel perfect, but the same report allows you to interact with the data to get deeper insight. You can click any chart or pivot table within the report and all the data presented in the report automatically and instantaneously updated and filtered based on the Click! I’ve been working on many BI and Reporting projects where often the reports requirements contains both pixel perfect and interactivity nature. Until recent the users either needed to sacrifice some functionalities or requirements for a sake of selecting one reporting tool or needed to have two reports with two different reporting tools or components. This brought a tremendous frustration and maintenance headache on both the report users and developers. But not anymore. This is the complete reporting solution for both interactive reporting and product reporting, and for both the users and the developers.

Well, there are many other new enhancements like Enterprise Security and Scalability, Scheduler, UI, Reports editor, new diagnostic capability, etc. I will talk about them some time soon. So stay tuned!

Friday, May 7, 2010

Date Formatting and Handling for Siebel Reporting

I have discussed about the Siebel Date related issue before at one of the posts. The issue is that the IO returns the date data in a different format from the one BI Publisher expects (Canonical format), which prevents BI Publisher from formatting the date or handling the date data with its functions.

There are some workarounds available I discussed about at the post. But not anymore! Siebel Reporting product development team at Oracle has addressed the issue so you don’t need the workaround anymore!

IO Returns Date in Canonical Format with 8.1.1.2 !

UPDATE: Actually, this functionality didn’t make it to the production. It’s planned, but I don’t know when or which release will have the fix. I will update once I get the update. Meanwhile you can use the following ‘getCanonicalDate’ function.

First, with the latest FixPack 8.1.1.2, which was released recently, the IO now returns the date in the canonical date format. So you can use BI Publisher’s date related function or formatting with the data without any workaround.

New Function - getCanonicalDate

Second, if you can’t apply the FixPack 8.1.1.2 then you can download an updated XSLFunction.jar file from Oracle Support page (ID 764191.1) and replace the original with this new one. This new library includes a function called, ‘getCanonicalDate’, and this is the one you can use to convert the Siebel date string to the canonical date format.

Here is an example of how you can use the ‘getCanonicalDate’ function.

<?namespace:psfn=http://www.oracle.com/XSL/Transform/java/com.siebel.xmlpublisher.reports.XSLFunctions?>

xdoxslt:date_diff('d', psfn:getCanonicalDate(CreatedDate), psfn:getCanonicalDate(LastUpdatedDate), $_XDOLOCALE, $_XDOTIMEZONE)

As you see in the example, make sure you declare the ‘psfn’ namespace first before you use the ‘getCanonicalDate’ function. You can take a look at ‘Siebel’s Extended Function for RTF Template’ if you don’t know how to enable your Word Add-ins Template Builder to test with the library.

And of course, you need to replace the existing one with this new library at the server side to take this in effect when you run the report. You need to do this at the two places, one is at BI Publisher server, and another is at Siebel home.

BI Publisher Server

Take a look at the bookshelf, ‘Copying Siebel JAR files to BI Publisher’, which describes the detail.

Siebel Home

Replace %SIEBEL_HOME%/classes/XSLFunctions.jar with the downloaded one.

Tuesday, April 20, 2010

How to Schedule a Report with BI Publisher Web Service?

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:

  1. Create DeliveryRequest object
  2. Create ReportRequest object
  3. Create ScheduleRequest object
  4. 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.

  • Email
  • 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.

image

Example:

//Create a Delivery Option for Email delivery
EMailDeliveryOption em = new EMailDeliveryOption();

//Set Email delivery related information
em.setEmailTo("kanichiro.nishida@oracle.com");
em.setEmailSubject("This is a BIP Web Service Test...");
em.setEmailFrom("bip_admin@oracle.com");
em.setEmailCC("kanaugust@gmail.com");
em.setEmailBody("Test");

 

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:


DeliveryRequest dr = new DeliveryRequest();
dr.setEmailOption(em);

 

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:


ScheduleRequest sreq = new ScheduleRequest();

//Set DeliveryRequest
sreq.setDeliveryRequest(dr);

//Set ReportRequest
sreq.setReportRequest(req);

//Set scheduling information
sreq.setNotificationTo("kanichiro.nishida@oracle.com");
sreq.setSaveDataOption(true);
sreq.setSaveOutputOption(true);
sreq.setScheduleBurstringOption(false);
sreq.setSchedulePublicOption(true);
sreq.setUserJobName("WebService Job1");

 

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 com.oracle.xmlns.oxp.service.publicreportservice.AccessDeniedException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.DeliveryRequest;
import com.oracle.xmlns.oxp.service.publicreportservice.EMailDeliveryOption;
import com.oracle.xmlns.oxp.service.publicreportservice.InvalidParametersException;
import com.oracle.xmlns.oxp.service.publicreportservice.InvalidParametersException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.LocalDeliveryOption;
import com.oracle.xmlns.oxp.service.publicreportservice.OperationFailedException;
import com.oracle.xmlns.oxp.service.publicreportservice.OperationFailedException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportService;
import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportServiceClient;
import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportServiceService;
import com.oracle.xmlns.oxp.service.publicreportservice.ReportRequest;
import com.oracle.xmlns.oxp.service.publicreportservice.ReportResponse;
import com.oracle.xmlns.oxp.service.publicreportservice.ScheduleRequest;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

public class BipServletTest extends HttpServlet {
    private static final String CONTENT_TYPE =
        "text/html; charset=windows-1252";
    private static PublicReportServiceService publicReportServiceService;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
                                                           IOException {
        response.setContentType(CONTENT_TYPE);
        OutputStream os = response.getOutputStream();
        //PrintWriter out = response.getWriter();
        String sid = "";
        publicReportServiceService = new PublicReportServiceService(new URL("http://knishida-lap.us.oracle.com:7001/xmlpserver/services/PublicReportService"),
                                               new QName("http://xmlns.oracle.com/oxp/service/PublicReportService",
                                                         "PublicReportServiceService"));
        PublicReportService publicReportService =
            publicReportServiceService.getPublicReportService();

        //To get a session id
       try {
            sid = this.getSessionID("Administrator", "Administrator", publicReportService);
        } catch (AccessDeniedException_Exception e) {
            System.out.println("invalid user"); 
        }

       String job_id = this.scheduleReportInSession(publicReportService, sid);

        try {
            publicReportService.logout(sid);
        } catch (InvalidParametersException_Exception e) {
            System.out.println(e);
        } catch (AccessDeniedException_Exception e) {
            System.out.println(e);
        }
    }

public String getSessionID(String username, String password, PublicReportService publicReportService) throws AccessDeniedException_Exception {
    String sid = publicReportService.login(username, password);
    return sid;
}

public String scheduleReportInSession(PublicReportService publicReportService,
                                    String sid){
    // Set Report request attributes
    ReportRequest req = new ReportRequest();
    req.setAttributeFormat("pdf");
    req.setAttributeLocale("en-US");
    req.setAttributeTemplate("Simple");
    req.setReportAbsolutePath("/HR Manager/Employee Salary Report/Employee Salary Report.xdo");

    EMailDeliveryOption em = new EMailDeliveryOption();
    em.setEmailTo("kanichiro.nishida@oracle.com");
    em.setEmailSubject("This is a BIP Web Service Test...");
    em.setEmailFrom("bip_admin@oracle.com");
    em.setEmailCC("kanaugust@gmail.com");
    em.setEmailBody("Test");
    DeliveryRequest dr = new DeliveryRequest();
    dr.setEmailOption(em);
    ScheduleRequest sreq = new ScheduleRequest();
    //Set DeliveryRequest
    sreq.setDeliveryRequest(dr);
    //Set ReportRequest
    sreq.setReportRequest(req);
    sreq.setNotificationTo(kanichiro.nishida@oracle.com);
    sreq.setSaveDataOption(true);
    sreq.setSaveOutputOption(true);
    sreq.setScheduleBurstringOption(false);
    sreq.setSchedulePublicOption(true);
    sreq.setUserJobName("WebService Job1");

    String job_id ="";
    try {
        job_id = publicReportService.scheduleReportInSession(sreq, sid);
        System.out.println(job_id);
    } catch (InvalidParametersException_Exception ie) {
        System.out.println(ie);
    } catch (AccessDeniedException_Exception ae) {
        System.out.println(ae);
    } catch (OperationFailedException_Exception oe) {
        System.out.println(oe);
    } 
    return job_id;
}

}

Monday, April 19, 2010

How to Run a Report with BI Publisher Web Service?

This is a follow up post from the last post ‘How to use BI Publisher Web Service with JDeveloper 11G’. Today, I want to talk about how to run a BI Publisher report with the Web Service within a Java Servlet. This post is assuming that you have already generated Java Web Service Proxy with JDeveloper, which creates a set of Java classes/methods that are required to call BI Publisher Web Service APIs. If you haven’t please take a look at ‘How to use BI Publisher Web Service with JDeveloper 11G’ first.

Which Method to run Report?

You can use a runReport() or runReportInSession() method to have BI Publisher Enterprise server to run a report and get the report output. The report output will be returned in binary format so you need to take care of handling the binary format appropriately in order to display or locate the report output.

Here are the definitions of runReport() and runReportInSession().

  • ReportResponse runReport(Request request, String username, String password);
  • ReportResponse runReport(Request request, String sessionToken);

While with runReport() method you need to always pass username and password, with runReportInSession() you can just pass a session token after you get with login() method. (See ‘How to use BI Publisher Web Service with JDeveloper 11G’ for the detail of the login() method.)

I’m going to use the runReportInSession() for my example below.

How to Call runReportInSession()?

First of all you need to create a ReportRequest object, with which you can set a report that you want to run. You can also set a report layout template name, report output format type such as ‘pdf, ‘html’, etc, and locale (language and territory) information. Once the ReportRequest is set then you can pass it to the runReportInSession() method along with the session token. The runReportInSession() willl return a ReportResponse object, which contains the report output in a binary format along with the report meta-data information such as content type, language information.

Here is a visualized process flow of the runReport() method.

image

 

So basically there are three steps.

  1. Create ReportRequest object
  2. Call runReportInSession() method
  3. Get a report from ReportResponse object

Create ReportRequest Object

You can set the following information when you create the ReportRequest object

  • Absolute Path to the Report
  • Report output format
  • Locale (Language and Country/Territory)
  • Template name

Function

Method

Description

Output format

void setAttributeFormat()

You can set a desired report output format such as ‘pdf’, ‘rtf’, ‘excel’, etc.

Locale

void setAttributeLocale()

You can set a user’s preferred report locale such as ‘en-US’ for English/America, ‘fr-FR’ for French/France. Based on this setting BI Publisher Enterprise will decide which language translation to use for the specified template if available.

Template Names

void setAttributeTemplate()

You can set a desired template among available templates that are registered for the specified report.

Absolute Path to the Report

void setReportAbsolutePath()

You can set an absolute path for the report that you want to run.

Example:

ReportRequest req = new ReportRequest(); //Instantiate ReportRequest object

req.setAttributeFormat("pdf"); //Set a report output format
req.setAttributeLocale("en-US"); //Set a report locale
req.setAttributeTemplate("Simple"); //Set a layout template name
req.setReportAbsolutePath("/HR Manager/Employee Salary Report/Employee Salary Report.xdo"); //Set a report path

 

Call runReportInSession()

You can call the runReportInSession() method through the publicReportService Java Web proxy client object. It returns a ReportResponse object.

Example:

ReportResponse res = new ReportResponse(); //Instantiate ReportResponse object

res = publicReportService.runReportInSession(req, sid);

 

Get a Reprot from ReportResponse Object

Here is a list of the methods that you can use to retrieve information from the ReportResponse object. And the most you care would be the getReprotBytes(), which returns a report output in a binary format.

Function

Method

Description

Report Content

byte[] getReportBytes()

You can get the report content itself. It returns the report in a form of binary so you need to take care of a proper encoding to retrieve the data and handle it appropriately.

Report Content Type

String getReportContentType()

You can get the report’s content type. For example if the report output is generated in a PDF format then it will return ‘application/pdf’.

Report Locale

String getReportLocale()

You can get a locale information of the generated report.

Example:

response.setContentType(res.getReportContentType()); // Set content type to HttpServletResponse

byte[] binaryBytes = res.getReportBytes(); // Get report content from ReportResponse

Troubleshoot

You might not get any report content from the ReportResponse object. If that’s the case you want to add the following code to set a data chunk size to ‘-1’. I had to set this before in order to get the report output successfully, but now it’s working fine without the setting with my latest BI Publisher Server environment. (March ‘10 patchset).

ReportRequest req = new ReportRequest(); //Instantiate ReportRequest object

req. setSizeOfDataChunkDownload (-1); //download all

Conclusion

Now you know how to call BI Publisher Web Service to run a report. My example is trying to get the report output and display it in a browser, but of course you can display it as part of your application UI or locate it on a file system.

Here is my whole source code. Again, I’m using a Java Servlet to exercise my code with BI Publisher Web Service.

package project1;

import com.oracle.xmlns.oxp.service.publicreportservice.AccessDeniedException;
import com.oracle.xmlns.oxp.service.publicreportservice.AccessDeniedException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.DeliveryRequest;
import com.oracle.xmlns.oxp.service.publicreportservice.InvalidParametersException;
import com.oracle.xmlns.oxp.service.publicreportservice.InvalidParametersException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.LocalDeliveryOption;
import com.oracle.xmlns.oxp.service.publicreportservice.OperationFailedException;
import com.oracle.xmlns.oxp.service.publicreportservice.OperationFailedException_Exception;
import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportService;
import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportServiceClient;

import com.oracle.xmlns.oxp.service.publicreportservice.PublicReportServiceService;
import com.oracle.xmlns.oxp.service.publicreportservice.ReportRequest;

import com.oracle.xmlns.oxp.service.publicreportservice.ReportResponse;

import com.oracle.xmlns.oxp.service.publicreportservice.ScheduleRequest;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.net.URL;

import javax.servlet.*;
import javax.servlet.http.*;

import javax.xml.namespace.QName;

public class BipServletTest extends HttpServlet {
    private static final String CONTENT_TYPE =
        "text/html; charset=windows-1252";
    private static PublicReportServiceService publicReportServiceService;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
                                                           IOException {
        response.setContentType(CONTENT_TYPE);
        OutputStream os = response.getOutputStream();
        //PrintWriter out = response.getWriter();
        String sid = "";
        publicReportServiceService = new PublicReportServiceService(new URL("http://knishida-lap.us.oracle.com:7001/xmlpserver/services/PublicReportService"),
                                               new QName("http://xmlns.oracle.com/oxp/service/PublicReportService",
                                                         "PublicReportServiceService"));
        PublicReportService publicReportService =
            publicReportServiceService.getPublicReportService();
        //To get a session id
       try {
            sid = this.getSessionID("Administrator", "Administrator", publicReportService);
        } catch (AccessDeniedException_Exception e) {
            System.out.println("invalid user");

        }
        //To generate a report and display it
        ReportResponse res = this.getReportInSession(publicReportService, sid);
        byte[] binaryBytes = res.getReportBytes();
        os.write(binaryBytes);
        response.setContentType(res.getReportContentType());
    }

    public String getSessionID(String username, String password, PublicReportService publicReportService) throws AccessDeniedException_Exception {
        String sid = publicReportService.login(username, password);
        return sid;
    }

    public ReportResponse getReportInSession(PublicReportService publicReportService,
                                             String sid) {

        ReportRequest req = new ReportRequest();
        ReportResponse res = new ReportResponse();

        req.setAttributeFormat("pdf");
        req.setAttributeLocale("en-US");
        req.setAttributeTemplate("Simple");
        req.setReportAbsolutePath("/HR Manager/Employee Salary Report/Employee Salary Report.xdo");
        //req. setSizeOfDataChunkDownload (-1); //download all

        try {
            res = publicReportService.runReportInSession(req, sid);
            System.out.println(res.getReportContentType());           

        } catch (Exception e) {
            {
                System.out.println(e);
            }
        }

        return res;
    } 

}

I’ll talk about how to schedule a BI Publisher report with the Web Service tomorrow, so stay tuned!

Friday, April 16, 2010

How to use BI Publisher Web Service with JDeveloper 11G?

How can I call BI Publisher Web Service from my Java application with JDeveloper?

BI Publisher provides a set of Web Service APIs, with which you can do pretty much everything you can do from the UI such as running reports, scheduling reports, creating/editing/deleting reports, etc. With JDeveloper you can easily integrate the BI Publisher Web Service with your Java application and start developing your code.

I wrote a ‘BI Publisher Web Service development guide for Java developers with JDeveloper’ paper quite a while ago, but never talked about this topic on this blog. And there have been some changes since then. Now JDeveloper is 11G and BI Publisher has added more APIs and fixed some issues we had before.

So I’ll spend the next couple of posts talking about this topic, hope it will be useful for Java Developers out there who want to integrate with BI Publisher to run and manage BI Publisher reports within your application.

Environment

Here is my environment information:

  • BI Publisher 10.1.3.4.1 with March Patch Set (9546699)
  • JDeveloper 11.1.1.2
  • WebLogic Server 11G (10.3.2)

Get BI Publisher WSDL File

First, you need to get a WSDL file first before start anything. You can obtain your BI Publisher Server’s WSDL file by submitting the following URL from your browser.

http://hostname:port/xmlpserver/services/PublicReportService?WSDL

Note: Somehow I couldn’t get this with my BI Publisher running on a OC4J. I don’t know why but keep getting an error message. Looks many people are just fine or it worked fine after upgraded or something. Since I didn’t have enough time to keep debugging I’ve just simply moved to my another BI Publisher Server running on WebLogic 11g Server, which is working perfect, thanks god!

Once you get the WSDL file then save it to your local system.

Create a Web Service Proxy

Now, in order to integrate with Web Service within Java application you need to create a Web Service Proxy. There is a UI wizard to generate this with JDeveloper. In the New Gallery (right click on Project and ‘New’), select Web Server Proxy under Business Tier/Web Services and follow the steps with the default options until finish. When you are asked to provide a WSDL then use the WSDL you just saved at above.

image

In my example I have chosen ‘JAX-WS Style’ as Client Style.

image

Once you click the ‘Finish’ button it automatically generates all the required Java classes to provide you a set of Java APIs each of which corresponds with each Web Service API. Also it generates the Proxy class called ‘PublicReportServiceService’ like the below.

public class PublicReportServiceClient
{
  @WebServiceRef
  private static PublicReportServiceService publicReportServiceService;

  public static void main(String [] args) {
    publicReportServiceService = new PublicReportServiceService();
    PublicReportService publicReportService = publicReportServiceService.getPublicReportService();
    // Add your code to call the desired methods.
  }
}

Now you can start writing your own code with the BI Publisher Web Service corresponding Java methods after the ‘Add your code to call….’ line.

Call BI Publisher Web Service

First, I’m going to use a simple API called ‘login(String username, String password)’ to test if the web service integration works. This API accepts two parameters, one is username and another is password. It passes those two values to the BI Publisher Server and returns a session token if the combination of the username and password is valid. You can use this session token later for any following actions such as running a report, scheduling a report, etc, without needing to be authenticated at every communication with the Server.

Anyway, so this ‘login()’ API is one of the BI Publisher Web Service APIs and I can call it through the Web Server Proxy. In the example below ‘publicReportService’ is the proxy, once this is instantiated then I can call it through the proxy ‘publicReportService’.

With the below example, I’m setting ‘Administrator’ for the username and ‘Administrator’ for the password, and trying to print the returned session token in the standard out.

public class PublicReportServiceClient
{
  @WebServiceRef
  private static PublicReportServiceService publicReportServiceService;

  public static void main(String [] args) throws AccessDeniedException_Exception,
                                                  MalformedURLException {
    publicReportServiceService = new PublicReportServiceService();

    PublicReportService publicReportService = publicReportServiceService.getPublicReportService();

    String sessionid = publicReportService.login("Administrator", "Administrator");
    System.out.println(sessionid);    
  }
}

When I run this program I get a session token like ‘6691223D7D070473ABA31D91AAB89’, which means the login was successful and I can use this token later when I call other BI Publisher Web Service APIs.

How to Change Endpoint?

Now, as long as I’m developing and testing in this instance I would be fine. But what if I need to migrate my code to a QA or Production and I need to run the BI Publisher calls against a different BI Publisher Server?

When you create the Web Server Proxy with JDeveloper it generates it with a default endpoint URL setting, which is retrieved from the WSDL file. That means, every time I run the BI Publisher Web Service it goes against a BI Publisher server with the endpoint URL. So I want to dynamically change the endpoint URL address instead of hard-coding it somewhere.

With 10G JDeveloper it generated an API that I can use to set the endpoint URL address. But with 11G JDeveloper I need to do that in a slight different way, which is to set that as part of the proxy construction. With my example, I can set that when I initiate ‘publicReportServiceService’. I need to provide a URL, which is the endpoint, and a QName, which consists of namespace and localname. My example, those are something like following.

  • Endpoint URL: http://knishida-lap.us.oracle.com:7001/xmlpserver/services/PublicReportService
  • Namespace: http://xmlns.oracle.com/oxp/service/PublicReportService
  • Localname: PublicReportServiceService

You can find these information from your BI Publisher Server WSDL file, or you just need to change the hostname and port number of the example above. And you can set those values something like below.

Before:

publicReportServiceService = new PublicReportServiceService();

After:

//publicReportServiceService = new PublicReportServiceService();
publicReportServiceService = new PublicReportServiceService(new URL("http://knishida-lap.us.oracle.com:7001/xmlpserver/services/PublicReportService"), new QName("http://xmlns.oracle.com/oxp/service/PublicReportService", "PublicReportServiceService"));

Now you have a control of which BI Publisher Server instance you want to communicate with the Web Service calls. Great!

Test with Java Servlet

With the above example I was testing with a Java application. But for the next couple of posts I want to use a Java Servlet to demonstrate other APIs. In case you are not familiar with Java Servlet, don’t worry, you can create it with JDeveloper pretty easily. Just select ‘HTTP Servlet’ under ‘Web Tier/Servlet’ in the ‘New Gallery’ menu and follow the wizard steps.

image

Now I created a Java Servlet to test called ‘BipServletTest’ under the same project. I’m going to use this Servlet to go over the next couple of posts to introduce other BI Publisher Web Service APIs such as runReport, scheduleReport, etc, so stay tuned!