Skip Headers
Oracle® Fusion Middleware User's Guide for Oracle Business Intelligence Discoverer Web Services API
11g Release 1 (11.1.1)
E10412-02
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

1 Introducing the Discoverer Web Services API

This chapter introduces the Discoverer Web Services API and describes how to use the API. It contains the following topics:

1.1 What is the Simple Object Access Protocol?

SOAP (Simple Object Access Protocol) is a World Wide Web Consortium (W3C) recommendation for an XML protocol for exchanging information on the Web.

1.2 What are the Oracle BI Discoverer Web Services?

The Oracle BI Discoverer Web Services are part of an Application Programming Interface (API) that enables a client to do the following:

1.3 What is the SOAP endpoint URL for Discoverer Web Services?

The SOAP endpoint URL for Discoverer Web Services is http(s)://<host>:<port>/discoverer/wsi.

1.4 What is the WSDL format?

The WSDL (Web Services Definition Language) format is an industry standard that formally defines services and methods, and is used to define Discoverer Web Service APIs. Proxy classes for the services can be generated automatically.

Notes

1.5 About authentication and authorization

The Discoverer Web Services are accessible only by trusted users. You must obtain the trusted user name and password set up by the Discoverer middle-tier administrator, to use these credentials in your code.

For a code example that includes user credentials, see Example 1-4, "Set credentials to access the protected web service".

For information about how to create trusted users, see Defining a trusted user to access Discoverer Web Services.

1.6 What modes of connecting to Discoverer are supported?

The Discoverer Web Services support Oracle Single Sign-On , Oracle Applications Single Sign-On, and public connections in the current release.

1.7 About maintaining Discoverer Web Service sessions

The Discoverer Web Services are stateful in nature. In other words, every instance of the web service client stub needs to have a single HTTP session with the Discoverer Web Service. This HTTP session can be used for all web service operations, for all client application users. For every user, the client application needs to call the login method, to inform the Discoverer Web Service about a new user session. Every user session is associated with a dedicated Discoverer session on the server side which is either created or reused from the Discoverer session pool. The associated Discoverer session is used in all interactions with the user. The client application must ensure that it calls the logout method after completing all operations for the user.

The HTTP session established between the web service client and the server is tracked by cookies and is managed by the web service.

1.8 About managing the Discoverer session pool size

It is useful to know the Discoverer session pool size, because every login() call and subsequent data fetching operation requires a Discoverer session, and every logout() call releases the session.

The maximum session pool size value can be configured (in configuration.xml) using Oracle Fusion Middleware Control. The Discoverer session clean-up operation runs periodically removing any stale or inactive DiscovererSession objects from the pool.

The SSOusername, Connectionkey, Workbook, Worksheet, and Locale methods are all used to determine which Discoverer sessions to pick up, to optimize allocation of Discoverer sessions for new login requests.

1.9 What are the availability requirements?

The Discoverer Web Services can be distributed across a cluster and have no dependency on a single point of failure. Transparent failover is not supported; therefore in the event of a failure, each client must authenticate again to create new user sessions.

1.10 About error messages

A web service API call can result in an exception that must be handled by the client. Error messages are displayed using the locale that was selected during login.

1.11 How do you diagnose problems?

You can diagnose problems from log files and from web service exceptions. You can view log entries using Oracle Fusion Middleware Control. For more information, see Oracle Fusion Middleware Configuration Guide for Oracle Business Intelligence Discoverer.

1.12 What is required to invoke the Discoverer Web Services?

To invoke the Discoverer Web Services you must comply with the following:

1.12.1 Defining a trusted user to access Discoverer Web Services

Only trusted users can access Discoverer Web Services. You create trusted users by using the WebLogic Server Administration Console. For more information about creating users, see the "Create Users" topic in the WebLogic Administration Console Online Help.


Note:

By default, the Administrators group is assigned a scoped security role for the Discoverer application. To provide access to Discoverer Web Services, you can add the new user to the Administrators group.

For more information about adding users to groups, see "Add users to groups topic" in the WebLogic Administration Console Online Help.


For the new user to access Discoverer Web Services, you must assign the Discoverer scoped security role to the new user. For more information about adding users to security roles, see the "Add users to roles" topic in the WebLogic Administration Console Online Help.

1.12.2 Verifying access to the Discoverer Web Services

