Cics中Java调用的两种方式

在Cics中 , Java调用分两种方式 , ECI and EPI .

External Call Interface(ECI) 即是一种类似于元过程调用( RPC), CICS Client 端通过 ECI 调用就可以把 CICS Server 端的交易程序叫起来运行,运行结束后再返回 CICS Client
External Presentation Interface(EPI), CICS Client 端模仿了一个 CICS Server 的终端, CICS Client 程序与 CICS Server 程序间交换的是3270的数据流 .
这些都自己去理解, 网上关于掉用的文档都很坑爹,没代码说个飞机啊!!!
 
首先我们需要知道在java中 , cics需要支持的jar文件, ctgclient.jar ,还要知道基本的调用类.
  JavaGateway javaGateway = null;
  EPIRequest epiRequest = null;
  ECIRequest eciRequest=null;
  //字面上意思很容易理解啊
  //ECI调用: 
	/**
	 * ECI request
	 * @param para
	 * @return
	 * @throws Exception
	 */
	public static DataBean eciRequest(CicsParameter para,DataBean databean) throws Exception{
		JavaGateway javaGateway=null;
		ECIRequest eciRequest=null;
		int iReturnCode;
		CICSResult result = new CICSResult();
		//Should delete first three bytes
		//byte[] commArea=new byte[8192];	
		//INIT buffer
		for (int i=0;i
//EPI调用
 
   

 /**   * EPI request   * @param para   * @return   * @throws Exception   */  public static DataBean epiRequest(CicsParameter para,DataBean databean) throws Exception{   JavaGateway javaGateway = null;   EPIRequest epiRequest = null;   int iReturnCode =0;   CICSResult result = new CICSResult();   try {    javaGateway = new JavaGateway();    javaGateway.setURL(para.getjGateURL());    javaGateway.setPort(para.getjGatePort());    javaGateway.open();    epiRequest = EPIRequest.addTerminal(para.getServerName(), null, "vt100");    iReturnCode = javaGateway.flow(epiRequest);    if (iReturnCode != EPIRequest.EPI_NORMAL)     EpiPublic.logEpiErrorAndException("main - addTerminal - javaGateway.flow", iReturnCode);        epiRequest.startTran(para.getServsId(), databean.getSendMsg(), databean.getSendMsg().length);    iReturnCode = javaGateway.flow(epiRequest);    if (iReturnCode != EPIRequest.EPI_NORMAL)     EpiPublic.logEpiErrorAndException("main - startTran - javaGateway.flow", iReturnCode);    // wait until service end    int num = 1;    do {     epiRequest.getEvent(EPIRequest.EPI_WAIT,ByteArray.BUFFER_SIZE_MAX);     iReturnCode = javaGateway.flow(epiRequest);     ///     exception test     ///     if(iReturnCode == EPIRequest.EPI_ERR_MORE_DATA){      log.debug("epiRequest.event=EPI_ERR_MORE_DATA");      log.debug("iReturnCode=" + iReturnCode+",num="+num);      if(num>=5){       EpiPublic.logEpiErrorAndException("main - getEvent - javaGateway.flow", iReturnCode);      }      num++;      continue;     }     ///     exception test     ///     if (iReturnCode != EPIRequest.EPI_NORMAL       && iReturnCode != EPIRequest.EPI_ERR_MORE_EVENTS) {      log.debug("iReturnCode=" + iReturnCode);      EpiPublic.logEpiErrorAndException("main - getEvent - javaGateway.flow", iReturnCode);     }     switch (epiRequest.event) {     case EPIRequest.EPI_EVENT_SEND:      log.debug("epiRequest.event=EPI_EVENT_SEND");      result.setMsg(new ByteArray(epiRequest.data, 2, epiRequest.size - 2));      break;

    case EPIRequest.EPI_EVENT_END_TRAN:      log.debug(        "epiRequest.event=EPI_EVENT_END_TRAN");      break;

    default:      log.debug("epiRequest.event=?");      EpiPublic.printEpiEventData(epiRequest);      break;     }    } while (epiRequest.event != EPIRequest.EPI_EVENT_END_TRAN);

   epiRequest.delTerminal();    iReturnCode = javaGateway.flow(epiRequest);    if (iReturnCode != EPIRequest.EPI_NORMAL)     EpiPublic.logEpiErrorAndException("main - delTerminal - javaGateway.flow", iReturnCode);    // wait until terminal end    do {     epiRequest.getEvent(EPIRequest.EPI_WAIT,       ByteArray.BUFFER_SIZE_MAX);     iReturnCode = javaGateway.flow(epiRequest);     if (iReturnCode != EPIRequest.EPI_NORMAL       && iReturnCode != EPIRequest.EPI_ERR_MORE_EVENTS)      EpiPublic.logEpiErrorAndException(        "main - getEvent - javaGateway.flow", iReturnCode);

    switch (epiRequest.event) {     case EPIRequest.EPI_EVENT_END_TERM:      if (epiRequest.endReason != EPIRequest.EPI_END_SIGNOFF) // what       // we       // expected       // is       // EPI_END_SIGNOFF       EpiPublic.printEpiEventData(epiRequest);      break;

    default:      EpiPublic.printEpiEventData(epiRequest);      break;     }    } while (epiRequest.event != EPIRequest.EPI_EVENT_END_TERM);    //close    javaGateway.close();   } catch (Exception ex) {    log.debug(ex);    throw ex ;   }finally  {       try       {        if (javaGateway != null)        {         javaGateway.close();         log.debug("Successfully closed JavaGateway");        }       } catch (Exception eClose)       {        log.error("Exception during close : " + eClose);       }             }      if (result.getMsg() == null){    log.info(" ReceiveMessage rm is null.");    return null;   }else    databean.setReceiveMsg(result.getMsg().getValue());      return databean ;  }

//懂不懂看个人啦, 自己慢慢看

你可能感兴趣的:(Cics中Java调用的两种方式)