分类:
2008-04-07 10:46:27
buildserver -o simpserv -f simpserv.c -s TOUPPER
buildclient -f tolower.c -o tolower
buildclient -f simpcl.c -o simpcl
tmoot –y
从APPDIR目录运行tolower客户端,以便调用Tolower EJB,并将结果返回客户端。使用以下命令:
tolower ALLSMALL
WebLogic Server 服务使用以下命令答复您的Tuxedo 客户端:
Returned string is: allsmall
package org.flying.ejb.client;
import weblogic.wtc.jatmi.*;
import weblogic.wtc.gwt.*;
import javax.naming.*;
public class TuxedoClient {
public String getUpper(String inStr) {
String outStr = "";
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();
}
return outStr;
}
}
<%@page language="java" contentType="text/html; charset=GB2312"%>
<jsp:useBean id="mytuxedo" scope="session"
class="org.flying.ejb.client.TuxedoClient">jsp:useBean>
<% String str = "";
String id = request.getParameter("id");
if (id == null) {
str = mytuxedo.getUpper("longshine");
} else if (!id.equals("")) {
str = mytuxedo.getUpper(id);
}
%>
<html>
<body bgcolor="#cccccc">
<form name="f1" action="tuxedo.jsp" method="post">
<table width=60% align="center">
<tr>
<td>
小写字母:
<input name=id value=<%=id%> size=15>
td>
<td>
Tuxedo返回大写字母:<%=str%>td>
tr>
<tr>
<td>
<br>
<br>
td>
tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="查询">
td>
tr>
table>
form>
body>
html>
JSP页面tuxedo.jsp调用javabean mytuxedo 的getUpper方法,执行调用Tuxedo的TOUPPER服务的操作,并显示返回的结果:LONGSHINE。