Beispiel #1
0
  public void call(Exchange exchange, Message in, Message out) {
    ProcessContext pc = new ProcessContext(exchange);
    JBFHelper jbfHelper = new JBFHelper(properties);
    jbfHelper.setBalanced(balanced);
    jbfHelper.setIgnoreFaultStrings(ignoreFaultStrings);

    // OPEN SESSION
    logger.debug("-- JBFCaller -- Opening session");
    int openSession = jbfHelper.openSession();
    if (handleError(openSession, jbfHelper, pc, exchange, in, out)) return;

    // CALL
    logger.debug("-- JBFCaller -- Calling WS");
    jbfHelper.setJbfRequest(in.getBodyText());
    int call = jbfHelper.callWS();
    if (handleError(call, jbfHelper, pc, exchange, in, out)) return;

    out.setHeader(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.OK);
    pc.setVariable(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.OK);
    out.setBodyText(jbfHelper.getJbfResponse());

    // CLOSE SESSION
    logger.debug("-- JBFCaller -- Closing session");
    int closeSession = jbfHelper.closeSession();
    if (handleError(closeSession, jbfHelper, pc, exchange, in, out)) return;
  }
Beispiel #2
0
  public boolean handleError(
      int code, JBFHelper helper, ProcessContext pc, Exchange exchange, Message in, Message out) {

    if (code == JBFConstants.JBF_CONNECTION_ERROR) {
      String error = helper.getJbfError();
      out.setHeader(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.KO);
      out.setHeader(JBFConstants.JBF_ERRORE_HEADER_NAME, error);

      pc.setVariable(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.KO);
      pc.setVariable(JBFConstants.JBF_ERRORE_HEADER_NAME, error);
      out.setBodyText(helper.getJbfResponse());

      return true;
    } else if (code == JBFConstants.JBF_APPLICATION_ERROR) {
      String error = helper.getJbfError();
      out.setHeader(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.KO);
      out.setHeader(JBFConstants.JBF_ERRORE_HEADER_NAME, error);

      pc.setVariable(JBFConstants.JBF_ESITO_HEADER_NAME, JBFConstants.KO);
      pc.setVariable(JBFConstants.JBF_ERRORE_HEADER_NAME, error);
      out.setBodyText(helper.getJbfResponse());

      return true;
    } else {
      return false;
    }
  }