Пример #1
0
  private void doFromSoapMessage(Message message, Object sm) {
    SOAPMessage m = (SOAPMessage) sm;
    MessageContentsList list = (MessageContentsList) message.getContent(List.class);
    if (list == null) {
      list = new MessageContentsList();
      message.setContent(List.class, list);
    }
    Object o = m;

    if (StreamSource.class.isAssignableFrom(type)) {
      try {
        try (CachedOutputStream out = new CachedOutputStream()) {
          XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
          StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw);
          xsw.close();
          o = new StreamSource(out.getInputStream());
        }
      } catch (Exception e) {
        throw new Fault(e);
      }
    } else if (SAXSource.class.isAssignableFrom(type)) {
      o = new StaxSource(new W3CDOMStreamReader(m.getSOAPPart()));
    } else if (Source.class.isAssignableFrom(type)) {
      o = new DOMSource(m.getSOAPPart());
    }
    list.set(0, o);
  }
Пример #2
0
 private void doDataSource(final Message message) {
   MessageContentsList list = (MessageContentsList) message.getContent(List.class);
   // reconstitute all the parts into a Mime data source
   if (message.getAttachments() != null
       && !message.getAttachments().isEmpty()
       && list != null
       && !list.isEmpty()
       && list.get(0) instanceof DataSource) {
     list.set(0, new MultiPartDataSource(message, (DataSource) list.get(0)));
   }
 }