一. 调用方式
二. WTC配置步骤:
1. Tuxedo的配置
2.1.1. 设置环境变量:
2.1.2. 编写Tuxedo服务(atmi)
2.1.3. 配置ubbconfig
2.1.4. 编译ubbconfig文件
2.1.5. 配置domconfig
2.1.6. 编译domconfig
2. Weblogic配置(7.0以上的版本)
2.1.7. 配置config.xml
3. Weblogic做客户端,访问Tuxedo服务
4. Tuxedo做客户端,访问Weblogic服务
三. JOLT配置步骤:
1. Tuxedo的配置
3.1.1. 配置ubbconfig
3.1.2. 注册tuxedo service
2. Weblogic的配置
3.1.3. 配置jolt pool
3.1.4. 配置startup class, shutdown class
3. 程序调用例子
四. CORBA的调用步骤:
1. 获得IDL,并且根据IDL生成java class
2. 配置config.xml文件
3. 程序调用例子
BEA公司的TUXEDO,WEBLOGIC作为优秀的中间件产品,在银行、电信、金融等行业广泛使用,通常采用TUXEDO实现系统的核心业务,用WEBLOGIC做为系统扩展到INTERNET的平台,实现电子商务,由WEBLOGIC调用TUXEDO上的服务,所以TUXEDO与WEBLOGIC之间的互连经常遇到。
一. 调用方式
WEBLOGIC与TUXEDO的调用有三种方式
1. WTC(WEBLOGIC TUXEDO CONNECTOR)
2. JOLT
3. CORBA(Common Object Request Broker Architecture)
WTC不仅能让WEBLOGIC调用TUXEDO中的SERVICE,而且能让TUXEDO调用WEBLOGIC中的EJB,但是只能用于WEBLOGIC与TUXEDO之间进行互连。
JOLT只能让WEBLOGIC调用TUXEDO. 但JOLT可以使TUXEDO与WEBSPERE等其他应用服务器相连。
CORBA是通用对象请求代理体系结构(Common Object Request Broker Architecture) 的英文缩写,这是标准化组织OMG提出的一种实现分布式异构环境下面向对象软件的可重用、可移植、可互操作的体系结构。只要符合CORBA规范的服务器之间都可以互联。
二. WTC配置步骤:
1. Tuxedo的配置
2.1.1. 设置环境变量:
set TUXDIR=C:\bea\tuxedo8.0
set APPDIR=C:\bea\tuxedo8.0\samples\atmi\simpapp
set PATH=%TUXDIR%\bin;%APPDIR%;%PATH%
set TUXCONFIG=%APPDIR%\tuxconfig 编译之后生成的2进制配置文件. tuxconfig
set BDMCONFIG=%APPDIR%\bdmconfig编译之后生成的2进制配置文件. bdmconfig
2.1.2. 编写Tuxedo服务(atmi)
#include <stdio.h>
#include <ctype.h>
#include <atmi.h> /* TUXEDO Header File */
#include <userlog.h> /* TUXEDO Header File */
/* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
*/
#if defined(__STDC__) defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
/* Some compilers warn if argc and argv aren't used. */
argc = argc;
argv = argv;
/* userlog writes to the central TUXEDO message log */
userlog("Welcome to the simple server");
return(0);
}
/* This function performs the actual service requested by the client.
Its argument is a structure containing among other things a pointer
to the data buffer, and the length of the data buffer.
*/
#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) defined(__cplusplus)
TOUPPER(TPSVCINFO *rqst)
#else
TOUPPER(rqst)
TPSVCINFO *rqst;
#endif
{
int i;
for(i = 0; i < rqst->len-1; i++)
rqst->data[i] = toupper(rqst->data[i]);
/* Return the transformed buffer to the requestor. */
tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}
2.1.3. 配置ubbconfig
*RESOURCES
IPCKEY 123456
DOMAINID simpapp
MASTER simple
MAXACCESSERS 50
MAXSERVERS 25
MAXSERVICES 50
MODEL SHM
LDBAL N
*MACHINES
"SZ-XJS-DUANW"
LMID=simple
APPDIR="C:/bea/tuxedo8.0/samples/atmi/simpapp"
TUXCONFIG="C:/bea/tuxedo8.0/samples/atmi/simpapp/tuxconfig"
TUXDIR="C:/bea/tuxedo8.0"
*GROUPS
GROUP1
LMID=simple GRPNO=1 OPENINFO=NONE
GROUP2
LMID=simple GRPNO=2 OPENINFO=NONE
*SERVERS
simpserv SRVGRP=GROUP1 SRVID=1
/* simpserv编译生成的可执行文件名字*/
DMADM SRVGRP=GROUP2 SRVID=2
/*域间通信的进程:管理域的server,在运行时管理BDMCONFIG,对已登记的gateway group提供支持,在tuxedo系统中,只能有一个DMADM进程,且不能对它采用MSSQ,不能有REPLYQ.*/
GWADM SRVGRP=GROUP2 SRVID=3
/*管理域的域网关进程,在运行时可以对某一组域网关进行管理,主要从DMADM那里取得域的配置信息,并对域网管进程及跨越域的全局事务的LOG文件进行管理.*/
GWTDOMAIN SRVGRP=GROUP2 SRVID=4
/*处理域之前的互操作,使本地域和调用远程域可以互相调用彼此的service,其中GMADM和GWTDOMAIN必须在一个组中,一个tuxedo应用可以有多个GWADM,GWTDOMAIN对,一个组只能有一个GMADM,GWTDOMAIN对,但一个tuxedo应用只能有一个DMADM,DMADM可以在如何一个组中,一个本地域可以和多个远程域实现互操作. */
*SERVICES
TOUPPER
/* TOUPPER是simpserv文件中的函数名字, 该函数就被发布为属于server: simpserv中的一个tuxedo service*/
2.1.4. 编译ubbconfig文件
Tmloadcf ?y ubbconfig
2.1.5. 配置domconfig
*DM_RESOURCES
VERSION=U22
*DM_LOCAL_DOMAINS
/*DM_LOCAL_DOMAINS定义本地tuxedo域的信息,分别定义该域所在的组,域类型,域的唯一标识,域间通信时日志的全路径,其中GWGRP, DOMAINID的值要与ubb文件中的定义匹配.*/
TDOM1 GWGRP=GROUP2
TYPE=TDOMAIN
DOMAINID="TDOM1"
BLOCKTIME=20
MAXDATALEN=56
MAXRDOM=89
DMTLOGDEV="C:/bea/tuxedo8.0/samples/atmi/simpapp/TLOG"
AUDITLOG="C:/bea/tuxedo8.0/samples/atmi/simpapp/AUDITLOG"
DMTLOGNAME="DMTLOG_TUXDOM"
*DM_REMOTE_DOMAINS
/*DM_REMOTE_DOMAINS定义远程weblogic域的信息,分别定义域类型,域的唯一性标识,该id标识需要与在weblogic server中的配置名称吻合,否则通信将会失败*/
TDOM2 TYPE=TDOMAIN
DOMAINID="TDOM2"
*DM_TDOMAIN
/*DM_TDOMAIN定义在DM_LOCAL_DOMAIN中已经说明的本地域和在DM_REMOTE_DOMAINS中已经说明的远程域的具体的通信ip地址以及通信端口,其中NWDEVICE指定tuxedo发布的server通信进程文件所在的路径*/
TDOM1 NWADDR="//10.16.73.31:9998"
TDOM2 NWADDR="//10.16.73.31:9999"
*DM_REMOTE_SERVICES
/*DM_REMOTE_SERVICES定义当前域需要调用远程域的服务名称*/
TOLOWER RDOM="TDOM2"
*DM_LOCAL_SERVICES
/* DM_LOCAL_SERVICES定义当前域对外发布的tuxedo service名称,可以通过RNAME重新命名service;该service可以被其他域中的服务调用*/
TOUPPER RNAME=" TOUPPER "
2.1.6. 编译domconfig
dmloadcf ?y domconfig
2. Weblogic配置(7.0以上的版本)
2.1.7. 配置config.xml
<WTCServer Name="MyWTCServer" Targets="myserver">
<WTCExport EJBName="wtcservice" LocalAccessPoint="TDOM2" Name="WTCExport-1111629542315" ResourceName="TOLOWER"/>
<WTCImport LocalAccessPoint="TDOM2" Name="WTCImport-1111634013933" RemoteAccessPointList="TDOM1" ResourceName="TOUPPER"/>
<WTCLocalTuxDom AccessPoint="TDOM2" AccessPointId="TDOM2" NWAddr="//10.16.73.31:9999" Name="WTCLocalTuxDom-1111629491418"/>
<WTCRemoteTuxDom AccessPoint="TDOM1" AccessPointId="TDOM1" LocalAccessPoint="TDOM2" NWAddr="//10.16.73.31:9998" Name="WTCRemoteTuxDom-1111629517202"/>
</WTCServer>
WTCLocalTuxDom中的AccessPointId与在tuxedo dm文件中*DM_REMOTE_DOMAINS节中指定的domainid相同;NWAddr与*DM_TDOMAIN节中相应的NWADDR相同
WTCRemoteTuxDom中的AccessPointId与在tuxedo dm文件中*DM_REMOTE_DOMAINS节中指定的domainid相同;NWAddr与*DM_TDOMAIN节中相应的NWADDR相同
WTCImport中的ResourceName与在tuxedo ubb文件中SERVICES节点中指定的服务名相同;RemoteName与在tuxedo dm文件中* DM_LOCAL_SERVICES节中发布的服务名相同(可以省略)
WTCImport中的ResourceName与在tuxedo dm文件中DM_REMOTE_SERVICES节点中指定的服务名相同
3. Weblogic做客户端,访问Tuxedo服务
import="weblogic.wtc.jatmi.;
import="weblogic.wtc.gwt.*;
import="javax.naming.*;
import="java.sql.;
try
{
//调用接口服务
Context ctx = new InitialContext();
TuxedoConnectionFactory cdmaTuxedoFactory = (TuxedoConnectionFactory) ctx.lookup("tuxedo.services.TuxedoConnection");
TuxedoConnection cdmaTuxedo = cdmaTuxedoFactory.getTuxedoConnection();
TypedString cdmaData = new TypedString(inStr);
Reply cdmaRtn = cdmaTuxedo.tpcall("TOUPPER", cdmaData, 0);
cdmaData = (TypedString) cdmaRtn.getReplyBuffer();
outStr = cdmaData.toString();
cdmaTuxedo.tpterm();
}
catch(Exception e)
{
outStr = e.getMessage();
}
4. Tuxedo做客户端,访问Weblogic服务
#include <stdio.h>
#include "atmi.h" /* TUXEDO Header File */
#if defined(__STDC__) defined(__cplusplus)
main(int argc, char *argv[])
#else
main(argc, argv)
int argc;
char *argv[];
#endif
{
char *sendbuf, *rcvbuf;
long sendlen, rcvlen;
int ret;
if(argc != 2) {
(void) fprintf(stderr, "Usage: simpcl string\n");
exit(1);
}
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failed\n");
exit(1);
}
sendlen = strlen(argv[1]);
/* Allocate STRING buffers for the request and the reply */
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}
if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating receive buffer\n");
tpfree(sendbuf);
tpterm();
exit(1);
}
(void) strcpy(sendbuf, argv[1]);
/* Request the service TOUPPER TOLOWER, waiting for a reply */
ret = tpcall("TOLOWER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);
if(ret == -1) {
(void) fprintf(stderr, "Can't send request to service TOLOWER\n");
(void) fprintf(stderr, "Tperrno = %d\n", tperrno);
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(1);
}
(void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
return(0);
}
三. JOLT配置步骤:
1. Tuxedo的配置
3.1.1. 配置ubbconfig
在ubb文件*GROUPS节点中增加如下2个tuxedo group:
JSLGRP LMID=simple GRPNO=5 OPENINFO=NONE
JREPGRP LMID=simple GRPNO=6 OPENINFO=NONE
在ubb文件*SERVERS节点中增加如下2个tuxedo server:
JSL SRVGRP=JSLGRP SRVID=22210 CLOPT="-A -- -n //tuxedoserver_ip:port -m 5 -M 10 -x 5"
JREPSVR SRVGRP=JREPGRP SRVID=22220 CLOPT="-A -- -W -P $(TUXDIR)/udataobj/jolt/repository/jrepository"
在ubb文件*MACHINES节点中增加MAXWSCLIENTS=10
*RESOURCES
IPCKEY 123456
DOMAINID simpapp
MASTER simple
MAXACCESSERS 50
MAXSERVERS 25
MAXSERVICES 50
MODEL SHM
LDBAL N
*MACHINES
"SZ-XJS-DUANW"
LMID=simple
APPDIR="C:/bea/tuxedo8.0/samples/simpapp"
TUXCONFIG="C:/bea/tuxedo8.0/samples/simpapp/tuxconfig"
TUXDIR="C:/bea/tuxedo8.0"
MAXWSCLIENTS=10
*GROUPS
GROUP1
LMID=simple GRPNO=1 OPENINFO=NONE
GROUP2
LMID=simple GRPNO=2 OPENINFO=NONE
JSLGRP
LMID=simple GRPNO=5 OPENINFO=NONE
JREPGRP
LMID=simple GRPNO=6 OPENINFO=NONE
*SERVERS
simpserv SRVGRP=GROUP1 SRVID=1
DMADM SRVGRP=GROUP2 SRVID=2
GWADM SRVGRP=GROUP2 SRVID=3
GWTDOMAIN SRVGRP=GROUP2 SRVID=4
JSL SRVGRP=JSLGRP SRVID=10 CLOPT="-A -- -n //10.16.73.31:9000 -m 5 -M 10 -x 5"
JREPSVR SRVGRP=JREPGRP SRVID=20 CLOPT="-A -- -W -P C:/bea/tuxedo8.0/udataobj/jolt/repository/jrepository"
/**当通过jolt实现tuxedo,weblogic互连时,JSL,JREPSVR是在tuxedo中必须发布启动的2个server*/
*SERVICES
TOUPPER
3.1.2. 注册tuxedo service
打开Tuxedo安装目录下的udataobj/jolt/子目录下RE.html文件,其中包含java applet,可通过appletviewer RE.html命令启动该文件,该applet可以接收用户输入,并在jrepository中注册tuxedo service以及service的输入输出参数等等,只有注册之后才能通过jolt访问tuxedo service.
2. Weblogic的配置
3.1.3. 配置jolt pool
<JoltConnectionPool FailoverAddresses="//10.16.73.31:9000"
Name="MyJoltPool" PrimaryAddresses="//10.16.73.31:9000" Targets="myserver"/>
/*//10.16.73.31:9000是ubbconfig中JSL指定的地址。
*/
3.1.4. 配置startup class, shutdown class
<ShutdownClass
ClassName="bea.jolt.pool.servlet.weblogic.PoolManagerShutDown"
Name="MyJoltPoolShutdown" Targets="myserver"/>
<StartupClass
ClassName="bea.jolt.pool.servlet.weblogic.PoolManagerStartUp"
Name="MyJoltPoolStart" Targets="myserver"/>
3. 程序调用例子
import bea.jolt.pool.SessionPoolManager;
import bea.jolt.pool.servlet.ServletResult;
import bea.jolt.pool.servlet.ServletSessionPool;
import bea.jolt.pool.ServiceException;
import weblogic.utils.http.QueryParams;
import weblogic.servlet.internal.ServletRequestImpl;
import bea.jolt.pool.ServiceException;
import com.beasys.BootstrapFactory;
import java.util.Properties;
import javax.naming.InitialContext;
String inStr = "dw";
try
{
SessionPoolManager b_mgr = SessionPoolManager.poolmgr;
ServletSessionPool servletSessionPool = (ServletSessionPool) b_mgr.getSessionPool("MyJoltPool");
//构造request
ServletRequestImpl impl = new ServletRequestImpl();
QueryParams q = new QueryParams();
q.put("name", inStr);
impl.setQueryParams(q);
ServletResult servletResult = servletSessionPool.call("TOUPPER", impl, null);
String name = (String) servletResult.getValue("name", 0, "");
}
catch (Exception e)
{
e.printStackTrace();
}
四. CORBA的调用步骤:
1. 获得IDL,并且根据IDL生成java class
2. 配置config.xml文件
<WLECConnectionPool FailoverAddresses="//10.1.10.51:3842"
MaximumPoolSize="10" Name="Sys97WLEPool"
PrimaryAddresses="//10.1.10.51:3842"
Targets="myserver"
WLEDomain="etelecom_server"/>
3. 程序调用例子
import org.omg.CORBA.*;
import com.beasys.*;
import com.beasys.Tobj.*;
//初始化ORB和BEA的Bootstrap,获得FactoryFinder的对象引用.
Properties prop = new Properties(System.getProperties());
prop.put("org.omg.CORBA.ORBClass", "com.beasys.CORBA.iiop.ORB");
prop.put("org.omg.CORBA.ORBSingletonClass", "com.beasys.CORBA.idl.ORBSingleton");
String[] args = null;
ORB orb = ORB.init(args, prop);
//为提高性能,从指定的连接池中获取Tobj_Bootstrap
Tobj_Bootstrap bootstrap = BootstrapFactory.getClientContext("Sys97WLEPool");
//如果从WLEC连接池获取Tobj_Bootstrap失败,则根据指定的确CORBA服务器IP和端口初始化Tobj_Bootstrap
if (bootstrap == null)
Tobj_Bootstrap bootstrap = new Tobj_Bootstrap(orb, "corbaloc://10.1.10.27:3842");
org.omg.CORBA.Object factory_finder_oref =
bootstrap.resolve_initial_references("FactoryFinder");
FactoryFinder factory_finder_ref = FactoryFinderHelper.narrow(factory_finder_oref);
//实例化后台系统的CB_Service操作接口
org.omg.CORBA.Object srv_factory_ref =
factory_finder_ref.find_one_factory_by_id(FindFactoryHelper.id());
FindFactory find_factory = FindFactoryHelper.narrow(srv_factory_ref);
CB_BondService service = find_factory.find_CB_BondService();
StringHolder outXml = new StringHolder();
String inXml="";
service.businessProcess(inXml,outXml);
System.out.println("outXml:"+outXml.value);