Use Java to call the WTC Service

Source: Internet
Author: User

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 ());
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.