由於在嘗試用BCB 4訪問NameService時,遇到了一些奇奇怪怪的問題,而Visibroker所帶的例子卻可以用bcc32正常編譯運行,俺決定從頭做一個程序看看問題出在哪裡。折騰了一夜,結論是做還是不用Corba Server wizard好。(我還是不明白為什麼?)
1、File| New, Multitier,Corba IDL File:
interface Order{
string Name();
};
存為order.idl
2、File|New, Consol Wizard,生成一個無vcl支持的consol應用。
3、Project|Add to project,選上剛寫的order.idl,Project | Compile之。
4、File|New, Miltitier, Corba Object Implementation,IDL選剛寫的order.idl,Interface選Order,為簡明起見,其它的名字就不改了。確定,自動生成OrderServer.cpp。
5、在OrderServer.cpp中找到char* OrderImpl::Name(),在其函數體中寫:
return "Hi, I am Test CorbaServer";
6、File | Save All,Unit1.cpp存為tcnServer.cpp,Project存為tcnServer.bpr。然後Make之。一個簡單的Corba Server就做好了。
7、測試運行一下,然後在MS-Dos方式下運行osfind.exe(應該在path裡,否則到$(VBroker)\bin裡找),這時會顯示一系列的corba信息:
C:\>osfind
osfind: Found one agent at port 14000
HOST: YANGWU
osfind: Found 1 OADs in your domain
HOST: YANGWU
osfind: Following are the list of Implementations registered with OADs.
HOST: YANGWU
REPOSITORY ID: IDL:CorbaTester/DBServer2Factory:1.0
OBJECT NAME: DBServer2
osfind: Following are the list of Implementations started manually.
HOST: YANGWU
REPOSITORY ID: IDL:Order:1.0
OBJECT NAME: OrderObject
REPOSITORY ID: IDL:visigenic.com/Activation/OAD:1.0
OBJECT NAME: 61.132.58.166