Before you create a Java class to invoke the Discoverer Web Services you must ensure that the Discoverer Web Services are installed and configured.

To verify that the Discoverer Web Services are installed and configured, you access the endpoint URL. If you cannot access the URL, contact the Discoverer manager.

Navigate to the link http://<host>:<port>/discoverer/wsi.

You should be prompted for the user/password created in the earlier steps.

Note: You can also use the user name and password of the 'weblogic' user that was entered during installation (for more information, see your middle tier administrator).

1.12.3 Setting values for Discoverer Web Services using Oracle Fusion Middleware Control

The maxSessions setting for Discoverer Web Services should be configured using Fusion Middleware Control. This setting specifies the maximum number of Discoverer sessions that can be active at the same time (the recommended value is 20)

For more information about configuring Discoverer Web Services using Fusion Middleware Control, see the Oracle Fusion Middleware Configuration Guide for Oracle Business Intelligence Discoverer.

1.12.4 Creating web service client stubs (web service proxy)

You can obtain a set of proxy/client files by generating them from a set of web service client libraries. Oracle Web Services provide libraries for this purpose. For more information, see Oracle Fusion Middleware Developer's Guide for Oracle Web Services.

To generate the Discoverer Web Service client from the Discoverer WSDL URL:

  1. Display a Web browser.

  2. Access the Discoverer WSDL URL: http://<host>:<port>/discoverer/wsi?wsdl

    For more information, see "What is the WSDL format?", and "Writing a client application to invoke web services using generated web service client stubs".

1.12.5 Setting the Session Maintain Property

You must set the value of the SESSION_MAINTAIN_PROPERTY in the web service library. The SESSION_MAINTAIN_PROPERTY specifies whether sessions are stateful, and because Discoverer Web Services sessions are stateful, this property must be set to True as follows:

Map requestContext = ((BindingProvider)proxy).getRequestContext();
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);

Note: Each supported web service library has an equivalent SESSION_MAINTAIN_PROPERTY for maintaining stateful sessions. For more information, see your web service documentation.

1.12.6 Writing a client application to invoke web services using generated web service client stubs

The following code examples provide an illustration of a basic client application:

Example 1-1 Define a Java class

class webserviceclient
{
    public static void main(String[] args)
    {
    }
}

Example 1-2 Instantiate the web service client stub

class webserviceclient
{
    @WebServiceRef
    private static Wsi_Service wsi_Service;
    public static void main(String[] args)
    {
      wsi_Service = new Wsi_Service();
      wsiProxy proxy = wsi_Service.getWsi();
    }
}

Example 1-3 Ensure the client maintains the session

This is needed as the Discoverer web service is stateful.

class webserviceclient
{
    @WebServiceRef
    private static Wsi_Service wsi_Service;
    public static void main(String[] args)
    {
      wsi_Service = new Wsi_Service();
      wsiProxy proxy = wsi_Service.getWsi();
      Map requestContext = ((BindingProvider)proxy).getRequestContext();
      requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
    }
}

Example 1-4 Set credentials to access the protected web service

class webserviceclient
{
    @WebServiceRef
    private static Wsi_Service wsi_Service;
    public static void main(String[] args)
    {
     wsi_Service = new Wsi_Service();
     wsiProxy proxy = wsi_Service.getWsi();
     Map requestContext = ((BindingProvider)proxy).getRequestContext();
     requestContext.put(BindingProvider.USERNAME_PROPERTY,"username");
     requestContext.put(BindingProvider.PASSWORD_PROPERTY,"password");
     requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
    }
}

Example 1-5 Set the web service endpoint

class webserviceclient{    @WebServiceRef    private static Wsi_Service wsi_Service;    public static void main(String[] args)
    {
     wsi_Service = new Wsi_Service();
     wsiProxy proxy = wsi_Service.getWsi();
     Map requestContext = ((BindingProvider)proxy).getRequestContext();
     requestContext.put(BindingProvider.USERNAME_PROPERTY,"username");
     requestContext.put(BindingProvider.PASSWORD_PROPERTY,"password");
     requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://host:port/discoverer/wsi");
     requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
    }}

Example 1-6 Perform any web service operations on the stub

