Exemple #1
0
  private void processRequest(MessageExchange exchange) throws MessagingException {
    if (exchange.getStatus() == ExchangeStatus.ACTIVE) {

      String id = exchange.getExchangeId();
      this.exchanges.put(id, exchange);

      InOut inOut = createInOutExchange(QName.valueOf(getTargetServiceQName()), null, null);
      inOut.setProperty(CORRELATION_ID, id);

      NormalizedMessage inMsg = getInMessage(exchange);
      removeHeader(inMsg);

      //            NormalizedMessage msg = inOut.createMessage();
      //            String xml = null;
      //            try {
      //                xml = new SourceTransformer().contentToString(inMsg);
      //            } catch (Exception ex) {
      //                throw new MessagingException("Error getting content: " + ex.getMessage(),
      // ex);
      //            }
      //            System.out.println("XML TO SVC: " + xml);
      //            msg.setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes())));

      //            inOut.setInMessage(msg);
      inOut.setInMessage(inMsg);
      send(inOut);
    }
  }
Exemple #2
0
  private void processResponse(MessageExchange exchange) throws MessagingException {

    if (exchange.getStatus() == ExchangeStatus.ACTIVE) {

      System.out.println("Endpoint: " + exchange.getEndpoint().getServiceName());

      String id = (String) exchange.getProperty(CORRELATION_ID);
      MessageExchange request = (MessageExchange) this.exchanges.remove(id);
      if (request == null) {
        throw new MessagingException("No exchange found for ID: " + id);
      }

      NormalizedMessage response = request.createMessage();
      String xml = null;
      try {
        xml = new SourceTransformer().contentToString(exchange.getMessage("out"));
      } catch (Exception ex) {
        throw new MessagingException("Error getting content: " + ex.getMessage(), ex);
      }
      System.out.println("XML FROM SVC: " + xml);
      response.setContent(new StreamSource(new ByteArrayInputStream(xml.getBytes())));

      done(exchange);
      request.setMessage(response, "out");
      send(request);
    }
  }