Business Intelligence – Oracle

Archive for January 4th, 2008

Oracle BI Publisher 10.1.3.3.1 – Creating Applications using JDeveloper 11g and Web Service SOAP APIs

Posted by Venkatakrishnan J on January 4, 2008

I had some time today to see how easy it is to create a sample application that would basically call a BI Publisher web service and then run a report. Well if you had seen my previous blog entry on this here, i would have mentioned that i was not able to get the sample code provided in the documentation to work. Well, so far still i could not figure out the additional jars required. So we would be using a different approach here to test out these web services. Before going further, let me first list out the components and their versions that i would be using for this

1.    JDeveloper Tech Preview 3 – Yes this is a new year gift(though released by the end of December). JDev has never been any better. So many changes in UI and features and many more are coming in the 11g release.
2.    BI Publisher 10.1.3.3.1 (without the latest patchset).

Now, the first thing that we need to do for testing this to see whether we are able to access the WSDL of the BIP web services. To check this just open a browser and enter the below URL.

      http://localhost:9704/xmlpserver/services/PublicReportService?WSDL

      

Once this is done open up the JDev Tech Preview 3 Console and start with creating a new application (without any template). In my case the application and all the project names would be bipsoap.

      

Now create a new web service proxy. Here we would be entering all the details regarding the BIP WSDL.

      

Use JAX-RPC as the Web Service Client type and enter the WSDL URL that we used above. Do not make any changes to the port end points (every other step will be having the default values. No changes required).

      

Now this would automatically create a java file containing the relevant code. Now go to the main method of this java file and in the Try block enter the below piece of code

// @GeneratedBlockBegin (value={“oracle.j2ee.ws”} );
samplesoap.proxy.PublicReportServiceClient myPort = new samplesoap.proxy.PublicReportServiceClient();
// @GeneratedBlockEnd (value={“oracle.j2ee.ws”} );
String userName = “Administrator”;
String passWord = “Administrator”;

System.out.println(“calling ” + myPort.getEndpoint());
System.out.println(myPort.validateLogin(userName,passWord));

ReportRequest repReq = new ReportRequest();
ReportResponse repRes = new ReportResponse();

repReq.setAttributeFormat(“pdf”);
repReq.setAttributeLocale(“en-US”);
repReq.setAttributeTemplate(“World Sales”);
repReq.setReportAbsolutePath(“/Sales Manager/World Sales/World Sales.xdo”);

repRes = myPort.runReport(repReq,userName,passWord);
System.out.println(repRes.getReportContentType());

byte[] binaryBytes = repRes.getReportBytes();
OutputStream out = new FileOutputStream(“D:\\out.pdf”);
out.write(binaryBytes);
out.close();
System.out.println(“Success for Run Report”);

What this code does it runs the World Sales report (present under Sales Manager -> World Sales) and exports it into PDF format in the local D drive. Lets try to understand the code above.

   samplesoap.proxy.PublicReportServiceClient myPort = new samplesoap.proxy.PublicReportServiceClient();

The above instantiation opens up myPort which would your service handle. So, in JDeveloper if you type myPort. and press Ctrl+Space you can find all the methods that have been exposed in the BIP webservice.

      

Now compile this report and run it. If you get Success for Run Report in the output window, then go to your D drive. You would find out.pdf which would contain the report in a PDF format.

      

      

Very simple but again can be very useful when you are doing custom integration. You dont have to have any more of xdo related jar files in your code (Java APIs). All you need is the service handle!!!

Posted in All Posts, Bi Publisher | 25 Comments »