WTC配置(四)

5测试通信

5.1生成服务端

buildserver -o simpserv -f simpserv.c -s TOUPPER

5.2生成产客户端

buildclient -f tolower.c -o tolower

buildclient -f simpcl.c -o simpcl

5.3引导Tuxedo

tmoot –y

5.4 TuxedoWebLogic的互操作性

APPDIR目录运行tolower客户端,以便调用Tolower EJB,并将结果返回客户端。使用以下命令:

     tolower ALLSMALL

WebLogic Server 服务使用以下命令答复您的Tuxedo 客户端:

     Returned string is: allsmall

5.5 WebLogic应用访问Tuxedo服务

5.5.1编写TuxedoClient.java

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;

       }

}

5.5.2编写tuxedo.jsp

<%@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");

    } elseif (!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方法,执行调用 TuxedoTOUPPER服务的操作,并显示返回的结果: LONGSHINE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值