class webserviceclient{    
     @WebServiceRef
     private static Wsi_Service wsi_Service;f
     public static void main(String[] args)
     {
      wsi_Service = new Wsi_Service();
      wsiProxy proxy = wsi_Service.getWsi();
      Map requestContext = ((BindingProvider)proxy).getRequestContext();
      requestContext.put(BindingProvider.USERNAME_PROPERTY,"username");
      requestContext.put(BindingProvider.PASSWORD_PROPERTY,"password");
      requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"http://host:port/discoverer/wsi");
      requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
 
      DisplayName displayname = new DisplayName();
      displayname.setUser("DISPLAYNAME");
      Identifier idfr = new Identifier() ;
      idfr.setId("IDENTIFIER");
 
      UserCredential uc = new UserCredential();
      uc.setDisplayName(displayname);
      uc.setIdentifier(idfr);
 
      LocaleBean locale = new LocaleBean();
      locale.setCountry("US");
      locale.setLanguage("en");
      locale.setVariant("");
 
      SessionKey sKey = proxy.login(uc, locale);
      proxy.logout(sKey);
    }}

Note: To compile the above client application, the web service libraries must be set in the classpath. When using the Oracle libraries, soap.jar, Http_client.jar and the downloaded proxy.jar must be present. For example, if you run the client application from the command prompt, you might set the Java classpath as follows:

set CLASSPATH=<absolute path of>/proxy.jar;<absolute path of>\soap.jar;<absolute path of>\Http_client.jar

Note: If you use an integrated development environment such as Oracle JDeveloper or Eclipse, then set the Java classpath using the user interface for that environment

1.13 What is a typical flow of events for accessing Discoverer Web Services API to return results?

The Discoverer Web Services API can be used by a client application to obtain XML data related to Discoverer connections and worksheets. A typical flow of events is suggested in the following flow (for more information, see "Typical flow of events: Detailed task examples"):

Typical flow of events

  1. "Provide the credentials to invoke Discoverer Web Services"

  2. "Use the identifier to invoke login()"

    This starts a user session and provides a valid session key.

  3. "Inspect the connection information by invoking getConnectionList()"

    This returns a list of connections for clients to use for display and selection.

  4. "Select a particular connection and invoke getFolderEntryList()"

    This returns a list of workbooks for user display and selection.

    In case of OLAP connections there can be folders along with workbooks.

  5. "Select a particular worksheet by invoking getWorksheetList()"

    This returns just a list of worksheets with empty parameter information.

  6. "Get the layout of the worksheet by invoking getLayoutMetadata()"

  7. "Select the parameter metadata for a worksheet by invoking getParameterMetadata()"

  8. "Select a worksheet parameter and obtain its LOVs by invoking getParameterValueList()"

    This returns the LOV data in chunks which is used by clients for user display and selection.

    Alternatively, you can select worksheet parameters in the cascading style by invoking the getCascadeParameterValueList(). For more information see "Select worksheet parameters and obtain LOVs in the cascading style by invoking getCascadeParameterValueList()".

    Note: If the worksheet does not contain parameters, then the client should not invoke getParameterValueList() or getCascadeParameterValueList().

  9. "Submit a worksheet query (including parameters) by invoking submitWorksheetQuery()"

    The client performs a submit, passing parameters if required.

    A queryKey is obtained when a worksheet query request is submitted.

  10. "Check the status of the query by invoking getQueryStatus()"

    This returns the current status of the query for user display and selection.

  11. "View worksheet data on completion of the query by invoking getWorksheetData()"

  12. "Log out, by invoking Logout()"

Note: Queries must be executed sequentially, so that when the client application performs a single login call for a user, it must ensure that the query submission for a worksheet is made only after the previous query submission has yielded results.

Note: For OLAP worksheets, the XML can contain aggregate totals. In that case, if the API client creates a total for an OLAP worksheet with Aggregate totals, it would yield wrong results.

1.14 Typical flow of events: Detailed task examples

The following flow of events shows some typical Java class entries for each task example.

1.14.1 Provide the credentials to invoke Discoverer Web Services

The following code must be executed before you can successfully perform a login() API call.

     wsi_Service = new Wsi_Service();
     Wsi proxy = wsi_Service.getWsi();
     Map requestContext = ((BindingProvider)proxy).getRequestContext();
     requestContext.put(BindingProvider.USERNAME_PROPERTY,"weblogic");
     requestContext.put(BindingProvider.PASSWORD_PROPERTY,"weblogic");
     requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,testEndpoint);
     requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);

1.14.2 Use the identifier to invoke login()

