This is the portion of code.
I need to attach a mime multipart attachment 

  | SOAPMessage message = messageFactory.createMessage();
  |             
  |             SOAPPart soapPart = message.getSOAPPart();
  |             SOAPEnvelope envelope = soapPart.getEnvelope();
  |             SOAPBody soapBody = envelope.getBody();
  | 
  |             SOAPElement bodyElement = 
soapBody.addBodyElement(BODY_ELEM_NAME);
  | 
  |             //...not relevant code
  | 
  | 
  |             bodyElement.addChildElement(CHILD_NAME).addTextNode("textNode");
  |             
bodyElement.addChildElement(OTHER_CHILD_NAME).addTextNode("textNode");
  |            
  |             // ...
  |             // Create MimeMultipart to attach to the message
  |             String text = "Example ...";
  |             MimeMultipart multipart = new MimeMultipart();
  |             
  |             //add the text to the multipart
  |             MimeBodyPart textPart = new MimeBodyPart();
  |             textPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
  |                     "Text data", text.getBytes(), "text/plain")));
  |             textPart.setContentID("text1.txt");
  |             textPart.setHeader("Content-Type", "text/plain");
  |             textPart.setDisposition(MimeBodyPart.ATTACHMENT);
  |             textPart.setHeader("Content-Transfer-Encoding", "binary");
  |             textPart.setFileName("text1.txt");
  |             multipart.addBodyPart(textPart);
  | 
  |             // add another content
  |             byte[] imgContent= getImageContent(myImage);//a custom    
method to retrieve some contents
  |             MimeBodyPart imgPart = new MimeBodyPart();
  |             imgPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
  |                     "image data", imgContent, "image/jpg")));
  |             smilPart.setContentID("image.img");
  |             smilPart.setHeader("Content-Type", "image/jpeg");
  |             smilPart.setDisposition(MimeBodyPart.ATTACHMENT);
  |             smilPart.setHeader("Content-Transfer-Encoding", "base64");
  |             smilPart.setFileName("file1.jpg");
  |             multipart.addBodyPart(imgPart, 0);
  |             
  |             multipart.setSubType("related");
  |                 
  |             AttachmentPart multipartAtt = message.createAttachmentPart(
  |                     multipart, multipart.getContentType());
  |             multipartAtt.setContentId("multipart-content-id");
  |                 
  |             message.addAttachmentPart(multipartAtt);
  | 
  |             message.saveChanges();
  | 
  |             printMessage(message);
  | 
  |             SOAPMessage reply = connection.call(message, address);
  | 

I've deleted some portions of code not relevant


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3905769#3905769

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3905769


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to