Skip Headers

Oracle® Application Developer's Guide - XML 10g (9.0.4) Part Number B12099-01 |
Home | Contents | Index

# 18
Using OracleAS Dynamic Services and XML

OracleAS Dynamic Services (Dynamic Services or DS) enables developers to take advantage of Web application functionality and content, as services to increase productivity. DS adds web services deployment and management capability to Oracle. Developers can use Oracle9i Dynamic Services to compose, catalog, manage, and personalize web services according to user roles, protocols and delivery devices.

This chapter describes the following sections:

- Introducing OracleAS Dynamic Services

- What is Needed to Run OracleAS Dynamic Services?

- Dynamic Services (DS) Architecture Overview

- Dynamic Services (DS) Implementation Overview (Java, PL/SQL, HTTP/Java)

- Dynamic Services Features

- Dynamic Services Integrates with Other Oracle Products

- How Service Consumers Use Dynamic Services

- Developing Services For Dynamic Services

- Oracle Syndication Server (OSS)

- Dynamic Services Consumer Application: Stock Portfolio Example

- Frequently Asked Questions (FAQs): Dynamic Services

## Introducing OracleAS Dynamic Services

OracleAS Dynamic Services (DS) is a Java-based programmatic framework for incorporating, managing, and deploying Internet and Intranet services. It uses the Internet as the information source. It facilitates the rapid incorporation of services from Web sites, local databases, and proprietary systems into applications.

For example, an online financial portfolio application can use DS to integrate Internet financial services, such as stock quotes and exchange rates, from different resource providers to calculate the current value of a portfolio in foreign currency. See also Figure 18-1 and "Dynamic Services Consumer Application: Stock Portfolio Example" . DS handles dynamic business models with no degradation in service quality. A DS "service" provides access to information or application functionality through standard Internet protocols, such as, HTTP, JDBC, or SOAP. A "service" can also aggregate other DS services to form a compound service with a specific execution flow. It can include transformations and conditional logic and is accessible through a uniform interface.

Figure 18-1 illustrates a typical Dynamic Services (DS) scenario. This is a workflow of how an application can use DS services to retrieve and manage the data. You simply need to determine the semantics and output formats needed:

1. The database notes that the inventory is getting low for a certain part in your inventory. This triggers an event that tells you a specific part is low.

2. A DS service is then invoked that access a supplier and invokes the service that accesses the information. The supplier ABC's site could be in a foreign currency or different format. Data about the supplier is logged as well as a catalog of parts available.

3. Another service is invoked that translates the language and currency to the desired language and currency of your Inventory Application.

4. The inventory application can also be connected to other applications. In steps 4 and 5 the results are delivered in multiple channels.

5. The resulting data is formatted according to the devices target user's devices. The DS service can also render the results in any format that the service has been equipped for using stylesheets. The data is transferred mostly in XML.

#### Figure 18-1 Typical Dynamic Services Scenario

Text description of the illustration dyn5.jpg

### How Dynamic Services (DS) Helps Developers

DS meets the design criteria needed by application developers in that with DS, developers have:

- A single programmatic framework for service access, management, execution, and delivery, based on the following features:

  - Access: Uniform, XML-based access to diverse sources through different protocols.

  - Management: Centralized management of services, sessions, caching policies, and events.

  - Execution: Advanced execution modules to enable service aggregation and failover.

  - Delivery: Multi-channel delivery to different output formats, devices, and user groups

- Each business can define its own internal service interfaces, without forcing partners to standardize. In other words, if you have partners with various interfaces, languages, currencies, and so on, they will not have to make any changes in order to exchange data with you.

### For Further Information

For further information about OracleAS Dynamic Services:

See: Oracle Directory Service Integration and Deployment Guide Oracle Dynamic Services User's and Administrator's Guide http://otn.oracle.com/products/dynamic_services/index.htm

## What is Needed to Run OracleAS Dynamic Services?

To run OracleAS Dynamic Services you need the following:

- Oracle9i Enterprise Edition, OracleAS

- Any platform that has Java2-compliant (JDK 1.2.2 or later) JVM installed, including Oracle8i JVM or higher. This is because the Dynamic Services engine is implemented in Java.

- JDK 1.2.2 or higher.`<JAVA2_HOME>` is the installation directory of the JDK 1.2.2 or higher, distribution.