You must provide the user credentials to invoke the Discoverer Web Services before you can use the login() call. For more information, see "Provide the credentials to invoke Discoverer Web Services".

Note: The login() call must be invoked before invoking any other Discoverer Web Services.

      DisplayName displayname = new DisplayName();
      displayname.setUser("DISPLAYNAME");
      Identifier idfr = new Identifier() ;
      idfr.setId("IDENTIFIER");
 
      UserCredential uc = new UserCredential();
      uc.setDisplayName(displayname);
      uc.setIdentifier(idfr);
 
      LocaleBean locale = new LocaleBean();
      locale.setCountry("US");
      locale.setLanguage("en");
      locale.setVariant("");
 
      System.out.println("Invoke the login() WS API");
      SessionKey sKey = proxy.login(uc, locale);
      System.out.println("Session Key :"+sKey.getKey());

Note: To access SSO-based connections, you can provide the GUID and SSOUsername as the Identifier and DisplayName respectively.

1.14.3 Inspect the connection information by invoking getConnectionList()

Once logged in, the user can invoke the getConnectionList() API to obtain a list of available connections as shown below:

   System.out.println("Invoke the getConnectionList() API");
   ConnectionList cl = proxy.getConnectionList(sKey);
   List conns = cl.getConnections();
   System.out.println("Discoverer connections:");
   for(int i=0; i<conns.size(); i++)
   {
    System.out.println("Name:"+conns.get(i).getConnectionName().getName());
    System.out.println(" Key:"+ conns.get(i).getConnectionKey().getKey());
    System.out.println(" Desc:"+ conns.get(i).getConnectionDesc().getDesc());
   }

1.14.4 Select a particular connection and invoke getFolderEntryList()

Before you can use the getFolderEntryList() API, you must provide credentials to invoke the Discoverer Web Services, and have a valid session key (by performing a login() call). For more information, see "Provide the credentials to invoke Discoverer Web Services", and "Use the identifier to invoke login()".

ConnectionKey cKey = new ConnectionKey();
cKey.setKey("CONNECTIONKEY");
FolderEntryPath fPath = new FolderEntryPath();
fPath.setPath("");
 
System.out.println("Invoke the getFolderEntryList() API");
FolderEntryList fList = proxy.getFolderEntryList(sKey, cKey, fPath);
List fEntries = fList.getFolderEntries();
for(int i=0; i<fEntries.size(); i++)
 {
       System.out.println("Name:"+ fEntries.get(i).getName().getName());
       System.out.println(" Path:"+ fEntries.get(i).getPath().getPath());
       System.out.println("    Desc:"+fEntries.get(i).getDesc().getDesc());
       System.out.println("       Type:"+ fEntries.get(i).getType().getType()); 
 }

Notes:

  • The folder path is an empty string for relational database connections. For OLAP connections you can specify the complete folder name.

    • For a relational database connection, the Type is always "Workbook". In case of an OLAP connection, you can see "Folder" as Type.


1.14.5 Select a particular worksheet by invoking getWorksheetList()

You can use the getWorksheetList() API to get a list of worksheets for a given workbook.

WorkbookKey wbKey = new WorkbookKey();
wbKey.setConnKey(cKey);
wbKey.setKey("ANALYTIC_FUNCTION_EXAMPLES");
 
System.out.println("Invoke the getWorksheetList() API");
WorksheetList wsList = proxy.getWorksheetList(sKey, wbKey);
List wsheets = wsList.getWorksheets();
      for(int i=0; i<wsheets.size(); i++)
      {
        System.out.println("Name:" +wsheets.get(i).getName().getName());
        System.out.println("    Key:"+wsheets.get(i).getKey().getKey());
      }

The Key that you obtained from the above call can be used as the worksheet key for the subsequent web service calls.

1.14.6 Get the layout of the worksheet by invoking getLayoutMetadata()

This API provides information about the dimensions of a Discoverer worksheet.

WorksheetKey wsKey = new WorksheetKey();
wsKey.setWbKey(wbKey);
wsKey.setKey("ANALYTIC_FUNCTION_EXAMPLES/1817");
 
