// look up srvService
SrvSessionService srvService = this.getSrvSessionServiceByServiceName(serviceName);
String sessionId = reqMessage.getSessionId();
// create scMessage
SCMessage scMessage = new SCMessage();
scMessage.setData(reqMessage.getBody());
scMessage.setDataLength(reqMessage.getBodyLength());
scMessage.setCompressed(reqMessage.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
scMessage.setMessageInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
scMessage.setSessionId(sessionId);
scMessage.setSessionInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
scMessage.setServiceName(reqMessage.getServiceName());
int oti = Integer.parseInt(reqMessage.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT));
// inform callback with scMessages
SCMessage scReply = srvService.getCallback().createSession(scMessage, oti);
// set up reply
SCMPMessage reply = new SCMPMessage();
if (scReply != null) {
reply.setBody(scReply.getData());
if (scReply.isCompressed()) {
reply.setHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION);
}
if (scReply.getAppErrorCode() != Constants.EMPTY_APP_ERROR_CODE) {
reply.setHeader(SCMPHeaderAttributeKey.APP_ERROR_CODE, scReply.getAppErrorCode());
}
if (scReply.getAppErrorText() != null) {
reply.setHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT, scReply.getAppErrorText());
}
if (scReply.isReject()) {
// session rejected
reply.setHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION);
} else {
// create session in SCMPSessionCompositeRegistry
SrvCommandAdapter.sessionCompositeRegistry.addSession(sessionId);
// handling msgSequenceNr
SCMPMessageSequenceNr msgSequenceNr = SrvCommandAdapter.sessionCompositeRegistry.getSCMPMsgSequenceNr(sessionId);
reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
}
if (scReply.getSessionInfo() != null) {
reply.setHeader(SCMPHeaderAttributeKey.SESSION_INFO, scReply.getSessionInfo());
}
}
reply.setSessionId(reqMessage.getSessionId());
reply.setServiceName(serviceName);
reply.setMessageType(this.getKey());