// Instead of throwing NullPointerException like
// we used to do, throw something meaningful.
throw new IOException(Messages.getMessage("noAttachments"));
}
SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
Part attachmentPart= attachments.createAttachmentPart(dh);
AttributesImpl attrs = new AttributesImpl();
if (attributes != null && 0 < attributes.getLength())
attrs.setAttributes(attributes); //copy the existing ones.