System.out.println("Invoke the getLayoutMetadata() API");
Layout layout = proxy.getLayoutMetadata(sKey, wsKey);
List dimensions = layout.getDimensions();
List measures = layout.getMeasures();
      for(int i=0; i< dimensions.size(); i++)
         {
           System.out.println("Dimension :"+dimensions.get(i).getName());
         }          
      for(int i=0; i<measures.size(); i++)
          {
            System.out.println("Measure :"+measures.get(i).getName());
          }

1.14.7 Select the parameter metadata for a worksheet by invoking getParameterMetadata()

Use this API to check whether any parameter metadata is available for the worksheet.

System.out.println("Invoke the getParameterMetaData() API");
ParameterList pList = proxy.getParameterMetadata(sKey, wsKey);
List parameters = pList.getParameters();
     for(int i=0; i< parameters.size(); i++)
      {
        System.out.println("Name:"+ parameters.get(i).getName().getName());
        System.out.println("  Key:"+parameters.get(i).getKey().getKey());
      }

This API returns an empty list if the worksheet does not contain any parameter.

1.14.8 Select a worksheet parameter and obtain its LOVs by invoking getParameterValueList()

The parameters for this API are sessionKey, parameterKey, and an integer.

ParameterKey pKey = new ParameterKey();
pKey.setKey("ANALYTIC_FUNCTION_EXAMPLES/1817/36211");
pKey.setWsKey( wsKey);
ParameterValueList pvList = proxy.getParameterValueList(sKey,pKey,new Integer(50));
List pvs = pvList.getParamValues();  
System.out.println("Invoke the getParameterValueList() API");
System.out.println("Parameter Lovs:");
for(int i=0; i< pvs.size(); i++)
{
System.out.println("Val :"+pvs.get(i).getValue()); // Lov
System.out.println(" DescriptorKey :"+pvs.get(i).getDescriptorKey());
//paramter descriptor key. This is valid if the parameter is an indexed type;
}

1.14.9 Select worksheet parameters and obtain LOVs in the cascading style by invoking getCascadeParameterValueList()

The parameters for this API are sessionKey, parameterKey, an integer, and ParameterSelectList.

// Code to retrieve cities from the region 'west'.
// To build the ParameterSelectList with the region as "west"

ParameterValue[] pval_region = new ParameterValue[1];
pval_region[0] = new ParameterValue();
pval_region[0].setValue("West");
pval_region[0].setDescriptorKey(null);

ParameterSelect[] pselect_region = new ParameterSelect[1];
pselect_region[0] = new ParameterSelect();
pselect_region[0].setKey(pKey_region);
ArrayList<ParameterValue> pval_regionlist = new ArrayList<ParameterValue>();
pval_regionlist.add(pval_region[0]);
pselect_region[0].getValues().addAll(pval_regionlist);

ParameterSelectList pselectList= new ParameterSelectList();
ArrayList<ParameterSelect> pSelectArraylist = new ArrayList<ParameterSelect>();
pSelectArraylist.add(pselect_region[0]);
pselectList.getSelParams().addAll(pSelectArraylist);

// To get the values for the city parameter
ParameterKey pKey_city = new ParameterKey();
pKey_city.setKey("XMLP_PARAMETERSCASCADE/1/10");
pKey_city.setWsKey(wsKey);

do
{


    pvList = proxy.getCascadeParameterValueList(sKey,pKey_city,new Integer(10),pselectList);
    pvs= pvList.getParamValues();
    System.out.println("Invoke the getParameterValueList() API");
    System.out.println("Parameter Lovs: "+pvs.size());
    for(int i=0; i< pvs.size(); i++)
    {
      System.out.println("Val :"+pvs.get(i).getValue()); // Lov
      System.out.println("    DescriptorKey :"+pvs.get(i).getDescriptorKey());
    }
}while (pvs.size()>0 );

1.14.10 Submit a worksheet query (including parameters) by invoking submitWorksheetQuery()

The parameters for this API are sessionKey, workSheetKey, ParameterSelectList and QueryOption.

ParameterSelectList helps you to pass a list of selected parameters. The code below is for multiple parameters and multiple vales for each parameter.

   ParameterValue[] pval = new ParameterValue[1];
   pval[0] = new ParameterValue();
   pval[0].setValue("Aladdin"); 
   pval[0].setDescriptorKey(null);
   pval[1] = new ParameterValue();
   pval[1].setValue("A Few Good Men");
   pval[1].setDescriptorKey(null);
 
   ParameterSelect[] pselect = new ParameterSelect[1];
   pselect[0] = new ParameterSelect();
   pselect[0].setKey(pKey);
   ArrayList pvallist = new ArrayList();
   pvallist.add(pval[0]); 
   pvallist.add(pval[1]);
   pselect[0].getValues().addAll(pvallist);
   ParameterSelectList pselectList = new ParameterSelectList();
   ArrayList pselectlist = new ArrayList();
   pselectlist.add(pselect[0]);
   pselectList.getSelParams().addAll(pselectlist);

