// if we have attachment support, do this as an attachment
if (useAttachments) {
// System.out.println("Creating attachment"); //DEBUG
SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
DataHandler dataHandler = new DataHandler(new OctetStreamDataSource("test",
new OctetStream(bytes)));
Part attachmentPart = attachments.createAttachmentPart(dataHandler);
AttributesImpl attrs = new AttributesImpl();
if (attributes != null && 0 < attributes.getLength())
attrs.setAttributes(attributes); // copy the existing ones.