Accessing BI Publisher 11g Web Services through a JDeveloper Web Service Proxy

In the second part of this series looking at Web Services in BI Publisher 11g, I will look at using JDeveloper to create a Web Service Proxy. This exposes the BI Publisher Web Services in Java, from where they can be embedded in numerous other applications.

I demonstrated in part one how simple it is to invoke a Web Service, such as running an existing report in BI Publisher and writing the output as PDF to file. Now we will take a look at extending this to something that can actually be used in real applications. JDeveloper is Oracle's development platform for Java applications, and it includes functionality to dynamically generate java code for accessing Web Services. It calls this a Web Service Proxy, for obvious reasons since it is generating a proxy for the Web Service proper as a set of java methods and data types.

By utilising a Web Service Proxy, calls can be made out to the BI Publisher Web Services from any java code. Think of the possibilities! Whether you just want to touch BI Publisher briefly to schedule a report, or integrate a lot more closely, perhaps putting together report components on the fly, all of this is possible from java code.

Versions

Before we start on the worked example, a very important note about versions. Pay attention to this and you will save yourself the loss of hair and hours that I suffered!

If you are running OBIEE 11.1.1.5, then you must use JDeveloper 11.1.1.5. You cannot use JDeveloper 11.1.2!

If you try to use JDeveloper 11.1.2.1.0 you will most likely see the following:

  • Using a JAX-WS style proxy, the generate fails with an error:
    java.lang.IllegalArgumentException: Not a valid simple name: 'v2/ScheduleServiceClient'
  • Using a JAX-RPC style proxy, your Java code will be generated full of these errors:
    Unreported Exception

Create a Web Service Proxy in JDeveloper, step by step

The following steps walk you through creating a Web Service Proxy in JDeveloper for the ReportService BI Publisher Web Service. It then uses the proxy to invoke the runReport method that we prototyped in part one to run a report and write the output to PDF.
  1. Run JDeveloper 11.1.1.5, and create a new Generic Application. In the new project, insert a Web Service Proxy (under Business Tier -> Web Services)
    1. Select a JAX-WS Client Style
    2. Use the same WSDL URL as you prototyped in soapUI, for example,
      http://localhost:7001/xmlpserver/services/v2/ReportService?wsdl
    3. Click Finish (you don't need to specify anything in the rest of the Wizard)

  2. You should get a successful creation of your proxy. Remember, it is just a java program, that has been generated to wire into the specified Web Service, but is still just java code.  

      If not open already, open up V2ReportServiceClient.java and locate the line which says "Add your code to call the desired methods". So now, you can add your code to call the desired methods :-)
    
        public static void main(String[] args) {
            reportService_Service = new ReportService_Service();
            ReportService reportService =
                reportService_Service.getV2ReportService();
            // Add your code to call the desired methods.
    
        // Set up the credentials for our service call
        String username = "weblogic";
        String password = "Admin123";
        
        // Instantiate a new ReportRequest object
        ReportRequest repReq = new ReportRequest();
        
        // Define the report that we want to run
        repReq.setReportAbsolutePath("/6. Published Reporting/Sales/North America Sales.xdo"); // This is the Report name, as an absolute path.
        
        // Define what we want to do with it
        repReq.setAttributeFormat("pdf"); // defaults to HTML
        repReq.setReportOutputPath("/tmp/jdev_ws.pdf"); // The path on the **BIP server** to which the report should be saved
        
        // Let's go!
        try {
            reportService.runReport(repReq, username, password);
        } catch (InvalidParametersException_Exception e) {
            System.out.println("Exception thrown: InvalidParameters!");
        } catch (AccessDeniedException_Exception e) {
            System.out.println("Exception thrown: AccessDenied!");
        } catch (OperationFailedException_Exception e) {
            System.out.println("Exception thrown: OperationFailed!");
        }
        // All done
        System.out.println("Success!");
    }
    

  3. Run it, and you should get "Success!" in the JDeveloper message window

    And there should be a PDF file in the path specified:

So there you have it -- easy access of BI Publisher 11g Web Services from Java, using the JDeveloper Web Service Proxy functionality

NB: The above java code is heavily based on Venkat's original code here.

BI Publisher Web Services and BPEL

The third part of this series will demonstrate incorporating a call to a BI Publisher Web Service in a SOA / BPEL process. Click here to read it.

Subscribe to Rittman Mead

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!

Subscribe to Our
Monthly Newsletter!

* indicates required