WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.iiop.ejb.stateless.cppclient

This directory contains a C++ CORBA client which can be used to call a stateless session bean from WebLogic and to additionally make an outbound call to a Tuxedo server. It also demonstrates using complex java data types with C++. You must have Visibroker 4.1 or 5.0 installed on your machine in order to get the example running. You set the location of visibroker by modifying the iiop.properties located in the WL_HOME/samples/server/src/examples/iiop folder (for example, it would likely be set to INPRISE_HOME=c:/Inprise/vbroker). You also need a C++ compiler; this example used Microsoft Visual C++. Make sure that your PATH is set so that the compiler can be run. The source code for all the RMI-IIOP examples is in your WL_HOME\samples\server\src\examples\iiop directory.

Before you run the client applications in this directory, be sure to build the full example. This includes building the WebLogic Server and, if you wish to run an outbound call to Tuxedo, the Tuxedo Server (iiop/stateless/server/tux) as well.

  • Trader bean and configuring WebLogic Server

  • Setting up and configuring Tuxedo Server

    Be sure to also take a look at the C++ client code.

    Visibroker

    There are many bugs in Visibroker that make configuring your files and environment correctly a difficult process (Note how we must force GIOP version below). This example demonstrates using Visibroker with an EJB, but it also simultaneously demonstrates how difficult this process can be.

    Visibroker 5.0

    You may now also build this example with visibroker 5.0. to do so, you must make the following changes from the instructions below:

    1. You need to specify utf-16/iso-8859-1 as the default native codesets. Change your config.xml within the Server mbean to include the following:

      <Server> <IIOP DefaultCharCodeset="iso-8859-1" DefaultWideCharCodeset="utf-16" Name="myserver"/> </Server>

    2. Do not use GIOP 1.1, and do not use the DefaultMinorVersion entry in your config.xml, this gets specified in the step below.

    3. When running the client you need to use a full corbaloc url (Note the '1.2', which specifies GIOP version. Change:

      Client -ORBInitRef NameService=iioploc://localhost:7001/NameService

      to:

      Client -ORBInitRef NameService=corbaloc:iiop:1.2@localhost:7001/NameService

    Configure WebLogic

    Due to a Visibroker bug in GIOP 1.2 you must force Visibroker to use GIOP 1.1. You can do this by adding the DefaultMinorVersion element to your Server MBean in the config.xml contained in the WL_HOME/samples/server/config/examples directory (also, because we cannot currently force GIOP on Tuxedo, this example only works when calling WebLogic--though you can still make an outbound call from WebLogic to Tuxedo). Below is an example of using the DefaultMinorVersion attribute:
    <Server AcceptBacklog="50" COMEnabled="true" ClusterWeight="1"
            ConsoleInputEnabled="false" DGCIdlePeriodsUntilTimeout="2"
            DefaultProtocol="t3" DefaultSecureProtocol="t3s"
            HttpdEnabled="true" JavaCompiler="C:/bea/jdk131_02/bin/javac"
            ListenPort="7001" Name="examplesServer" NativeIOEnabled="true"
            ServerVersion="7.0.0.0" SocketReaderTimeoutMaxMillis="10"
            TunnelingClientPingSecs="45" TunnelingClientTimeoutSecs="40">
    <IIOP Name="examplesServer" DefaultMinorVersion="1"/>
    </Server>
    

    Build the example

    1. Set up your development shell as described in Setting up your environment.

    2. Execute the build script provided for this example in the samples\examples\iiop\ejb\stateless\cppclient directory of your WebLogic Server installation.

    Run the Example

    1. Make sure you have started the WebLogic Server as per the directions for WL_HOME/samples/server/src/examples/iiop/ejb/stateless/server/wls.

    2. Open a separate command-line window in which you will run the client.

    3. Set up the environment for your client as described in Setting up your environment for building and running the examples.

    4. The build script included in this example also contains the command needed to run the client. Check the build.xml script provided in the examples\iiop\ejb\stateless\cppclient directory to make sure it is using your correct port and hostname. The last section of this xml file contains the run command. Run the client by entering:

      ant run

    5. To run the client and make an outbound call to Tuxedo make sure you have built and properly configured the included components necessary for both the Tuxedo server and WebLogic (examples/iiop/ejb/stateless/server/wls and examples/iiop/ejb/stateless/server/tux). Then run the client application with the following command:
      
       Client -ORBInitRef NameService=iioploc://localhost:7001/NameService true
      

      Enter the correct host and port for your particular configuration

    6. You should see output like the following:
      Getting name service reference
      Narrowing to a naming context
      Resolving the naming context
      Narrowing to the TraderHome
      Buying 100 shares of BEAS
      Bought 100 shares of BEAS
      Buying 200 shares of MSFT
      Bought 200 shares of MSFT
      Buying 300 shares of AMZN
      Bought 300 shares of AMZN
      Buying 400 shares of HWP
      Bought 400 shares of HWP
      

    There's more...

    Read more about WebLogic RMI over IIOP in the Developer Guide, Using WebLogic RMI over IIOP.

    Read more about WebLogic EJB in the Developer Guide, BEA WebLogic Server Enterprise JavaBeans.

    Read more about WebLogic RMI in the Developer Guide, Using WebLogic RMI.

    For more information on how to provide interoperability between WebLogic Server applications and Tuxedo services, see WebLogic Tuxedo Connector.
    Documentation is available at
    http://e-docs.bea.com/wls/docs61


    Copyright © 2002 BEA Systems, Inc. All Rights Reserved.