javax.xml.bind.attachment


1. Generating SOAP Messages with Attachments

import javax.xml.bind.annotation.*;
import javax.xml.bind.attachment.*;

@XmlRootElement(name = "Mail")
public class Mail {
    private String from;
    private String to;
    @XmlAttachmentRef
    private Attachment attachment;
}

2. Consuming SOAP Messages with Attachments

AttachmentPart part = attachment.getAttachmentParts().get(0);
part.getDataHandler().getInputStream(); // Read attachment content

3. Sending Attachments with SOAP Web Services

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.*;
import javax.xml.bind.attachment.*;

@WebService
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class AttachmentWebService {
    public void sendAttachment(@Param("mail") Mail mail) {
        // Save attachment
    }
}

4. Receiving Attachments with SOAP Web Services

5. Using @XmlAttachmentRef Annotation

6. Using AttachmentMarshaller

7. Using AttachmentUnmarshaller

8. Creating Attachment

9. Using MTOM Policy

10. Using SOAP with Attachments (MTOM)

11. Using SOAP with Attachments (SWA)

12. Using Attachment Type

13. Using MimeHeaders

14. Using DataHandler

15. Using MimeType

16. Using JAXBContext

17. Using Unmarshaller

18. Using @XmlRootElement Annotation

19. Using @XmlElement Annotation

20. Using @XmlAttribute Annotation

21. Using @XmlTransient Annotation

22. Using @XmlAccessorOrder Annotation

23. Using @XmlElementRef Annotation

24. Using @XmlElementWrapper Annotation

25. Using @XmlAnyElement Annotation

26. Using @XmlSchema Annotation**

27. Using @XmlJavaTypeAdapter Annotation**

28. Using @XmlInlineBinaryData Annotation**

29. Using @XmlID Annotation

30. Using @XmlIDREF Annotation

31. Using @XmlList Annotation

32. Using @XmlName Annotation

33. Using @XmlNamespace Annotation

34. Using @XmlPath Annotation

35. Using @XmlProperty Annotation

36. Using @XmlRegistry Annotation

37. Using @XmlRootElementWrapper Annotation

38. Using @XmlSchemaType Annotation

39. Using @XmlSeeAlso Annotation

40. Using @XmlEnumValue Annotation

41. Using @XmlMixed Annotation

42. Using @XmlTransient Annotation

43. Using @XmlValue Annotation

44. Using @XmlWrapperType Annotation

45. Using @XmlAnyElement Annotation

46. Using @XmlAttachmentRef Annotation

47. Using @XmlElement Annotation

48. Using @XmlElements Annotation

49. Using @XmlElementWrapper Annotation

50. Using @XmlRootElement Annotation