COM to WebLogic Server Communication

The COM to WebLogic Server communication, illustrated in Figure 20.2, can be performed using the jCOM bridge as the intermediary. Before using the jCOM bridge, it must be enabled in the WebLogic Server using the Administration Console.

Figure 20.2. Block diagram of COM client to WebLogic Server communication.

graphics/20fig02.gif

For example, if you need to access an EJB deployed in WebLogic Server from a Visual Basic client application, you should use the jCOM bridge software as an intermediary between the EJB and the COM client.

After building and deploying the EJB, you need to generate the wrapper files and the IDL file to be used by the COM client. For this purpose, you need to use the java2com tool (shown in Figure 20.3).

Figure 20.3. Screen shot of the java2com tool.

graphics/20fig03.jpg

From the figure, you can see how the wrapper and IDL files are generated. In the dialog box, you will need to supply the home interface name of the EJB that needs to be accessed. Also, provide the public Java classes that will be accessed by the COM client.

The java2com tool will generate an IDL file conforming to a COM IDL file that contains the equivalent COM interfaces for the Java interfaces and Java classes. Apart from this, a set of Java wrapper classes is generated. The Java wrapper classes are used by the jCOM bridge software to perform marshalling, or translation, of data for a Java object or component.

After using the java2com tool and compiling and placing the Java wrapper classes in the CLASSPATH of the WebLogic Server, you will see what is required to be done at the COM client side.

On the COM client side, there are two ways in which the communications between a COM client and the Java components on WebLogic server can be set up.

Zero Client Mode

In a zero client mode, there is no footprint on the COM client side. You need only to hard code the location of the WebLogic Server in the COM client. The location of the WebLogic Server can be obtained by invoking the com servlet from the URL

http://WL_HOST:WL_PORT/bea_wls_internal/com

(WL_HOST is the host name or IP of the machine where WebLogic is installed, and WL_PORT is the port on which the WebLogic Server is listening for requests.)

You can also obtain the location of the WebLogic Server by executing the Java class GetJvmMoniker and passing it the WL_HOST and WL_PORT parameters:

 java com.bea.jcom.GetJvmMoniker WL_HOST WL_PORT  

Executing this command displays a long string of values. This string should be saved and then used in the COM client application.

This location is technically referred to as the Object Reference Moniker (ORM).

Early Binding

The second way to establish communications between the COM client and the WebLogic Server is to use the IDL files generated by the java2com tool. This mechanism is called early binding because the IDL file will be used at the COM client side to process and generate information necessary for the COM client. Now, you will take a quick look at the steps involved in the early binding mechansim.

First the IDL files generated using the java2com tool need to be processed to generate the type library. To process the IDL files, you need a COM IDL file processor. An example of this is the midl.exe compiler available in Visual C++:

 midl mysams.idl  

This will generate the mysams.tlb type library file.

The next step is to register the WebLogic Server's Java Virtual Machine (JVM) in the Windows registry using a logical name. Use the regjvm utility (or the command-line version, regjvmcmd) to do this.

The regjvm command starts up the regjvm GUI tool. Select the DCOM-pure java option, and provide the WebLogic Server name and port number on which it is listening. After this, provide a name for the registered JVm, such as mysamsjvm.

Now you can register the type library generated from the IDL file and the JVM name from the previous step in the Windows registry. This is done using the regtlb utility provided as a part of the jCOM bridge software, as follows:

 regtlb  mysams.tlb mysamsjvm  

The COM client is all set to access the Java objects/components deployed in WebLogic Server. A snippet of a generated IDL file is given here:

 [      uuid(7bc904b3-00ee-1000-5000-c0a801640000),     version(1.0),     helpstring("MyCOMWaiterHome generated from             com.sams.learnweblogic7.ejb.stateful.WaiterHome (J-Integra)") ] library MyCOMWaiterHome { importlib("STDOLE2.TLB"); //  Forward declare all types defined in this IDL file interface ComSamsLearnweblogic7EjbStatefulChefInterface; interface IComSamsLearnweblogic7EjbStatefulCookedItemImpl; coclass ComSamsLearnweblogic7EjbStatefulCookedItemImpl; interface ComSamsLearnweblogic7EjbStatefulMenuItem; interface ComSamsLearnweblogic7EjbStatefulMenuList; interface ComSamsLearnweblogic7EjbStatefulWaiterHome; interface ComSamsLearnweblogic7EjbStatefulWaiterInterface; interface JavaUtilCollection; interface JavaUtilEnumeration; interface JavaUtilIterator; interface JavaUtilList; interface JavaUtilListIterator; interface JavaUtilMap; interface JavaUtilSet; interface IJavaUtilVector; coclass JavaUtilVector; interface JavaxEjbEJBHome; interface JavaxEjbEJBMetaData; interface JavaxEjbEJBObject; interface JavaxEjbHandle; interface JavaxEjbHomeHandle; ... 


Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

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