Ensure that you have at least a full (typical) installation of Oracle.

## Dynamic Services (DS) Architecture Overview

Figure 18-2 shows an overview of Oracle Dynamic Services (DS) architecture. It shows the following:

- How Service Providers (business partners and application developers) provide services that Service Administrators register in the Service Registry using the `DSAdmin` utility (Service Administrator).

- Application developers can create applications using application profiles that service administrators register in the Application Profile Registry. The registry is an Oracle Internet Directory (OID) Lightweight Directory Access Protocol (LDAP) server whose contents are also mirrored in the Oracle database for performance optimization.

#### Figure 18-2 Oracle Dynamic Services (DS) Architecture

Text description of the illustration dsarch.gif

Dynamic Services can be deployed in the following ways:

- Using PL/SQL interfaces when deployed within the Oracle JVM (see Figure 18-4)

- Using Java interfaces, when deployed on a local machine hosting the application (thick client library) (see Figure 18-3)

- Using remote Java interfaces when deployed as a middle-tier Java engine behind a Java servlet with which the application can communicate through Dynamic Services thin client library (see Figure 18-5)

## Dynamic Services (DS) Implementation Overview

OracleAS Dynamic Services (DS) currently offers deployment modes:

- Java deployment view (see "Dynamic Services Java Deployment" ).

- PL/SQL deployment view (see "Dynamic Services PL/SQL Deployment" ).

- Java (HTTP/Java Messaging Services (JMS)) Deployment view (see"Dynamic Services Java HTTP/Java Messaging Services (JMS) Deployment" ).

#### Main DS Components

The following lists the DS main components for each of these deployment modes.

- Dynamic Services Engine. The Dynamic Services engine can be deployed as any of the following three engine types:

  - A Java engine running on the machine hosting the application (thick client library) (see Figure 18-3).

  - A middle-tier Java engine behind a Java servlet (see Figure 18-5).

  - An engine running within Oracle JVM (see Figure 18-4).

  You can switch from one environment to another without recompiling or even restarting your application. This gives you a way to try out the various options.

- DS Service and Application Profile Registries. The Service Registry and Application Profile Registry are used as directories in Oracle Internet Directory (OID) server. The access control list of OID is used for access control, allowing service administrators to choose the services visible to a particular service consumer application.

- Communication Between Service Consumer Applications and Dynamic Services Engine. Communication between the Dynamic Services engine and the service consumer applications is handled by the Dynamic Services client library. By registering a Dynamic Servicesdriver, a service consumer application can dynamically change the underlying communication protocol used by the client library to communicate with the Dynamic Services engine. Supported communication protocols include HTTP, AQ/JMS, and direct Java access.

## Dynamic Services Java Deployment

Figure 18-3 shows the Dynamic Services Java deployment view. Oracle serves as a registry cache, communicating with the OID Lightweight Directory Access Protocol (LDAP) server hosting the registries. Service Consumer Application contains application logic that uses the services through direct Java calls.

Here, Service Consumer Application uses the DS thick client library, that contains the Dynamic Services Execution Engine. Service providers run in their own servers.

#### Figure 18-3 Oracle Dynamic Services: Java Deployment

Text description of the illustration dysrv_i3.gif

## Dynamic Services PL/SQL Deployment

Figure 18-4 shows Oracle Dynamic Services PL/SQL deployment. The Dynamic Services engine runs in the Oracle JVM, with its functions exposed as a set of Java stored procedures. Oracle database serves as a registry cache. It communicates with Oracle Internet Directory LDAP server which hosts the registries. The Service Consumer Application's logic makes use of the services through PL/SQL calls. Service Providers run in their own servers.

#### Figure 18-4 Oracle Dynamic Services: PL/SQL Deployment

Text description of the illustration dysrv_ic.gif

## Dynamic Services Java HTTP/Java Messaging Services (JMS) Deployment

Figure 18-5 shows an Oracle Dynamic Services Java (HTTP/JMS) deployment view. The Dynamic Services engine running in a Dynamic Services gateway (middle tier) supports HTTP, HTTPS, and JMS communication protocols. Oracle database serves as a registry cache, communicating with the Oracle Internet Directory LDAP server hosting the registries. The Service Consumer Application's logic, makes use of the services through Dynamic Services' thin Java client library, and executes services remotely in other systems. Here, service execution requests are forwarded to the Dynamic Services gateway, which executes the service and returns a response. Communication between the service consumer application and the gateway is handled by the Dynamic Services thin client library.

