"/test-resources" + File.separator + "attach.xml"));
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
AttachmentPart ap = message.createAttachmentPart();
MimeHeader mh = null;
//Setting Mime Header
ap.setMimeHeader("Content-Description", "some text");
//Setting Content Id Header
ap.setContentId("id@abc.com");
//Setting Content
ap.setContent(new StreamSource(in1), "text/xml");
//Clearing Content
ap.clearContent();
try {
//Getting Content
InputStream is = (InputStream)ap.getContent();
fail("Error: SOAPException should have been thrown");
} catch (SOAPException e) {
//Error thrown.(expected)
}
Iterator iterator = ap.getAllMimeHeaders();
int cnt = 0;
boolean foundHeader1 = false;
boolean foundHeader2 = false;
boolean foundDefaultHeader = false;
while (iterator.hasNext()) {
cnt++;
mh = (MimeHeader)iterator.next();
String name = mh.getName();
String value = mh.getValue();
if (name.equals("Content-Description") && value.equals("some text")) {
if (!foundHeader1) {
foundHeader1 = true;
//MimeHeaders do match for header1
} else {