본문으로 건너뛰기
버전: 3.4.4

요청응답구분프로그램

프로그램용도구현할 Java인터페이스적용할 설정화면
사용자호출프로그램RequestAndResponseDistinction기본설정관리>기관별업무정보, 기본설정관리>시스템별업무정보

공통부 전문의 요청/응답을 구분하는 방법은 매우 다양하다.

기관의 경우 전문종별/업무코드의 조합으로 판단되기도 하고, 전문의 특정필드 또는 송수신 커넥션을 구분하여 처리되기도 한다. 따라서 요청응답구분 프로그램은 각 기관/시스템별로 프로그램을 개발하여 적용해야 한다.

해당 프로그램은 필수 커스터마이징 프로그램이다.

개발방법

제공되는 인터페이스에는 공통부를 내부 처리 전문인 Map 방식으로 변환한 후 호출하는 API와, 수신한 전문 그대로 호출하는 API가 있다.

Map방식으로 변환한 후 호출하는 API

해당 예제는 Map에서 종별코드 msgCbtpCd 필드의 값을 조회하여 세번째 값이 0이면 요청이고 아니면 응답으로 판단한다.

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, Map<String, Object> header) {
// 1) Field lookup in Map
String msgType = (String) header.get("msgCbtpCd");
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

☑ 입력

  • bxiMessage : 전문 처리에 필요한 정보가 저장되어 있는 항목
  • header : 헤더부를 Unmarshal한 Map 형식의 헤더부 데이터

☑ 출력

  • RequestResponseKindEnum 값으로 요청은 REQUEST, 응답은 RESPONSE 반환

수신받은 전문 데이터로 호출하는 API

해당 예제는 대외에서 수신한 전문에서 종별코드 위치의 값을 조회하고, 종별코드의 세번째 값이 0이면 요청, 0이 아니면 응답으로 판단한다.

헤더부를 Unmarshal하기 전 데이터로 요청응답을 구분하는 API이다.

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, String message) {
// 1) Separate data from field positions in the text
String msgType = message.substring(18, 22);
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

☑ 입력

  • bxiMessage : 해당 전문 처리에 필요한 정보가 저장되어 있는 항목
  • message : 수신한 전문 데이터

☑ 출력

  • RequestResponseKindEnum 값으로 요청은 REQUEST, 응답은 RESPONSE 반환

전체 예제

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import bxi.api.RequestAndResponseDistinction;
import bxi.common.enums.RequestResponseKindEnum;
import bxi.common.model.ExchangeMessage;

@Component
public class RequestAndResponseDistinctionImpl implements RequestAndResponseDistinction {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, Map<String, Object> header) {
// 1) Field lookup in Map
String msgType = (String) header.get("msgCbtpCd");
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}

@Override
public RequestResponseKindEnum distinction(ExchangeMessage bxiMessage, String message) {
// 1) Separate data from field positions in the text
String msgType = message.substring(18, 22);
logger.debug("msgType : {}", msgType);

// 2) If the third field of the field is 0, it is request specific.
return ("0".equals(msgType.substring(2, 3))) ? RequestResponseKindEnum.REQUEST
: RequestResponseKindEnum.RESPONSE;
}
}