#### Figure 18-5 Oracle Dynamic Services Java (HTTP/JMS) Deployment

Text description of the illustration dysrv_i4.gif

For example, in asynchronous deployment communications (JMS), the DSJMSDriver can allow for asynchronous access to services, in the form of a JMS daemon (using a Dynamic Services gateway). The driver allows request submission asynchronously to an AQ/JMS queue in a remote database. The driver assumes the existence of this JMS daemon running somewhere that listens asynchronously to the same queue where requests are being submitted.

The JMS daemon takes on the role of the Dynamic Services engine. It processes the request, generates a response, and submits the response to another queue that the DSJMSDriver listens to asynchronously. On the service consumer application side, therefore, listeners can be registered to be informed when the response is returned.

See Also: Oracle Directory Service Integration and Deployment Guide Oracle Dynamic Services User's and Administrator's Guide for more information about Dynamic Services' Java, PL/SQL, and JMS deployment.

### Multiple Channel Capabilities of DS

Figure 18-6 illustrates the multiple channels through which DS can be delivered. These include:

- Oracle Portal

- Oracle Application Server Wireless Edition (OracleAS WE)

- ICE through the Oracle Syndication Server (OSS)

- SOAP through the Oracle Dynamic Services SOAP Listener

#### Figure 18-6 Dynamic Services Overview

Text description of the illustration dynam1.jpg

## Dynamic Services Features

Dynamic Services (DS) features include the following:

### Service Management and Administration

Dynamic Services' (DS) service management and administration features include: DS business relationship management can handle such business tasks as:

- Specifying service policies, priorities

- Working with partner security or authentication models

- Tracking usage and perform billing through events

- Maintain copyright, logo, and other provider information in service descriptor

In forthcoming releases, DS will be managed and administered through Oracle Enterprise Manager.

### Service Discovery

Dynamic Services' service discovery feature supports run-time Intranet Discovery (LDAP). For example, service descriptors can be stored in Oracle Internet Directory (OID) for security, centralized management, and LDAP lookup. They can be accessed from mirrored Oracle instances for improved runtime performance.

### Service Execution

Dynamic Services service execution features include the following:

- Executing a service. Figure 18-7 shows an overview of this.

- Advanced Execution Modules:

  - Failover

  - Compound

  - Conditional services

- Events/triggers

The following sections and diagrams describe these DS service execution features.

#### Figure 18-7 DS: Executing a Service -- Overview

Text description of the illustration dynsrv_7.gif

D

#### Failover Services

DS Failover services is a prioritized list of backup equivalent services. Figure 18-8 shows an example of failover services used in a stock quote application.

#### Figure 18-8 Dynamic Services: Failover Services Example

Text description of the illustration dynsrv_9.gif

#### Compound Services

DS allows you to aggregate services and specify which services you need executed in parallel and which services you need executed in series.

For example, Figure 18-9 shows how you can take one or more services, here Service 1 and Service 2, and combine the results by performing operations (here merging or splitting) on them to generate a single result. You can also take the output of one service and input this into another service.

#### Figure 18-9 Dynamic Services: Compound Services

Text description of the illustration dynsrv10.gif

#### Conditional Services

Dynamic Services can execute services according to business requirements. Requirements can be based on service request or user profile properties. Figure 18-10 shows how you can use DS to switch on a specific service(s) for 'gold' customers.

#### Figure 18-10 DS: Conditional Services

Text description of the illustration dynsrv11.gif

#### Events or Triggers

Through the course of executing a DS service, numerous events will be generated that can be captured by the monitoring application. This application will in turn execute other DS services, termed, "monitoring services", depending on the events they receive. Figure 18-11 illustrates an example of this and how the monitored events can trigger a variety of services, including logging, notification, profiling, and billing services.

#### Figure 18-11 Dynamic Services: Events or Trigger Services

Text description of the illustration dynsrv12.gif

## Dynamic Services Integrates with Other Oracle Products

Dynamic Services (DS) integrates with other Oracle products, including:

