Interface MimeMessage

All Superinterfaces:
WebServiceMessage
All Known Subinterfaces:
SoapMessage
All Known Implementing Classes:
AbstractMimeMessage, AbstractSoapMessage, SaajSoapMessage

public interface MimeMessage extends WebServiceMessage
Represents a Web service message with MIME attachments. Attachments can be added as a file, an InputStreamSource, or a DataHandler.
Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Method Details

    • isXopPackage

      boolean isXopPackage()
      Indicates whether this message is a XOP package.
      Returns:
      true when the constraints specified in Identifying XOP Documents are met.
      See Also:
    • convertToXopPackage

      boolean convertToXopPackage()
      Turns this message into a XOP package.
      Returns:
      true when the message is a XOP package
      See Also:
    • getAttachment

      Attachment getAttachment(String contentId) throws AttachmentException
      Returns the Attachment with the specified content Id.
      Returns:
      the attachment with the specified content id; or null if it cannot be found
      Throws:
      AttachmentException - in case of errors
    • getAttachments

      Iterator<Attachment> getAttachments() throws AttachmentException
      Returns an Iterator over all Attachment objects that are part of this message.
      Returns:
      an iterator over all attachments
      Throws:
      AttachmentException - in case of errors
      See Also:
    • addAttachment

      Attachment addAttachment(String contentId, File file) throws AttachmentException
      Add an attachment to the message, taking the content from a File.

      The content type will be determined by the name of the given content file. Do not use this for temporary files with arbitrary filenames (possibly ending in ".tmp" or the like)!

      Parameters:
      contentId - the content Id of the attachment
      file - the file to take the content from
      Returns:
      the added attachment
      Throws:
      AttachmentException - in case of errors
    • addAttachment

      Attachment addAttachment(String contentId, org.springframework.core.io.InputStreamSource inputStreamSource, String contentType)
      Add an attachment to the message, taking the content from an InputStreamSource.

      Note that the stream returned by the source needs to be a fresh one on each call, as underlying implementations can invoke InputStreamSource.getInputStream() multiple times.

      Parameters:
      contentId - the content Id of the attachment
      inputStreamSource - the resource to take the content from (all of Spring's Resource implementations can be passed in here)
      contentType - the content type to use for the element
      Returns:
      the added attachment
      Throws:
      AttachmentException - in case of errors
      See Also:
      • Resource
    • addAttachment

      Attachment addAttachment(String contentId, jakarta.activation.DataHandler dataHandler)
      Add an attachment to the message, taking the content from a DataHandler.
      Parameters:
      dataHandler - the data handler to take the content from
      Returns:
      the added attachment
      Throws:
      AttachmentException - in case of errors