Liberty 최적화 로컬 어댑터 API를 사용하여 외부 주소 공간에서 서비스 호출

WebSphere® 최적화 로컬 어댑터(WOLA) API를 사용하여 Liberty 서버의 외부 주소 공간 또는 서브시스템에서 서비스를 호출할 수 있습니다.

시작하기 전에

최적화 로컬 어댑터를 사용하여 Liberty 애플리케이션에서 외부 주소 공간의 애플리케이션에 연결에서 설명하는 대로 애플리케이션을 외부 주소 공간 또는 서브시스템에 연결하십시오.

Rational® Application Developer CICS®/IMS™ Java™ 데이터 바인딩 마법사에서 생성된 레코드 데이터를 전달하려면 우선 생성된 레코드 데이터를 연결이 사용할 수 있도록 해야 합니다. 추가 정보는 Liberty에서 아웃바운드 최적화 로컬 어댑터 연결에서 생성된 레코드 데이터 사용의 내용을 참조하십시오.

프로시저

  1. 애플리케이션에서, 작성한 연결 오브젝트로부터 상호작용을 작성하십시오. 다음 예제는 con 연결 오브젝트에서 int 상호작용을 작성합니다.
    Interaction int = con.createInteraction();
  2. InteractionSpecImpl 오브젝트를 작성하고 서비스 이름(외부 주소 공간 또는 서브시스템에서 호출할 메소드의 이름)을 제공하여 상호작용 스펙을 작성하십시오. 서비스 이름은 모든 요청 수신, 특정 요청 수신 또는 호스트 서비스 API를 호출할 때 설정한 이름이어야 하며, CICS(Customer Information Control System) 서버 태스크를 사용 중인 경우에는 해당 CICS 프로그램의 이름이어야 합니다. 다음 예제는 isi InteractionSpecImpl 오브젝트에 MYSERVICE 서비스 이름을 제공합니다.
    InteractionSpecImpl isi = new InteractionSpecImpl();
    isi.setServiceName("MYSERVICE");
  3. 상호작용 스펙으로 상호작용을 실행하십시오. 다음 예제는 isi 상호작용 스펙으로 int 상호작용을 실행하고 데이터를 전송하지 않습니다.
    int.execute(isi, null);

다음 예제는 바이트 배열(byte[])로 입력 및 출력 데이터가 있는 상호작용을 시작하는 방법을 나타냅니다.
public byte[] driveInteraction(javax.resource.cci.ConnectionFactory cf,
javax.resource.cci.Connection con,byte[] inputDataBytes),throws javax.resource.ResourceException
	{
	// Create an interaction using the optimized local adapter connection
		 javax.resource.cci.Interaction i = con.createInteraction();
	// The InteractionSpec describes the service we want to call
		 com.ibm.websphere.ola.InteractionSpecImpl isi = new com.ibm.websphere.ola.InteractionSpecImpl();
		 isi.setServiceName("MYSERVICE");
	// The input data is specified using an IndexedRecord.  The first
	// slot in the indexed record contains the input data bytes.
		 javax.resource.cci.RecordFactory rf = cf.getRecordFactory();
		 javax.resource.cci.IndexedRecord ir = rf.createIndexedRecord(null);
		 ir.add(inputDataBytes);
		 		 
	// The interaction returns another IndexedRecord, whose first
	// slot contains the output data bytes.
		 javax.resource.cci.Record or = i.execute(isi, ir);
		 byte[] outputDataBytes = null;
		 		 
		 if (or != null)
		 {
		 		 outputDataBytes = (byte[])((javax.resource.cci.IndexedRecord)or).get(0);
		 }
		 		 
	// Return the output data to the caller 
			return outputDataBytes;
		 }

다음 예제는 Rational Application Developer가 생성한 카피북 Record 오브젝트를 사용하여 상호작용을 시작하는 방법을 보여줍니다. .

 /**
  * An example of driving an optimized local adapter interaction, using a Rational 
  * Application Developer copybook mapping class as input (inputRecord) and receiving
  * a Rational Application Developer copybook mapping as output.
	*/		 
			public javax.resource.cci.Record driveInteraction(
		 	javax.resource.cci.Connection con,
		 	javax.resource.cci.Record inputRecord)
		 	throws javax.resource.ResourceException
	  {
	// Create an interaction using the OLA connection
		 	javax.resource.cci.Interaction i = con.createInteraction();
	// The InteractionSpec describes the service we want to call com.ibm.websphere.ola.InteractionSpecImpl isi = 
		 new com.ibm.websphere.ola.InteractionSpecImpl();
		 isi.setServiceName("MYSERVICE");
	// The Rational Application Developer generated copybook implements 
	// javax.resource.cci.Record and can be passed directly to the interaction.
	// The interaction returns an IndexedRecord, whose first slot contains 
  // the output data bytes.
		 	javax.resource.cci.Record or = i.execute(isi, inputRecord);
		 	javax.resource.cci.Record outputRecord = null;
		 	if (or != null)
		 {
	// In this example, RADGeneratedOutputType is the name of the Rational Application Developer
  // generated copybook mapping class.
		 	outputRecord = new RADGeneratedOutputType();
 // The output bytes are stored in the output record returned on the
 // interaction, which is an IndexedRecord.
		 byte[] outputDataBytes = 
     (byte[])((javax.resource.cci.IndexedRecord)or).get(0);
		 		 		 
 // To convert the output bytes to another Rational Application Developer generated copybook, 
 // call the setBytes(byte[]) method of that class.  The class will 
 // implement the  com.ibm.etools.marshall.RecordBytes interface.
		 ((com.ibm.etools.marshall.RecordBytes)outputRecord)
        .setBytes(outputDataBytes);
		 }
		 		 
// Return the output data to the caller
		 		 return outputRecord;
		 }

주제의 유형을 표시하는 아이콘 태스크 주제

파일 이름: twlp_dat_useoutboundconnection.html