- JDeveloper. You can use JDeveloper to create, debug, and deploy DS. JDeveloper facilitates application integration in Java, JSP, XSQL, and SOAP.

- OracleAS Wireless Edition. DS integrates with Oracle Application Server Wireless Edition (WE), previously known as Portal-To-Go. You can build an adaptor for Oracle Application Server WE to make use of Dynamic Services in your mobile applications.

- Oracle Portal. You can integrate with Oracle Portal through the Oracle Portal JPDK to create a Java Web Provider that uses Dynamic Services. This exposes Dynamic Services as portlets.

  Under "Portal Development Kit (PDK)", select the PDK ("click here") then "Integrating Technologies". Read further information under Developing Portlets with Dynamic Services Portlet

## How Service Consumers Use Dynamic Services

The Dynamic Services client library provides service consumers (application developers) with a Java application programming interface (API) that can be used to access the functions of the Dynamic Services engine.

See Also: Oracle Directory Service Integration and Deployment Guide Oracle Dynamic Services User's and Administrator's Guide for client Java code examples used to create a service request for some of the sample services supplied with Oracle Dynamic Services, and executing them.

For more information, refer to the sample code in `<$ORACLE_HOME>/ds/demo/consumer` directory and to the Javadoc API (apidoc.zip) in `<$ORACLE_HOME>/ds/doc/`.

## Developing Services For Dynamic Services

In Dynamic Services, a service is a component within the Internet computing model that delivers a specialized value-added function. A service is bundled into a simple service package and structured as a local directory. The following are typical tasks you will be using Dynamic Services for:

- Enabling Persistent Auditing or Event Monitor Services

- Enabling Event Logging and the event monitor

- Using the event logger monitor service

- Querying the logger events

- Modifying Cache Parameter values

#### Service Response Caching

The Dynamic Services engine uses the Oracle database for caching service responses. The caching policy for a given service is controlled through deployment parameters in the service descriptors. Before registering a service, the Service Administrator can review these parameters and modify them as needed. The caching parameters are defined in the SERVICE_HEADER, DEPLOYMENT, and CACHING elements in the service descriptor.

To change the caching parameters of a given service, you must unregister the service and register it again with the new parameter settings. Available caching parameters are:

- MAX_AGE: Specifies the number of seconds the service response remains valid in the cache. After the specified amount of time elapses, the cached response is discarded. When the MAX_AGE value is specified to be zero or less, the service response is never cached.

- SESSION_PRIVATE: Takes a Boolean value (TRUE or FALSE) to indicate whether cached responses for this service should be visible only within the current session, or if they should be visible to all executions. Table 7-1 shows an overview of the behavior of four possible service response cases.

  See: Oracle Directory Service Integration and Deployment Guide Oracle Dynamic Services User's and Administrator's Guide chapters 3 and 6, and Appendix C, "Descriptive Matrix of the packaged XML Schemas and Adaptors", for detailed information about developing Dynamic Services services.

## Oracle Syndication Server (OSS)

OSS is an application of Dynamic Services. See Chapter 19, "Oracle Syndication Server (OSS) and XML".

## Dynamic Services Consumer Application: Stock Portfolio Example

The Dynamic Services software package contains sample code to specifically invoke Yahoo Portfolio service through Dynamic Service engine, using Java. Portfolio service is a service that takes stock symbols as input and give quotes as responses. This service is provided by Yahoo®.

This Dynamic Services software contains the following:

- `SampleStock.java`: Example java code to invoke a dynamic service in Java.

- `yapfl_req.xml`: Sample service request file.

- readme.txt

### Compiling SampleStock.java

Before compiling `SampleStock.java`, include the following library in your CLASSPATH:

- Dynamic Services: C:\Oracle\Ora81\ds\lib\ds.jar

- Oracle XML Parser 2.0.2.9: C:\Oracle\Ora81\ds\lib\xmlparserv2.jar

- Oracle XMLSchema Parser 1.0: C:\Oracle\Ora81\ds\lib\xschema.jar

- Oracle AQ and JMS: C:\Oracle\Ora81\RDBMS\jlib\jmscommon.jar;C:\Oracle\Ora81\RDBMS\jlib\aqapi.jar

- JSSE 1.0: C:\Oracle\Ora81\ds\lib\jcert.jar;C:\Oracle\Ora81\ds\lib\jsse.jar;C:\Oracle\Ora81\ds\lib\jnet.jar

