|
The Developer's Resource & Community Site
|
Coding a DCOM Client
Author: Gopalan Suresh Raj
Date Submitted: February 10th 2000
Level of Difficulty: Advanced
Subjects Covered: IDL, DCOM, J++
Pre-required Reading: Component Object Model, Coding a DCOM Server Component from IDL
To work with any of these samples you will need the following:
- Microsoft Visual J++ ver 6.0
The Steps involved in developing the DCOM Client are
- Add a new project StockDCOMClient to the StockDCOM project
- Add COM wrapper of SimpleStocks to StockDCOMClient
- Add code to Form1.java
- Build and run the client
Add a new project StockDCOMClient to the StockDCOM project
From Project Explorer | Solution | Add Project | Applications | Windows Application | Name: StockDCOMClient
From Project Explorer | StockDCOMClient | StockDCOMClient Properties | ClassPath uncheck the "Merge all Project-specific ClassPaths in solution" check box.
2. Add COM wrapper of SimpleStocks to StockDCOMClient
From Project Explorer | StockDCOMClient | Add | COM Wrapper check the checkbox listed with "SimpleStocks 1.0 Type Library".
Click "OK" to confirm list of COM Wrappers. Notice that the stockmarketlib folder was created under the StockDCOMClient project.
Notice the java source files that have been generated: StockMarket.java and IStockMarket.java
3. Add code to Form1.java
Form1.java |
import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*; /**
* This class can take a variable number of
parameters on the command
* line. Program execution begins with the main()
method. The class
* constructor is not invoked unless an object of
type 'Form1' is
* created in the main() method.
*/
public class Form1 extends Form {
String editValue = null;
/**
* TODO: make sure all your
constructors/initialization code
* paths have the following line:
* initForm();
*/
public Form1() {
// Required for Visual J++ Form Designer support
initForm();
// TODO: Add any constructor code after initForm call
}
/**
* Form1 overrides dispose so it can clean up
the
* component list.
*
* TODO: have dispose call
* components.dispose();
*/
public void dispose() {
super.dispose();
components.dispose();
}
private void edit1_Leave(Object source, Event e) {
String editValue = edit1.getText();
try {
stockmarketlib.IStockMarket market =
(stockmarketlib.IStockMarket)new
stockmarketlib.StockMarket();
String str = "$
"+market.get_price(editValue);
edit2.setText(str);
System.out.println(
"The price of "+editValue+" is " + market.get_price(editValue)
);
}
catch (com.ms.com.ComFailException
exception) {
System.out.println(
"COM Exception:" );
}
}
private void button1_click(Object source, Event e) {
System.exit(0);
}
/**
* NOTE: The following code is required by
the Visual J++ form
* designer. It can be modified using
the form editor. Do not
* modify it using the code editor.
*/
Container components = new Container();
Label label1 = new Label();
Edit edit1 = new Edit();
Label label2 = new Label();
Edit edit2 = new Edit();
Button button1 = new Button();
private void initForm() {
this.setText("StockDCOM
Client");
this.setAutoScaleBaseSize(new Point(5,
13));
this.setClientSize(new Point(292,
157));
label1.setLocation(new Point(8, 32));
label1.setSize(new Point(136, 16));
label1.setTabIndex(0);
label1.setTabStop(false);
label1.setText("Enter the Stock
Symbol");
edit1.setLocation(new Point(168, 32));
edit1.setSize(new Point(100, 20));
edit1.setTabIndex(1);
edit1.setText("MY_COMPANY");
edit1.addOnLeave(new
EventHandler(this.edit1_Leave));
label2.setLocation(new Point(8, 80));
label2.setSize(new Point(128, 23));
label2.setTabIndex(2);
label2.setTabStop(false);
label2.setText("Price of my
company is");
edit2.setLocation(new Point(168, 72));
edit2.setSize(new Point(100, 20));
edit2.setTabIndex(3);
edit2.setText("$ 0.0");
edit2.setReadOnly(true);
button1.setLocation(new Point(112, 120));
button1.setSize(new Point(75, 23));
button1.setTabIndex(4);
button1.setText("Exit");
button1.addOnClick(new
EventHandler(this.button1_click));
this.setNewControls(new Control[] {
button1,
edit2,
label2,
edit1,
label1});
}
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to
the application
* via the command line.
*/
public static void main(String args[]) {
Application.run(new Form1());
}
}
|
4. Build and run the client
What do you think of this article?
You can also write a review. We will publish the best ones here on this article. Send your review to [email protected].
Mail a question to the author!!
As part of the IDevResource commitment to Open Publishing, all of our authors are available to answer all of your trickiest questions at Author Central. For information about the authors, or to mail a question, visit them at Author Central.
Want to read more articles by this author?
Try these:
Byte size articles:
COM Threading Models By Gopalan Suresh Raj, 070200
Gopalan explains the differences in COM and Win 32 threading models.
Go To Article.
ActiveX & COM By Gopalan Suresh Raj, 270100
Gopalan explains the basics of ActiveX / COM as a truly distributed Object Oriented Architecture.
Go To Article.
Full size articles:
COM Channel:
Java COM Integration - Use Visual J++ to implement COM Objects By Gopalan Suresh Raj.
Go To Article.
Developing an MSMQ Server Application using VJ++ By Gopalan Suresh Raj.
Go To Article.
Developing an MSMQ Client using VJ++ By Gopalan Suresh Raj.
Go To Article.
Coding a DCOM Server Component from IDL By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: February 10th 2000
Level of Difficulty: Advanced
Subjects Covered: IDL, DCOM, J++
Pre-required Reading: Component Object Model
Coding a DCOM Client By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: February 10th 2000
Level of Difficulty: Advanced
Subjects Covered: IDL, DCOM, J++
Pre-required Reading: Component Object Model, Coding a DCOM Server Component from IDL
Microsoft Transaction Server By Gopalan Suresh Raj.
Gopalans introductory article on Microsoft Transaction Server intorduces the basics to MTS, and leads in to the example articles included in the series.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: None
Developing a Simple MTS Server Component By Gopalan Suresh Raj.
Part 1 of a two part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server
Developing a Simple MTS Client Application By Gopalan Suresh Raj.
Part 2 of a two part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing a Simple MTS Server Component
Developing The Bank Account IDL By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - Developing The Bank Account IDL is part 1 of a 3 part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server
MTS Server Component By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - MTS Server Component is the second part of this three part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing The Bank Account IDL
MTS Client By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - MTS Server Component is the third part of this three part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing The Bank Account IDL, MTS Server Component
Java Channel:
Enterprise Java Beans By Gopalan Suresh Raj.
In this introduction to Enterprise Java Beans, Gopalan covers the bases then goes on to demonstrate how to build server side business object components. This article is the introduction to Gopalan's series of Enterprise JavaBeans articles. (This series of articles is © Copyright 1997-2000 Gopalan Suresh Raj. Reproduced with Permission)
Author: Gopalan Suresh Raj
Date Submitted: January 6th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Architecture, Java Naming and Directory Interface, Java Transaction Service.
Pre-required Reading: None
Enterprise Java Beans Series - Components at the Server By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server side components, CORBA
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Model By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Containers, EJB Clients.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Naming Services and JNDI By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Naming Services, Java Naming Directory Interface
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Transactions and JTS By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Java Transaction Service, Two-phase commits
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Lifecycle By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB server provider, EJB container provider, EJB developer, EJB deployer, Application developer.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Servers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server Infrastructure
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Containers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Containers, EJB Servers
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Components By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Object, Home Object, Remote Object
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Session Beans By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Stateful Session Beans, Stateless Session Beans
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Entity Beans By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Container-Managed Persistence, Bean-Managed Persistence
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an Entity Bean By Gopalan Suresh Raj.
Part 1 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Entity Beans, Home & Remote Interfaces, Data Sources.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing a Session Bean By Gopalan Suresh Raj.
Part 2 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Session Beans, Home & Remote Interfaces, Deployment Descriptors.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Client By Gopalan Suresh Raj.
Part 3 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Clients.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Servlet Client By Gopalan Suresh Raj.
Part 4 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Servlet Clients.
Pre-required Reading: Enterprise JavaBeans
More COM Library articles:
CAtlBitmapButton - ATL/WTL Ownerdraw Superclassed Bitmap Button By Amit Dey.
Amit describes building a simple user interface consisting of a series of bitmap buttons in a dialog.
Author: Amit Dey
Date Submitted: June 8 2001
ATL COM and ADO By Paddy Srinivas.
COM+ Events addresses many shortcomings of Connection points. Paddy Srinivas walks us through the COM+ Events System.
Author: Paddy Srinivas
Date Submitted: March 7 2001
ATL COM and ADO By Amit Dey.
New author Amit Dey (he's looking for a job BTW ;-) ) explains his recent experiences with ATL COM and ADO. He simply explains the fundamentals of ADO and then runs through some ATL code examples in his application.
Author: Amit Dey
Date Submitted: March 6 2001
COM Singletons: A Dangerous Animal By Richard Blewett.
Richard Blewitt simply explains the use of COM Singletons.
Author: Richard Blewett
Date Submitted: January 24 2001
ASP COM Objects By Jan Verhoeven.
Creating ASP com objects, or Active Server Objects with Delphi 5 is very easy, once you know how to do it.
Author: Jan Verhoeven
Date Submitted: November 1 2000
SafeArrays - For the Beginner By A. Abdul Azeez.
This article is a primer to Safe Arrays and can be used by any beginner to Safe Arrays.
Author: A. Abdul Azeez
Date Submitted: November 1 2000
COM+ Basics - Creating your first COM+ Application By Martin Lapierre.
Author: Martin Lapierre
Date Submitted: June 1 2000
COM+ - the backbone of Windows DNA By Mahesh Bhide.
Author: Mahesh Bhide
Date Submitted: June 1 2000
Exploring COM Threading and Apartments By Anthony Toivonen.
Anthony Toivonen wants you to figure it out for yourself: he guarantees success in threads and apartments after reading this article.
Author: Anthony Toivonen
Date Submitted: May 17th 2000
COM on Linux By Frank Rem.
A description of how to code a DCOM client for Linux without using Microsoft products.
Author: Frank Rem
Date Submitted: May 17th 2000
ATL Server By Richard Grimes.
A description of ATL Server.
Author: Richard Grimes
Date Submitted: May 9th 2000
ATL Internals - Part 2 By Shivesh Viswanathan.
Following on from Shivesh's first article of this two part series, this article covers the details of the internals of ATL.
Author: Shivesh Viswanathan
Date Submitted: May 3rd 2000
How to use DDX with WTL By Girish Bharadwaj.
Author: Girish Bharadwaj
Date Submitted: March 27th 2000
COM Patterns By Tony Toivonen.
Author: Tony Toivonen
Date Submitted: March 27th 2000
COM+ Object Pooling By Jeremiah Talkar.
Author: Jeremiah Talkar
Date Submitted: March 23rd 2000
What are COM Pipes? By Richard Grimes.
Author: Richard Grimes
Date Submitted: March 23rd 2000
Java COM Integration - Use Visual J++ to implement COM Objects By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: March 9th 2000
Developing an MSMQ Server Application using VJ++ By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: March 9th 2000
Developing an MSMQ Client using VJ++ By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: March 9th 2000
What is Async COM? By Richard Grimes.
Author: Richard Grimes
Date Submitted: March 8th 2000
Coding a DCOM Server Component from IDL By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: February 10th 2000
Level of Difficulty: Advanced
Subjects Covered: IDL, DCOM, J++
Pre-required Reading: Component Object Model
Coding a DCOM Client By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: February 10th 2000
Level of Difficulty: Advanced
Subjects Covered: IDL, DCOM, J++
Pre-required Reading: Component Object Model, Coding a DCOM Server Component from IDL
Threads and Apartments By Brad Wilson.
Brad's article gives detailed information about apartments and their relationship to threading and synchronization. The goal is to demystify what is a very important, yet under-documented system in COM.
Author: Brad Wilson
Date Submitted: Feb 04 2000
Level of Difficulty: Intermediate
Subjects Covered: Single Threaded Apartments, Multi Threaded Apartments, Apartments.
Pre-required Reading:
WTL Architecture By Richard Grimes.
This article covers the basics of the WTL architecture, it describes the types of applications that you can create and how WTL manages threads. The example monitors the debug stream and uses WTL to present this data.
Author: Richard Grimes
Date Submitted: Feb 02 2000
Level of Difficulty: Intermediate
Subjects Covered: WTL applications architecture, WTL UI update, OutputDebugString and debugging API
Pre-required Reading: assumes a knowledge of ATL and of Win32 application development (for example "Professional ATL COM Programming", Richard Grimes, Wrox Press)
The MTS Series by Gopalan Suresh Raj:
Microsoft Transaction Server By Gopalan Suresh Raj.
Gopalans introductory article on Microsoft Transaction Server introduces the basics to MTS, and leads in to the example articles included in the series.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: None
Developing a Simple MTS Server Component By Gopalan Suresh Raj.
Part 1 of a two part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server
Developing a Simple MTS Client Application By Gopalan Suresh Raj.
Part 2 of a two part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing a Simple MTS Server Component
Developing The Bank Account IDL By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - Developing The Bank Account IDL is part 1 of a 3 part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server
MTS Server Component By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - MTS Server Component is the second part of this three part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing The Bank Account IDL
MTS Client By Gopalan Suresh Raj.
A Three-Tier Architecture for a Bank Checking Account - MTS Server Component is the third part of this three part example.
Author: Gopalan Suresh Raj
Date Submitted: Jan 26 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: MTS
Pre-required Reading: Microsoft Transaction Server, Developing The Bank Account IDL, MTS Server Component
Other Articles
Active Template Library: Architecture & Internals By Shivesh Viswanathan.
Active Template Library is basically a set of template classes provided by Microsoft for writing COM components. The time to write COM components can be considerably reduced if they are written using the ATL framework. The document here provides theory of what goes inside ATL to implement certain generic interfaces.
Author: Shivesh Viswanathan
Date Submitted: Jan 21 2000
Level of Difficulty: Beginners / Intermediate
Subjects Covered: ATL
Pre-required Reading: None
Microsoft Transaction Server By Richard Grimes.
Introduces Microsoft Transaction Server
Author: Richard Grimes
Date Submitted: Dec 09 1999
Level of Difficulty: Beginners
Subjects Covered: MTS, VB
Pre-required Reading: None
What COM is all about By Richard Grimes.
An introductory article to COM, covering all basics including OLE, Activex and DLL's.
Level of difficulty: Beginner
Subjects Covered: COM
Pre-required reading: None
String Binding Moniker By Frank Rem.
This article shows how a SB Moniker resolves a connection with a DCE RP server running on Linux using a VB client.
Level of difficulty: Intermediate
Languages covered: COM
Pre-required reading: None
Author: Gopalan Suresh Raj
Gopalan Suresh Raj is a Software Architect, Developer and an active Author.
He is contributing author to a couple of books "Enterprise JavaComputing-Applications and Architecture"(Cambridge University Press, June '99) and "TheAwesome Power of JavaBeans"(Manning, July'98).
His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia site (https://www.execpc.com/~gopalan)or mail him at [email protected].
Go to Gopalan's pages in Author Central.
|