The QueryOption helps you to control the properties of the result set. The supported result types are XMLROWSET, PDF, HTML, and XLS. For the XMLROWSET type, you can specify the number of rows per fetch.

From the QueryOptions that you specify, the applicable options are considered; the others are discarded.

    ResultType rt = new ResultType();
    rt.setType("XMLROWSET"); 
 
    QueryOption qo = new QueryOption();
                qo.setChunkSize(1021);
    qo.setNoOfrows(25);
    qo.setResultType(rt);
    qo.setUserCredential(uc);
           

The code below submits the query.

    QueryKey qKey = proxy.submitWorksheetQuery(sKey, wsKey,pselectList,qo); 
    System.out.println("Query Key :" + qKey.getKey());

1.14.11 Check the status of the query by invoking getQueryStatus()

       String status="";            
       String resultsReady = "Results Ready";
       String cancelled = "Cancelled";
       QueryStatus qs = null;
       while(!status.equalsIgnoreCase(resultsReady) && 
       !status.equalsIgnoreCase(cancelled))
       { qs = proxy.getQueryStatus(sKey, qKey);
         status = qs.getStatus();
         System.out.println("Status :"+qs.getStatus());
         Thread.sleep(5);
       }

1.14.12 View worksheet data on completion of the query by invoking getWorksheetData()

Once you get the query status as Ready, you can get the worksheet data using the getWorksheetData() API. The code below shows how to get the worksheet data for XMLROWSET result type.

          if(qs!= null && qs.getStatus().equalsIgnoreCase(resultsReady))
        {
        System.out.println("Invoking getWorksheetData() API");
       QueryResult qr = null;
        do
        {
          qr = proxy.getWorksheetData(sKey, qKey,false);
          String data = qr.getData();
                if (qo.getResultType().getType().matches("XMLROWSET") )
                {
            System.out.println("------------Data block begin------------");
             System.out.println(data);
            System.out.println("------------Data block end------------");
                }
          }while(qr.isFinished()== false);
          }

The following code sample explains how to get the worksheet data for a binary data type (for example, XLS).

          if(qs!= null && qs.getStatus().equalsIgnoreCase(resultsReady))
        {
                System.out.println("Invoking getWorksheetData() API");
          QueryResult qr = null;
                do
           {
              qr = proxy.getWorksheetData(sKey, qKey,false);
              String data = qr.getData();
              if(qo.getResultType().getType().matches("XLS") )
              {
                 String opFilename = "/tmp/out.xls" ;
                        else if
                        Base64Decoder myBase64Decoder = new Base64Decoder();
                 byte _myTempByteArray [] = null;
                 FileOutputStream fout = null;
                 String opFilename = "/tmp/out.xls" ;
                 try
                 {
                  fout =new FileOutputStream(opFilename);
                 }
                 catch(FileNotFoundException e)
                 {
                   System.out.println("Error Opening Output File");
                   return;
                 }
                 _myTempByteArray = myBase64Decoder.decode(data);
         fout.write(_myTempByteArray);
         }
        }while(qr.isFinished()== false);
        }

1.14.13 Log out, by invoking Logout()

proxy.logout(sKey);

1.15 Example of a Java class that invokes Discoverer Web Services

The following text is an example of a Java class (wsiClient.java) that might invoke Discoverer Web Services:

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
 
import java.util.List;
import java.util.Map;
 
import javax.xml.ws.BindingProvider;
import javax.xml.ws.WebServiceRef;
 