- LDAP JNDI: C:\Oracle\Ora81\ds\lib\providerutil.jar;C:\Oracle\Ora81\ds\lib\ldap.jar;C:\Oracle\Ora81\ds\lib\jndi.jar

- ODS - XSQL 1.0.3 and dependent libraries:

- C:\Oracle\Ora81\ds\lib\sax2.jar;C:\Oracle\Ora81\ds\lib\oraclexsql.jar;C:\Oracle\Ora81\ds\lib\xsu12.jar where C:\Oracle\Ora81 should be replaced with your $ORACLE_HOME. If there are any other libraries in red, please fix them appropriately.

Compile `SampleStock` at the command line as follows:

    javac SampleStock.java

To run and test the sample, proper arguments should be given in the command line, as follows:

    java SampleStock <HOST_URL> <SID> <SymbolList>

where:

##### Table 18-1 SampleStock Command Line Arguments

Argument | Description
--- | ---
HOST_URL | For example, egroup-dev3.us.oracle.com
SID | For example, db816
SymbolList | For example, 'ORCL INTC MSFT'

The output of `SampleStock` should be a table of data about requested stocks, such as the following:

    |-----+--------------------|
    |     | Time  | 12:19PM    |
    |     |-------+------------|
    |     | Price | 30 3/16    |
    |ORCL |-------+------------|
    |     | Change| +0.42%     |
    |     |-------+------------|
    |     | Volume| 34,272,000 |
    |-----+--------------------|
    |     | Time  | 12:19PM    |
    |     |-------+------------|
    |     | Price | 35 15/64   |
    |INTC |-------+------------|
    |     | Change| -2.80%     |
    |     |-------+------------|
    |     | Volume| 22,499,200 |
    |-----+--------------------|
    |     | Time  | 12:19PM    |
    |     |-------+------------|
    |     | Price | 63         |
    |MSFT |-------+------------|
    |     | Change| +0.10%     |
    |     |-------+------------|
    |     | Volume| 24,091,600 |
    |-----+--------------------|

### Dynamic Services Example 1: SampleStock (Java)

`SampleStock` takes the command line parameters and keeps them in the class data members. Then it calls`getQuotes()` to retrieve the quote data.

`SampleStock` abstracts the process of executing YahooPortofolio DS service by:

- Inputting a list of stock tickers and returning all relevant information in the format of `Java.util.Hashtable`.

- Input parameter, symbolList A string, consists of several stock symbols, which are separated by white space, such as, "ORCL INTC MSFT".

- The return Hashtable is indexed by symbol name. Each entry of Hashtable is also a Hashtable which is indexed by an information label, that is, "Time", "Price", "Change", or "Volume".

