通过wtc使tuxedo与weblogic通信开发 联系客服

发布时间 : 星期二 文章通过wtc使tuxedo与weblogic通信开发更新完毕开始阅读

关键函数介绍:

Public int selectService ();

连接weblogic server,调用具体的函数调用tuxedo service.

Public int callTestService(String service_name);

根据输入参数学号,调用tuxedo service,获得返回结果学生姓名和年龄.

关键函数代码

函数selectService

import weblogic.wtc.jatmi.Ferror;

import weblogic.wtc.jatmi.TypedFML32;

import weblogic.wtc.jatmi.CallDescriptor;

Public int selectService ()

{

try

{

…连接weblogic server…………

obj = ctx.lookup(ejb的jndiname);

}

catch (Exception e)

{

…………………

}

wtcHome=(WtcInstanceHome)javax.rmi.PortableRemoteObject.narrow(obj, WtcInstanceHome.class);

try

{

wtcRemote = wtcHome.create();

}

catch (Exception e)

{

………….

}

callTestService(service_name);

try

{

wtcRemote.remove();

}

catch (Exception e)

{

………………

}

}

函数callTestService

public String callTestService (String service_name)

{

CallDescriptor tuxRtn = null;

TypedFML32 inParams = null, tuxResult = null;

try

{

//创建fml32缓冲区java描述类的实例

inParams = new TypedFML32(new student_fld());

//填写输入参数:学号

inParams.Fchg(student_fld.student_id , 0, getStudentId());

}

catch (Ferror e)

{

……

}

try

{ //异步调用tuxedo service.

tuxRtn = wtcRemote.Tpacall(service_name, inParams);

}

catch (Exception e)

{

………

}

try

{ //等待异步调用的service返回结果.

tuxResult = wtcRemote.Tpgetrply(tuxRtn);

}

catch (Exception e)

{

………

}

try

{

//得到学生的姓名和年龄…

stuName = (String)tuxResult.Fget(student_fld.student_name, 0);

stuAge = (Integer) tuxResult.Fget(student_fld.student_age, 0);

}

catch (Ferror e)

{

………

}

………

}