import jaxwstest.proxy.Wsi;
import jaxwstest.proxy.Wsi_Service;
import jaxwstest.proxy.types.ConnectionKey;
import jaxwstest.proxy.types.ConnectionList;
import jaxwstest.proxy.types.DisplayName;
import jaxwstest.proxy.types.FolderEntry;
import jaxwstest.proxy.types.FolderEntryList;
import jaxwstest.proxy.types.FolderEntryPath;
import jaxwstest.proxy.types.Identifier;
import jaxwstest.proxy.types.LocaleBean;
import jaxwstest.proxy.types.QueryKey;
import jaxwstest.proxy.types.QueryOption;
import jaxwstest.proxy.types.QueryResult;
import jaxwstest.proxy.types.QueryStatus;
import jaxwstest.proxy.types.ResultType;
import jaxwstest.proxy.types.SessionKey;
import jaxwstest.proxy.types.UserCredential;
import jaxwstest.proxy.types.WorkbookKey;
import jaxwstest.proxy.types.Worksheet;
import jaxwstest.proxy.types.WorksheetKey;
import jaxwstest.proxy.types.WorksheetList;
 
import oracle.net.www.Base64Decoder;
 
public class wsiClient 
{
  @WebServiceRef
  private static Wsi_Service wsi_Service;
  public static void main(String[] args)
  {
    
    try
    {
      // Create a new stub 
      wsi_Service = new Wsi_Service();
      wsiProxy proxy = new wsiProxy();
    
      Map requestContext = ((BindingProvider)proxy).getRequestContext();
      requestContext.put(BindingProvider.USERNAME_PROPERTY,"weblogic");
      requestContext.put(BindingProvider.PASSWORD_PROPERTY,"weblogic");
      requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,testEndpoint);
      requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
      // Add your code to call the desired methods
    
      String version = proxy.getVersion();
      System.out.println("Version ="+version );
    
      DisplayName ssouser = new DisplayName();
      ssouser.setUser("SSOUSER1");
      Identifier  idfr = new Identifier();
      idfr.setId("IDENTIFIER");
    
      UserCredential uc = new UserCredential();
      uc.setDisplayName(ssouser);
      uc.setIdentifier(idfr);
      LocaleBean locale = new LocaleBean();
      locale.setCountry("US");
      locale.setLanguage("en");
      locale.setVariant("");
      
      System.out.println("Invoke the login() WS API");
      SessionKey sKey = proxy.login(uc, locale);
      System.out.println("Session Key :"+sKey.getKey());
      
      System.out.println("-----------------------------------------------");
      // Get the list of connections accessible to this SSOUser
      System.out.println("Invoke the getConnectionList() API");
      ConnectionList cl = proxy.getConnectionList(sKey);
      List conns = cl.getConnections();
      System.out.println("Discoverer connections:");
      for(int i=0; i<conns.size(); i++)
      {
      System.out.println("Name:"+conns.get(i).getConnectionName().getName());
      System.out.println(" Key:"+ conns.get(i).getConnectionKey().getKey());
      System.out.println(" Desc:"+ conns.get(i).getConnectionDesc().getDesc());
      }
      System.out.println("-----------------------------------------------");
      
      System.out.println("Invoke the getFolderEntryList() API");
// Create a valid connectionKey object using one of the connection keys obtained
 in the getConnectionList
      ConnectionKey cKey = new ConnectionKey();
      cKey.setKey("CONNECTIONKEY");
      FolderEntryPath fPath = new FolderEntryPath();
      fPath.setPath("");
 
      System.out.println("Invoke the getFolderEntryList() API");
      FolderEntryList fList = proxy.getFolderEntryList(sKey, cKey, fPath);
      List fEntries = fList.getFolderEntries();
      for(int i=0; i<fEntries.size(); i++)
      {
       System.out.println("Name:"+ fEntries.get(i).getName().getName());
       System.out.println("   Path:"+ fEntries.get(i).getPath().getPath());
       System.out.println("   Desc:"+fEntries.get(i).getDesc().getDesc());
       System.out.println("   Type:"+ fEntries.get(i).getType().getType()); 
       }
       System.out.println("-----------------------------------------------");
      
      WorkbookKey wbKey = new WorkbookKey();
      wbKey.setConnKey(cKey);
      wbKey.setKey("ANALYTIC_FUNCTION_EXAMPLES");
 
      System.out.println("Invoke the getWorksheetList() API");
      WorksheetList wsList = proxy.getWorksheetList(sKey, wbKey);
      List wsheets = wsList.getWorksheets();
      for(int i=0; i<wsheets.size(); i++)
      {
        System.out.println("Name:" +wsheets.get(i).getName().getName());
        System.out.println("    Key:"+wsheets.get(i).getKey().getKey());
      }
      System.out.println("-----------------------------------------------");
      
      WorksheetKey wsKey = new WorksheetKey();
      wsKey.setWbKey(wbKey);
      wsKey.setKey("ANALYTIC_FUNCTION_EXAMPLES/1817");
 
      System.out.println("Invoke the getLayoutMetadata() API");
      Layout layout = proxy.getLayoutMetadata(sKey, wsKey);
      List dimensions = layout.getDimensions();
      List measures = layout.getMeasures();
      for(int i=0; i< dimensions.size(); i++)
         {
           System.out.println("Dimension :"+dimensions.get(i).getName());
         }          
      for(int i=0; i<measures.size(); i++)
          {
            System.out.println("Measure :"+measures.get(i).getName());
          }
      
System.out.println("-----------------------------------------------");
      
System.out.println("Invoke the getParameterMetaData() API");
ParameterList pList = proxy.getParameterMetadata(sKey, wsKey);
List parameters = pList.getParameters();
for(int i=0; i< parameters.size(); i++)
 {
   System.out.println("Name:"+ parameters.get(i).getName().getName());
   System.out.println("  Key:"+parameters.get(i).getKey().getKey());
 }
System.out.println("-----------------------------------------------");
      
ParameterKey pKey = new ParameterKey();
pKey.setKey("ANALYTIC_FUNCTION_EXAMPLES/1817/36211");
pKey.setWsKey( wsKey);
 
ParameterValueList pvList = proxy.getParameterValueList(sKey,pKey,new Integer(50));
List pvs = pvList.getParamValues();  
System.out.println("Invoke the getParameterValueList() API");
System.out.println("Parameter Lovs:");
for(int i=0; i< pvs.size(); i++)
{
System.out.println("Val :"+pvs.get(i).getValue()); // Lov
System.out.println(" DescriptorKey :"+pvs.get(i).getDescriptorKey());
//paramter descriptor key. This is valid if the parameter is an indexed type;
}
       
   ParameterValue[] pval = new ParameterValue[1];
   pval[0] = new ParameterValue();
   pval[0].setValue("Aladdin");     pval[0].setDescriptorKey(null);
   pval[1] = new ParameterValue();
   pval[1].setValue("A Few Good Men");
   pval[1].setDescriptorKey(null);
 
   ParameterSelect[] pselect = new ParameterSelect[1];
   pselect[0] = new ParameterSelect();
   pselect[0].setKey(pKey);
   ArrayList pvallist = new ArrayList();
   pvallist.add(pval[0]); 
   pvallist.add(pval[1]);
   pselect[0].getValues().addAll(pvallist);
   ParameterSelectList pselectList = new ParameterSelectList();
   ArrayList pselectlist = new ArrayList();
   pselectlist.add(pselect[0]);
   pselectList.getSelParams().addAll(pselectlist);
       
    ResultType rt = new ResultType();
    rt.setType("XMLROWSET"); 
 
    QueryOption qo = new QueryOption();
                qo.setChunkSize(1021);
    qo.setNoOfrows(25);
    qo.setResultType(rt);
    qo.setUserCredential(uc);
 
    QueryKey qKey = proxy.submitWorksheetQuery(sKey, wsKey,pselectList,qo); 
    System.out.println("Query Key :" + qKey.getKey());
 
       String status="";            
       String resultsReady = "Results Ready";
       String cancelled = "Cancelled";
       QueryStatus qs = null;
       while(!status.equalsIgnoreCase(resultsReady) && 
       !status.equalsIgnoreCase(cancelled))
       {
         qs = proxy.getQueryStatus(sKey, qKey);
         status = qs.getStatus();
         System.out.println("Status :"+qs.getStatus());
         Thread.sleep(5);
       }
        if(qs!= null && qs.getStatus().equalsIgnoreCase(resultsReady))
        {
        System.out.println("Invoking getWorksheetData() API");
       QueryResult qr = null;
        do
        {
          qr = proxy.getWorksheetData(sKey, qKey,false);
          String data = qr.getData();
                if (qo.getResultType().getType().matches("XMLROWSET") )
                {
            System.out.println("------------Data block begin------------");
             System.out.println(data);
            System.out.println("------------Data block end------------");
                }
          }while(qr.isFinished()== false);
          }
      proxy.logout(sKey);
      }
      catch(Exception ex){
      ex.printStackTrace();
      }
    }
  }