Building an UWS SDK Portal


Now that you know how about using the web services SDK, you can now build BI portals using it. As with the samples provided for deploying the Business Objects Enterprise SDK, you can download a white-box starter portal using the web services SDKs at www.usingcrystal.com. Table 32.4 shows several of the files you will find.

Table 32.4. White-box UWS SDK Portal JSP Pages

JSP Page

Description

_check_authentication_uws.jsp

Checks authentication and redirects to logon page on failure.

_footer.jsp

Generic footer.

_header.jsp

Generic footer.

directory.jsp

Allows users to browse and drill through BOE folders, and view the reports contained therein.

getImage.jsp

Image call-back handler.

logon.jsp

Logon page.

logout.jsp

Logoff page.

view.jsp

For viewing a Crystal Report or WebIntelligence document. Drilling is supported for Crystal. String parameters are supported.


Portions of these pages are described in greater detail in the sections that follow.

Setting Up a Consumer SDK Project

Using the UWS Consumer SDKs in the Java environment requires the 1.4.2 version of the Java 2 SDK Standard Edition and a Java application server. Client jar and .NET assemblies can be found in the \Web Services\en\dsws_consumer\data directory of the installation directory. For J2EE clients, unzip the client JAR files from dswsJavaApi.zip into the WEB-INF\lib directory of your project. These files include dsws-bicatalog.jar, dsws-common.jar, dsws-reportengine.jar, dsws-session.jar, and wilog.jar. Additionally, the implementation requires these six jars that are part of the Apache Axis distribution: Axis.jar, commons-discovery.jar, Jaxrpc.jar, Saaj.jar, Wsdl4j.jar, and Jtools.jar. If you followed the previous build instructions, these files will be in the C:\Program Files\Business Objects\Assemble\dswsBobjeJava\src\WEB-INF\lib Directory. For rich Java clients, add these JAR files to your application's classpath. Note that these JARs are considerably smaller than those required to deploy the alternative CORBA-based SDK application.

Checking Authentication

As with the SDK portal shown in Chapter 30, "Using the BusinessObjects Enterprise APIs," every page (except for login.jsp) in the UWS portal includes a special JSP page, check_authentication_uws.jsp, that ensures that the user has logged in properly. This page can process for credentials posted from the login page or create a page-level pointer to an EnterpriseSession in application session scope. In the event that an EnterpriseSession does not exist or has timed-out, it sends a user to the login page.

Listing 32.2 contains login code from check_authentication_uws.jsp which shows how to create a new session from a username and password.

Listing 32.2. Creating a New UWS Session

URL boConURL = new URL(UWS_CONNECTION_URL); Connection boConnection = new Connection(boConURL); EnterpriseCredential boCredential = new EnterpriseCredential(); //fill in login information for both servers boCredential.setLogin(USERNAME); boCredential.setPassword(PASSWORD); //create a session object using the connnection boSession = new Session(boConnection); //log in to the server boSI = boSession.login(boCredential); //cache session session.setAttribute(UWS_SESSION, boSession); session.setAttribute(UWS_SESSION_INFO, boSI); session.setAttribute(UWS_USR_NAME,usr);

Listing 32.3 shows the login form itself, which is found in login.jsp. What is different about this login page versus the CORBA SDK code is that it does not reference a CMS name, but rather the UWS server endpoint URL. In this application, the actual URL is stored in the property file under the key UWS_CONNECTION_URL.

Listing 32.3. Simplified Logon Form

[View full width]

<form name='logonform' method='post' action='<%=returnToURL%>'>     <input type=hidden name="returnToURL" value="<%=returnToURL%>">     <input type=hidden name="logon_action" value="logon"> <table><tr><td class='normalText' valign='top'> User </td>     <td><input class='normalText' type='text' size='30' name='usr' value='<%=lastusr%>'></ td></tr>     <tr><td width='80' class='normalText' valign='top'> Password </td>     <td><input class='normalText' type='password' size='30' name='pwd' value=''></td></tr>     <tr><td width="80"  valign="top"></td> <td><input  type="button" value="Logon" onclick="javascript:logon();"></ td></tr></table>

Keeping sessions alive longer than necessary may tie-up licenses and server memory. Be sure to provide a logout page that includes logic to close the Business Objects session (see Listing 32.4) and optionally invalidate the appserver session.

Listing 32.4. Logging Off

Session objSession = (Session)session.getAttribute(UWS_SESSION); if (objSession!=null){     objSession.logout();     // first set the session state to alive } session.invalidate();

The default page is the UWS portal is directory.jsp. This page renders a permission-aware folder catalog. Reports can be viewed as HTML by clicking on their name and as PDF by clicking on the PDF icon. It renders a pseudo-breadcrumb at the top of the page. Portions of directory.jsp are shown in Listing 32.5.

Listing 32.5. Listing Folders and Reports

[View full width]

//get parent folder ID and name from the request scope String catid = (String)request.getParameter("catid"); String catName = (String)request.getParameter("catName"); if (catName==null) catName="Root"; //instantiate BI catalog BICatalog oBICatalog = BICatalog.getInstance(boSession, boSession.getAssociatedServicesURL ("BICatalog")[0]); //set sorting SortType[] oSort = new SortType[1]; oSort[0] = SortType.NAMEASC; //get all objects beneath root BICatalogObject[] catItems = oBICatalog.getCatalog(catid,0,oSort,null,null,null,  InstanceRetrievalType.ALL); //print pseudo bread-crumb if (!catName.equalsIgnoreCase("Root")) out.println("<A HREF='directory.jsp'> <B>Top</B></A>  > "); out.println("<b>"+catName+"</b><br>"); //write out folders and reports... for(int i=0;i<catItems.length;i++){    out.println("<br/>");    if (catItems[i] instanceof Document)    {         if (catItems[i].getObjectType().equalsIgnoreCase("CrystalReport")){              out.println("<IMG src='/books/2/423/1/html/2/../images/report.gif' WIDTH=16 HEIGHT=16 BORDER=0>");         } else {              out.println("<IMG src='/books/2/423/1/html/2/../images/webi.gif' WIDTH=16 HEIGHT=16 BORDER=0>");         }%>         <a href="view.jsp?docref=<%=URLEncoder.encode(catItems[i].getUID())%> &type=html">< %=catItems[i].getName()%></a> <a href= "view.jsp?docref=<%=URLEncoder.encode(catItems[i]. getUID())%> &type=pdf"><IMG src='/books/2/423/1/html/2/images/pdf.gif' WIDTH=16 HEIGHT=16 BORDER=0></A>         <%}else{%>           <IMG src="/books/2/423/1/html/2/images/folder.gif" WIDTH=16 HEIGHT=16 BORDER=0> <a href="directory. jsp?catid=<%=URLEncoder.encode(catItems[i]. getUID())%> &catName=<%=catItems[i].getName()% >"><%=catItems[i].getName()%></a>         <%}     } }

Finally, the UWS viewer page (viewer.jsp) is used to output a report as HTML or PDF and a second file (getImage.jsp) is used to render image call-backs. Drilling in CrystalReports and simple text prompts are supported. These listings are quite long and can be downloaded from usingcrystal.com.




Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net