code: public static InputStream toInputStream(SOAPMessage msg){
          if(msg==null)
              return null;
          ByteArrayOutputStream os = new ByteArrayOutputStream();
          try {
              msg.writeTo(os);
          } catch (Exception e) {
              throw S1SystemError.wrap(e);
          }
          return new ByteArrayInputStream(os.toByteArray());
      }
docs: Write message with attachments to stream
  
  @param msg
  @return