지정된 요소의 비트스트림 표현을 가져옵니다. 요소와 연관된 구문 분석기는 요소 및 모든 하위 요소를 직렬화합니다. 결과는 호출자가 할당한 메모리에 복사됩니다. 지정된 모든 옵션이 원본 비트스트림 옵션과 일치하며(예: MQInput 노드가 WebSphere MQ 큐에서 읽은 비트스트림의 경우) 원본 비트스트림을 수신한 이후 메시지가 수정되지 않은 특수한 경우, 이 원본 비트스트림은 사용자가 할당한 메모리로 복사됩니다. 이 경우, 메시지를 구문 분석하고 다시 직렬화하기 위해 구문 분석기가 필요하지 않습니다.
그러므로 이러한 등록 정보를 판별하는 알고리즘은 기본적으로 ESQL BITSTREAM 함수에 사용되는 알고리즘과 같습니다.
일부 구문 분석기는 다른 FolderBitStream 모드도 지원합니다. 이 모드에서는 가리키는 필드가 폴더를 나타낼 경우 하위 트리의 유용한 비트스트림을 생성합니다.
CciSize cniElementAsBitstream( int* returnCode, CciElement* element, const struct CciByteArray* value, CciChar* messageType, CciChar* messageSet, CciChar* messageFormat, int encoding, int ccsid, int options);
다음 예에서는 옵션 매개변수를 사용하여 메시지 트리의 다른 부분에 대한 비트스트림을 생성하는 방법을 보여줍니다.
MQMD RFH2 <test><data><stuff>things</stuff></data></test>노드는 세 개의 메시지를 전달하는 데 그 중 하나는 BLOB 도메인에 입력 메시지의 사본이 포함되어 있습니다. 다른 메시지는 BLOB 도메인에 입력 RFH2의 사본을 메시지 본문으로 포함하고 있습니다. 또 다른 메시지는 BLOB 도메인에 <data></data> 폴더를 메시지 본문으로 포함하고 있습니다.
CciMessage* outMsg[3]; CciTerminal* terminalObject; CciElement* bodyChild; CciElement* inRootElement; CciElement* inSourceElement[3]; CciElement* outRootElement; CciElement* outBlobElement; CciElement* outBody; struct CciByteArray bitstream[3]; int bitstreamOptions[3]; int retvalue; int rc = 0; int loopCount; CCI_EXCEPTION_ST exception_st = {CCI_EXCEPTION_ST_DEFAULT}; const CciChar* constBLOBParserName = cciString("NONE",BIP_DEF_COMP_CCSID); const CciChar* constBLOBElementName = cciString("BLOB",BIP_DEF_COMP_CCSID); const CciChar* constEmptyString = cciString("",BIP_DEF_COMP_CCSID); /*3 출력 메시지 빌드 및 전달*/ /*첫번째 메시지에는 입력 메시지 본문에 대한 비트스트림이 있음*/ /*두 번째 메시지에는 입력 RFH2에 대한 비트스트림이 있음*/ /*세 번째 메시지에는 입력 메시지의 하위 요소에 대한 비트스트림이 있음*/ /* 입력 메시지의 루트 요소 가져오기*/ inRootElement=cniRootElement(&rc, message); /*CCI_CHECK_RC();*/ checkRC(rc); /*소스 요소 및 비트스트림 옵션 배열 설정*/ /*메시지 본문*/ inSourceElement[0] = cniLastChild(&rc,inRootElement); checkRC(rc); /*메시지 본문의 루트이므로 RootBitStream 모드를 사용함*/ bitstreamOptions[0] = CCI_BITSTREAM_OPTIONS_ROOT; /*마지막 헤더*/ inSourceElement[1] = cniPreviousSibling(&rc,inSourceElement[0]); checkRC(rc); /*RFH2의 루트이므로 RootBitStream 모드를 사용함*/ bitstreamOptions[1] = CCI_BITSTREAM_OPTIONS_ROOT; /*body.FIRST(메시지 본문의 첫번째 하위) */ inSourceElement[2] = cniFirstChild(&rc,inSourceElement[0]); checkRC(rc); /*body.FIRST.FIRST */ inSourceElement[2] = cniFirstChild(&rc,inSourceElement[2]); checkRC(rc); /*메시지 본문 내의 하위 트리이므로 FolderBitStream 모드를 사용함*/ bitstreamOptions[2] = CCI_BITSTREAM_OPTIONS_FOLDER; for (loopCount=0;loopCount<3;loopCount++) { int bufLength; /* 출력에 대한 새 메시지 작성 */ outMsg[loopCount] = cniCreateMessage(&rc, cniGetMessageContext(&rc, message)); checkRC(rc); /* 출력 메시지의 루트 요소 가져오기*/ outRootElement = cniRootElement(&rc, outMsg[loopCount]); checkRC(rc); /* 출력 메시지로 입력 메시지의 컨텐츠 복사 */ cniCopyElementTree(&rc, inRootElement, outRootElement); checkRC(rc); /* 루트의 마지막 하위(즉, 본문) 가져오기 */ bodyChild = cniLastChild(&rc, outRootElement); checkRC(rc); /*입력 메시지에서 복사된 메시지 본문 삭제*/ cniDetach(&rc, bodyChild); checkRC(rc); /*BLOB 도메인에서 새 출력 메시지 본문 작성*/ outBody = cniCreateElementAsLastChildUsingParser(&rc, outRootElement, constBLOBParserName); checkRC(rc); /*BLOB 요소 작성*/ outBlobElement = cniCreateElementAsLastChild(&rc, outBody); checkRC(rc); cniSetElementName(&rc, outBlobElement, constBLOBElementName); checkRC(rc); /*요소에 대한 비트스트림을 확보하여 BLOB 요소 값 설정 */ bitstream[loopCount].size=512; bitstream[loopCount].pointer=(CciByte*)malloc(sizeof(CciByte) * 512); bufLength = cniElementAsBitstream(&rc, inSourceElement[loopCount], &bitstream[loopCount], constEmptyString,/*assume XML message so no interest in*/ constEmptyString,/* type, set or format*/ constEmptyString, 0,/*Use Queue Manager CCSID & Encoding*/ 0, bitstreamOptions[loopCount]); if (rc==CCI_BUFFER_TOO_SMALL) { free(bitstream[loopCount].pointer); bitstream[loopCount].size=bufLength; bitstream[loopCount].pointer=(CciByte*)malloc(sizeof(CciByte) * bitstream[loopCount].size); bufLength = cniElementAsBitstream(&rc, inSourceElement[loopCount], &bitstream[loopCount], constEmptyString,/*assume XML message so no interest in*/ constEmptyString,/* type, set or format*/ constEmptyString, 0,/*Use Queue Manager CCSID & Encoding*/ 0, bitstreamOptions[loopCount]); } checkRC(rc); bitstream[loopCount].size=bufLength; cniSetElementByteArrayValue(&rc, outBlobElement, &bitstream[loopCount]); checkRC(rc); } /* 출력 터미널 처리 가져오기 */ terminalObject = getOutputTerminalHandle( (NODE_CONTEXT_ST *)context, (CciChar*)constOut); /* 터미널이 있고 접속된 경우 터미널로 전달함 */ if (terminalObject) { if (cniIsTerminalAttached(&rc, terminalObject)) { /* 새 메시지 및 변경된 메시지의 경우 ...로 끝나야 함 */ cniFinalize(&rc, outMsg[0], CCI_FINALIZE_NONE); cniFinalize(&rc, outMsg[1], CCI_FINALIZE_NONE); cniFinalize(&rc, outMsg[2], CCI_FINALIZE_NONE); retvalue = cniPropagate(&rc, terminalObject, destinationList, exceptionList, outMsg[0]); retvalue = cniPropagate(&rc, terminalObject, destinationList, exceptionList, outMsg[1]); retvalue = cniPropagate(&rc, terminalObject, destinationList, exceptionList, outMsg[2]); if (retvalue == CCI_FAILURE) { if (rc == CCI_EXCEPTION) { /* Get details of the exception */ memset(&exception_st, 0, sizeof(exception_st)); cciGetLastExceptionData(&rc, &exception_st); /* 로컬 오류 처리할 수 있음 */ /* 리턴/삭제 전에 메시지가 삭제되었는지 확인하십시오. */ cniDeleteMessage(0, outMsg[0]); cniDeleteMessage(0, outMsg[1]); cniDeleteMessage(0, outMsg[2]); /* 예외를 "다시 전달"해야 함; 리턴하지 않음 */ cciRethrowLastException(&rc); } else { /* 기타 오류...플러그인은 CciLog() 유틸리티 함수를 사용하여 로그할 */ /* 수 있음 */ } } else { } } } else { /* 터미널이 없음...심각한 내부 오류. 플러그인은 cciLog() 유틸리티 */ /* 함수를 사용하여 여기에서 오류를 로그할 수 있습니다. */ } /* Delete the messages we created now we have finished with them */ cniDeleteMessage(0, outMsg[0]); cniDeleteMessage(0, outMsg[1]); cniDeleteMessage(0, outMsg[2]); free((void*) constBLOBParserName); free((void*) constBLOBElementName); free((void*) constEmptyString); return;