Example #1
0
  public void send(MessageContext context, OutMessage message) throws XFireException {
    if (message.getUri().equals(Channel.BACKCHANNEL_URI)) {
      final OutputStream out = (OutputStream) context.getProperty(Channel.BACKCHANNEL_URI);
      if (out != null) {
        final XMLStreamWriter writer =
            STAXUtils.createXMLStreamWriter(out, message.getEncoding(), context);

        message.getSerializer().writeMessage(message, writer, context);
      } else {
        throw new XFireRuntimeException("No backchannel exists for message");
      }

      try {
        Attachments atts = message.getAttachments();
        if (atts != null && atts.size() > 0) {
          writeAttachmentBody(context, message);
          // TODO response.setContentType(atts.getContentType());
          atts.write(out);
        } else {
          // TODO response.setContentType(getSoapMimeType(message));
          writeWithoutAttachments(context, message, out);
        }
      } catch (IOException e) {
        throw new XFireException("Couldn't send message.", e);
      }
    } else {
      try {
        sendViaClient(context, message);
      } catch (Exception e) {
        throw new XFireException("Failed to Send via MuleUniversalChannel: " + e.getMessage(), e);
      }
    }
  }
Example #2
0
  public void send(final MessageContext context, final OutMessage message) throws XFireException {
    if (message.getUri().equals(Channel.BACKCHANNEL_URI)) {
      final OutputStream out = (OutputStream) context.getProperty(Channel.BACKCHANNEL_URI);
      if (out != null) {
        final XMLStreamWriter writer =
            STAXUtils.createXMLStreamWriter(out, message.getEncoding(), context);

        message.getSerializer().writeMessage(message, writer, context);
      } else {
        MessageContext oldContext = (MessageContext) context.getProperty(OLD_CONTEXT);

        sendViaNewChannel(context, oldContext, message, (String) context.getProperty(SENDER_URI));
      }
    } else {
      MessageContext receivingContext = new MessageContext();
      receivingContext.setXFire(context.getXFire());
      receivingContext.setService(getService(context.getXFire(), message.getUri()));
      receivingContext.setProperty(OLD_CONTEXT, context);
      receivingContext.setProperty(SENDER_URI, getUri());
      receivingContext.setSession(session);

      sendViaNewChannel(context, receivingContext, message, message.getUri());
    }
  }