Stock Quote - Configure and run


Configuring the Sample
Running the Sample

There are two Stock Quote clients, a Java 2 Standard Edition (J2SE) version and a Java 2 Enterprise Edition (J2EE) container-managed version. If you want the full benefit of J2EE container services run the J2EE version.

Configuring the Sample

To complete the configuration of this Sample, deploy the JAX-RPC Web services Sample application on the server. If the sample application is not already deployed refer to the instructions for Rebuilding and deploying the WebServicesSamples.ear file.

Running the Sample

Verify that the server has started before running the clients.

The Stock Quote Sample consists of two clients and a single enterprise bean deployed on the server. One client is a simple J2SE client. You can find it in a program named GetQuote. The other is a Java 2 Enterprise Edition (J2EE) client. You can find it in the GetQuoteClient.jar.

Running the J2SE Stock Quote simple client
Running the J2EE Stock Quote application client

Stock Quote clients

The Stock Quote clients query the StockQuote enterprise bean to retrieve current stock quotes from the Web. The StockQuote Web service can return a fixed value or current stock quotes if an Internet connection is available. The first argument to the Stock Quote clients is the target endpoint URL, which specifies the Web service to use. The second argument is the stock symbol. You can use a value of XXX to obtain the fixed price without using an Internet connection.

Running the J2SE Stock Quote simple client

The J2SE Stock Quote client is not container-managed.

For more general instructions on invoking a J2SE WebSphere client, refer to the topic about developing thin application client code in the Info Center.

To run the J2SE Stock Quote simple client from a WebSphere Application Server, perform the following steps, based on your operating system:

  1. Start the server.
  2. Open a command prompt.
  3. Issue the following commands:

    On Windows platforms:

    cd profile_root\bin
    setupCmdLine
    cd install_root\bin
    setupCmdLine

    On Linux, UNIX, and z/OS platforms:

    cd profile_root/bin
    . ./setupCmdLine.sh
    cd install_root/bin
    . ./setupCmdLine.sh

    On iSeries platforms:

    cd profile_root/bin
    . ./setupCmdLine
    cd install_root/bin
    . ./setupCmdLine

  4. Issue the following command:

    On Windows platforms:

    "%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.stock.GetQuote <URL> <symbol>

    On Linux, UNIX, and z/OS platforms:

    "$JAVA_HOME/bin/java" $WAS_LOGGING -classpath "$CLASSPATH:$WAS_CLASSPATH:$WAS_HOME/samples/lib/WebServicesSamples/simpleClients.jar:$WAS_HOME/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.stock.GetQuote <URL> <symbol>

    On iSeries platforms:

    java $JAVA_PARM -classpath "$CLASSPATH:$WAS_CLASSPATH:$WAS_HOME/samples/lib/WebServicesSamples/simpleClients.jar:$WAS_HOME/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.stock.GetQuote <URL> <symbol>

    where:
    <URL> is the service endpoint address http://<host_name>:<port>/StockQuote/services/xmltoday-delayed-quotes where <hostname> is the name of the host (default is localhost) and <port> is the port number (defaut is 9080).
    <symbol> is a stock symbol

    Successful runs of the Stock Quote client on Windows display the following output:

    C:\>"%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.stock.GetQuote http://localhost:9080/StockQuote/services/xmltoday-delayed-quotes XXX
    XXX: 55.25
     
    C:\>"%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.stock.GetQuote http://localhost:9080/StockQuote/services/xmltoday-delayed-quotes DELL
    DELL: 23.67
     
    

Running the J2EE Stock Quote application client

The J2EE application GetQuoteClient.jar is a container managed version of the Stock Quote client.

In the following steps, the variable install_root refers to the WebSphere installation root.

To run the J2EE application Stock Quote client from a WebSphere Application Server, perform the following steps, based on your operating system:

  1. Start the server.
  2. Open a command prompt.
  3. Type the following commands:

    On Windows platforms:

    cd <profile_root>\bin
    setupCmdLine

    On Linux, UNIX and z/OS platforms:

    cd <profile_root>/bin
    . ./setupCmdLine.sh

    On iSeries platforms:

    cd <profile_root>/bin
    . ./setupCmdLine

    where <profile_root> represents the profile installation directory.
  4. Change directory to install_root/samples/lib/WebServicesSamples
    where:
    install_root is the WebSphere Application Server installation root, or the profile installation root if the Sample is rebuilt.
  5. Issue the following command:

    On Windows platfroms:

    <install_root>\bin\launchClient ApplicationClients.ear -CCjar=GetQuoteClient.jar [<URL>] <symbol>

    On Linux, UNIX, and z/OS platforms:

    <install_root>/bin/launchClient.sh ApplicationClients.ear -CCjar=GetQuoteClient.jar [<URL>] <symbol>

    On iSeries platforms:

    <install_root>/bin/launchClient ApplicationClients.ear -CCjar=GetQuoteClient.jar [<URL>] <symbol>

    where:
    <URL> is the service endpoint address http://<host_name>:<port>/StockQuote/services/xmltoday-delayed-quotes where <hostname> is the name of the host (default is localhost) and <port> is the port number (defaut is 9080).
    <symbol> is a stock symbol

    The following example shows two successful runs of the J2EE application stock quote client:

    C:\WebSphere\AppServer\samples>\WebSphere\AppServer\bin\launchClient \WebSphere\AppServer\samples\lib\WebServicesSamples\ApplicationClients.ear -CCjar=GetQuoteClient.jar IBM
    IBM WebSphere Application Server, Release 7.0
    J2EE Application Client Tool
    Copyright IBM Corp., 1997-2008
    WSCL0012I: Processing command line arguments.
    WSCL0013I: Initializing the J2EE Application Client Environment.
    [3/29/06 14:55:22:359 CST] 0000000a  W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=720609:O=0:CT]
              CWPKI0041W: One or more key stores are using the default password.
    WSCL0035I: Initialization of the J2EE Application Client Environment has completed.
    WSCL0014I: Invoking the Application Client class com.ibm.websphere.samples.webservices.stockClient.GetQuote
    IBM: 83.36
     
    C:\WebSphere\AppServer\samples>\WebSphere\AppServer\bin\launchClient \WebSphere\AppServer\samples\lib\WebServicesSamples\ApplicationClients.ear -CCjar=GetQuoteClient.jar XXX
    IBM WebSphere Application Server, Release 7.0
    J2EE Application Client Tool
    Copyright IBM Corp., 1997-2008
    WSCL0012I: Processing command line arguments.
    WSCL0013I: Initializing the J2EE Application Client Environment.
    [3/29/06 15:00:04:062 CST] 0000000a  W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=2171:O=0:CT]
              CWPKI0041W: One or more key stores are using the default password.
    WSCL0035I: Initialization of the J2EE Application Client Environment has completed.
    WSCL0014I: Invoking the Application Client class com.ibm.websphere.samples.webservices.stockClient.GetQuote
    XXX: 55.25
      

You can learn more about how the client and the application work by referring to the Stock Quote tech notes and viewing the Java source code.