BEA公司的TUXEDO,WEBLOGIC作为优秀的中间件产品,在银行、电信、金融等行业广泛使用,通常采用TUXEDO实现系统的核心业务,用WEBLOGIC做为系统扩展到INTERNET的平台,实现电子商务,由WEBLOGIC调用TUXEDO上的服务,所以TUXEDO与WEBLOGIC之间的互连经常遇到。
因为在工作中经常用到,先就个人总结和网上收集的资料总结如下,惠人惠己。
#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
<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相同
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配置步骤:
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的调用步骤:
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);