- COMPLEX 메시지 정의의 www.complex.net 네임스페이스에서 다음과 같은 구조의
addev6in 및 addev6out 메시지를 작성하십시오.
addev6in
hexdata (xsd:hexBinary) local element
addev6out
decval (xsd:decimal) local element
fltval (xsd:float) local element
intval (xsd:int) local element
- MQInput > Mapping > MQOutput 맵핑을 포함하는 addev6 메시지 플로우를 작성하십시오.
- 맵을 열고 addev6in을 소스로, addev6out을 대상으로 선택하십시오.
- MAPPING3_COMPLEX_flows 프로젝트에서 addev6이라는 ESQL 파일을 작성하고
여기에 다음 함수를 넣으십시오.
CREATE PROCEDURE decFromBinary( IN hexval BLOB )
RETURNS DECIMAL
LANGUAGE JAVA
EXTERNAL NAME "addev6.decFromBinary";
CREATE PROCEDURE fltFromBinary( IN hexval BLOB )
RETURNS DECIMAL
LANGUAGE JAVA
EXTERNAL NAME "addev6.fltFromBinary";
CREATE PROCEDURE intFromBinary( IN hexval BLOB )
RETURNS DECIMAL
LANGUAGE JAVA
EXTERNAL NAME "addev6.intFromBinary";
- 다음 컨텐츠를 가진 addev6.java Java 소스 파일을 작성하십시오.
import java.lang.*;
import java.math.*;
public class addev6 {
//
// Return decimal element from binary string
//
public static BigDecimal decFromBinary( byte[] hexval) {
// Look for element named decval
String search = "decval";
String snval = findElement(hexval ,search );
// Convert the value to decimal type
BigDecimal numval = new BigDecimal(snval);
return numval;
}
//
// Return float element from binary string
//
public static Double fltFromBinary( byte[] hexval) {
// Look for element named fltval
String search = "fltval";
String snval = findElement(hexval ,search );
// Convert the value to float type
Double numval = new Double(snval);
return numval;
}
//
// Return integer element from binary string
//
public static Long intFromBinary( byte[] hexval) {
// Look for element named intval
String search = "intval";
String snval = findElement(hexval ,search );
// Convert the value to integer type
Long numval = new Long(snval);
return numval;
}
//
// Locate the named element and its value in the binary data
//
private static String findElement( byte[] hexval, String search ) {
// Convert bytes to string
String hexstr = new String(hexval);
// Fixed length label/value pairs (length=14)
int nvals = hexstr.length() / 14;
String numval = "";
String[] label = new String[nvals];
String[] value = new String[nvals];
// Loop over number of label/value pairs
for ( int i=0; i < nvals; i ++ ) {
// get start position
int st = i * 14;
// label is length 6
int endl = st + 6;
// value is length 8
int endv = endl + 8;
// extract label and value from string
label[i] = hexstr.substring( st, endl);
value[i] = hexstr.substring( (endl+1), endv);
// Check whether the current pair has the label requested
if ( label[i].compareTo( search) == 0 ) {
// trim padding from the value
numval = value[i].trim();
}
}
return numval;
}
}
- Java 코드를 컴파일하고 시스템 CLASSPATH에 클래스 파일의 위치를
추가하십시오. Windows를 재시작해야 할 수도 있습니다.
- 메시지 맵핑 편집기의 스프레드시트 분할창에서 대상 메시지를 펼치고
decval 대상 값을 esql:decFromBinary($source/comp:addev6in/bval)로 설정하십시오.
- fltval 대상을 esql:fltFromBinary($source/comp:addev6in/bval)로 설정하십시오.
- intval 대상을 esql:intFromBinary($source/comp:addev6in/bval)로 설정하십시오.
- 등록 정보 대상을 펼치고 다음과 같은 값을 설정하십시오.
MessageType | 'addev6out
- 적절한 RFH2 헤더를 사용하여 다음 인스턴스 메시지를 작성하십시오.
<comp:addev6in xmlns:comp="http://www.complex.net">
<bval>
<![CDATA[64656376616c20202031342e3238666c7476616c
2020312e34452b32696e7476616c2020202020313230]]>
</bval>
</comp:addev6in>
이제 메시지 세트 및 메시지 플로우를 전개하십시오.