The following describes how to configure the WTC service in weblogic.
Package test;
Import java. RMI. RemoteException;
Import javax. Naming. context;
Import javax. Naming. initialcontext;
Import javax. Naming. namingexception;
Import weblogic. WTC. GWT. tuxedoconnection;
Import weblogic. WTC. GWT. tuxedoconnectionfactory;
Import weblogic. WTC. jatmi. reply;
Import weblogic. WTC. jatmi. tpexception;
Import weblogic. WTC. jatmi. tpreplyexception;
Import weblogic. WTC. jatmi. typedstring;
Public class wtccaller {
/**
* Function: run the call command to return the result.
*
* @ Param servicename
* Service name, which may take the following values: the service configured in WTC, that is, the configuration in import
* @ Param Command refers to the Command sent
** @ Return returns the result value (that is, the value returned by tuxedo)
* @ Throws tpexception
* @ Throws tpreplyexception
*/
Public String execute (string servicename, string command)
Throws tpexception, tpreplyexception, RemoteException {
Context CTX;
Tuxedoconnectionfactory TCF;
Tuxedoconnection mytux;
Typedstring mydata;
Reply myrtn = NULL;
Try {
CTX = new initialcontext ();
Tcf = (tuxedoconnectionfactory) CTX
. Lookup ("tuxedo. Services. tuxedoconnection ");
} Catch (namingexception ne ){
String errorstr = "the tuxedo service cannot be connected. Specific error:" + Ne;
Throw new tpexception (tpexception. tpenoent, errorstr );
}
Mytux = TCF. gettuxedoconnection ();
Mydata = new typedstring (command );
Try {
Myrtn = mytux. tpcall (servicename, mydata, 0 );
} Catch (tpreplyexception tre ){
System. Out. println ("error occur ");
Throw tre;
} Catch (tpexception Te ){
System. Out. println ("error occur ");
Te. printstacktrace ();
Throw Te;
} Catch (exception ee ){
String errorstr = "An error occurred while calling the tuxedo service. Specific error:" + EE;
Throw new tpexception (tpexception. tpesystem, errorstr );
}
If (myrtn! = NULL ){
Mydata = (typedstring) myrtn. getreplybuffer ();
Mytux. tpterm ();
}
// System. Out. Print (mydata. tostring ());
Return ("value:" + mydata. tostring ());
}
}