- `SampleStock` calls`printQuotes()` to display the results in the Hashtable in the format shown above.

      import java.io.*;
      import java.util.*;

      // imports for handling XML docs
      import org.w3c.dom.*;
      import oracle.xml.parser.v2.*;

      // Dynamic Services imports
      import oracle.ds.*;
      import oracle.ds.comm.*;
      import oracle.ds.registry.*;
      import oracle.ds.comm.message.*;
      import oracle.ds.driver.*;
      import oracle.ds.utils.*;

      /**
      * SampleStock code. It opens a Dynamic Service
      * connection, looks up a stock quote service,
      * executes it and stores the results in a hash table.
      */
      public class SampleStock implements CommunicationMessageConstants
      {
       // Usage message
       private static final String USAGE =
       (
        "Usage: java SampleStock <HOST_URL> <SID> <Symbol list>\n "+
        "where, \n"+
        "\tHOST_URL: i.e. egroup-dev3.us.oracle.com\n"+
        "\tSID: i,e. db816\n" +
        "\tSymbol list: i.e. 'ORCL MSFT SEBL'\n"
       );

       // The following are actually the parameters in the
       // command line and some are hard coded.
       private static String ms_szJdbcURL;
       private static String ms_szUsername;
       private static String ms_szPassword;
       private static String ms_szServiceID;
       private static String ms_szSymbolList;

       // A utility to resolve the NamespacePrefix
       // In our case, we hard coded the namespace of the prortfolio service
       static private NSResolver ms_nsResolver = new NSResolver()
       {
         public String resolveNamespacePrefix(String szPrefix)
           { return "http://www.portfolio.org/Portfolio/Response"; }
       };

       /**
        * The main function
        */
       public static void main(String[] argv)
       {
         // Strict: Take only 3 arguments
         if (argv.length != 3) { System.err.println(USAGE); return; }

         // Extract the command line arguments
         int  iArgCounter = 0;
         ms_szJdbcURL = "jdbc:oracle:thin:@" + argv[iArgCounter++]
                                  + ":1521:" + argv[iArgCounter++];
         ms_szUsername = "dssys";
         ms_szPassword = "dssys";

         // Hardcoded service ID for "Yahoo StockQuote service"
         ms_szServiceID = "urn:com.yahoo:finance.portfolio03";
         ms_szSymbolList = argv[iArgCounter++];

         // Get quotes
         Hashtable ht = getQuotes(ms_szSymbolList);

         // Print quotes in a form
         printQuotes(ht);
       } // end of main

       /**
        * This function abstracts the process of executing the YahooPortofolio DS
        * service by taking in an input of a list of stock tickers and returning
        * all the relevant information in a java.util.Hashtable object.
        *
        * @param symbolList A white space delimited string containing the stock
        *                   symbols ( e.g. "ORCL INTC MSFT" ).
        * @return A Hashtable indexed by the stock symbol, and each entry of the
        *         Hashtable is also a Hashtable which is indexed by the information
        *         label, i.e. "Time", "Price", "Change", "Volume".
        */
       public static Hashtable getQuotes(String symbolList)
       {
         Hashtable ht = new Hashtable();

         // If we are to use a session, a header field has to be set
         DSConnection dsconn = null;

         try
         {
           // First open the connection with the Direct Driver
           DSDriverManager.registerDriver("oracle.ds.driver.DSDirectDriver");
           dsconn = DSDriverManager.getConnection(ms_szJdbcURL);

           // Connect using your specified username/password
           dsconn.connect(ms_szUsername, ms_szPassword);
           System.err.println("==> Opened connection for "+ms_szUsername);

           // Lookup a service and obtaing the service request/response schemas
           DService dsServ = dsconn.lookupService(ms_szServiceID);

           // Make an XML request string from the symbol list
           String xmlRequest =
      "<?xml version=\"1.0\"?>                                 \n" +
      "<!-- Sample request of the Yahoo! portfolio service --> \n" +
      "<PortfolioReq                                           \n" +
      "  xmlns=\"http://www.portfolio.org/Portfolio/Request\" >\n";

           StringTokenizer st = new StringTokenizer(ms_szSymbolList);
           while (st.hasMoreTokens()) {
      xmlRequest = xmlRequest + "<Symbol>" + st.nextToken() + "</Symbol>\n";
           }

           xmlRequest = xmlRequest + "</PortfolioReq>\n";

           // Create a Request by requesting for a default request context
           // from our Dynamic Services Connection
           DSRequest dsReq = dsconn.createDSRequest(ms_szServiceID,
             new StringReader(xmlRequest));

           // Execute synchronously, get the response and print it
           DSResponse dsResp = null;
           dsResp = dsconn.executeSynch(dsReq);

           // Get the result XML
           StringWriter sw = new StringWriter();
           dsResp.writeResponse(sw);

           // Instantiate a DOM Parser to parse the result
           // to eventually get a Document
           DOMParser xmlp = new DOMParser();
           xmlp.parse( new StringReader(sw.toString()));
           XMLDocument xmldoc = xmlp.getDocument();

           // Get the list of "Quote" nodes
           NodeList nlist = xmldoc.getElementsByTagName("Quote");
           int nsym = nlist.getLength();

           // For each 'Quote' node
           for (int i = 0 ; i < nsym ; i ++)
           {
      XMLNode qnode = (XMLNode) nlist.item(i);

      // Make an entry from a quote node
      Hashtable entry = new Hashtable();

      entry.put("Time", qnode.valueOf("./P:Time", ms_nsResolver));
      entry.put("Price", qnode.valueOf("./P:Price", ms_nsResolver));
      entry.put("Change", qnode.valueOf("./P:Change", ms_nsResolver));
      entry.put("Volume", qnode.valueOf("./P:Volume", ms_nsResolver));

      // Insert into hash table
      ht.put(qnode.valueOf("./P:Symbol", ms_nsResolver), entry);
           } // end of for
         }
         catch (Exception e) { e.printStackTrace(); }

         // Clean up job
         finally
         {
           // If I have a valid connection then do clean-up
           if(dsconn != null)
           {
      	// Now close the connectin
      	try { dsconn.close(); }
      	catch(Exception e) { e.printStackTrace(); }
           }
         }

         // Return the final result
         return ht;
       } // end of getQuotes

       /**
        * This function outputs quotes in a Hashable to a form like
        * |-----+-------------------|
        * |     | Time  | 12:19PM   |
        * |     |-------+-----------|
        * |     | Price | 30 3/16   |
        * |ORCL |-------+-----------|
        * |     | Change| +0.42%    |
        * |     |-------+-----------|
        * |     | Volume| 34,272,000|
        * |-----+-------------------|
        * |     | Time  | 12:19PM   |
        * |     |-------+-----------|
        * |     | Price | 35 15/64  |
        * |INTC |-------+-----------|
        * |     | Change| -2.80%    |
        * |     |-------+-----------|
        * |     | Volume| 22,499,200|
        * |-----+-------------------|
        * |     | Time  | 12:19PM   |
        * |     |-------+-----------|
        * |     | Price | 63        |
        * |MSFT |-------+-----------|
        * |     | Change| +0.10%    |
        * |     |-------+-----------|
        * |     | Volume| 24,091,600|
        * |-----+-------------------|
        *
        * @param ht A Java.util.Hastable that is the result of method getQuotes().
        */
       public static void printQuotes(Hashtable ht)
       {

         System.out.println("|-----+-------------------------|");

         Enumeration e = ht.keys();

         // For each key in the Hashtable
         while (e.hasMoreElements())
         {
           // Key is a symbol
           String symbol = (String) e.nextElement();

           // Get an entry
           Hashtable entry = (Hashtable) ht.get(symbol);

           // -- Time
           System.out.println("|     | Time  | " +
      		       (String) entry.get("Time") + "\t\t|" );
           System.out.println("|     |-------+-----------------|");

           // -- Price
           System.out.println("|     | Price | " +
      		       (String) entry.get("Price") + "      \t|" );
           System.out.println("|" + symbol + " |-------+-----------------|");

           // -- Change
           System.out.println("|     | Change| " +
      		       (String) entry.get("Change") + "\t\t|" );
           System.out.println("|     |-------+-----------------|");

           // -- Volume
           System.out.println("|     | Volume| " +
      		       (String) entry.get("Volume") + "\t|" );
           System.out.println("|-----+-------------------------|");
         } // end of while
       } // end of printQuotes
      }

Here is some typical XML code for SampleStock.java:

    <PortfolioReq xmlns="http://www.portfolio.org/Portfolio/Request">
      <Symbol>ORCL</Symbol>
      <Symbol>INTC</Symbol>
    </Portfolio>

## Frequently Asked Questions (FAQs): Dynamic Services

### How to Set Up a Language of Queuing and Sequencing Commands?

I am investigating setting up a small language for queueing and sequencing commands. XML has obvious benefits, so I would like to know if anybody is familiar with an existing dtd for that use? This is obviously not difficult, but if a standard DTD already exists, why reinvent the wheel? Desired commands include:

- fetch from queue

- perform xslt transform

- perform xsql process

- insert into queue

- send an email

- log a message

- set configuration parameter

Others may be required in the future.

#### Answer

Dynamic Services allows you to model all the commands you mentioned as XML based services.

You can define these services as well as the flow in which you can execute them. Dynamic Services engine will follow the flow (including sending email because it has SMTP services available inside the engine) and send you a completed response back. The engine is directly callable via Java/PLSQL APIs. You can also use the 'Dynamic Services Gateway' or equivalent, to accept requests over HTTP using SOAP or other SOAP like xml-rpc calls. Almost all parts of the engine are extensible to allow you to plug-in any transformation, protocol or execution flow according to your needs.

### Other FAQs?

You can locate other Frequently Asked Questions (FAQs) with your DS software package at:

`$ORACLE_HOME/ds/doc/dsfaq.txt`

| Copyright © 2001, 2003 Oracle Corporation. All Rights Reserved. |
Home | Contents | Index