Hello I'm using saaj to send a SOAP message with an attachment.
Here is my code thatI use to create the SOAPMessage:

messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
soapMessage.getMimeHeaders().removeAllHeaders();
soapMessage.getMimeHeaders().addHeader("Content-Type", "application/xml");
AttachmentPart attachment = soapMessage.createAttachmentPart(openFile(filePath ));
//attachment.setContent(openFile(filePath), "application/xml");
//attachment.setRawContent(openFile(filePath), "Application/octet-stream");
attachment.addMimeHeader("Content-Type", "application/xml");
attachment.setContentId("contactsFile");
soapMessage.addAttachmentPart(attachment);
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader();
SOAPBody soapBody = soapEnvelope.getBody();
soapHeader.detachNode();
SOAPBodyElement soapUploadRequest = soapBody.addBodyElement(QNamesRepository.getBodyNa me());
SOAPElement soapUser = soapUploadRequest.addChildElement(QNamesRepository .getUserName());
soapUser.addTextNode(user);
SOAPElement soapOperatorName = soapUploadRequest.addChildElement(QNamesRepository .getOperatorName());
soapOperatorName.addTextNode(operatorName);
SOAPElement soapOperatorPassword = soapUploadRequest.addChildElement(QNamesRepository .getOperatorPasswordName());
soapOperatorPassword.addTextNode(operatorPassword) ;
SOAPElement soapGroupPath = soapUploadRequest.addChildElement(QNamesRepository .getGroupPathName());
soapGroupPath.addTextNode(groupPath);
SOAPElement soapCanCreate = soapUploadRequest.addChildElement(QNamesRepository .getCanCreateName());
soapCanCreate.addTextNode(String.valueOf(canCreate ));
soapMessage.saveChanges();
return soapMessage;

I get an errore message:
ERRORE: 'Premature end of file.'
20-lug-2009 13.37.07 com.sun.xml.internal.messaging.saaj.soap.EnvelopeF actory createEnvelope
GRAVE: SAAJ0511: Unable to create envelope from given source

And if I print the InputStream of the request on the server I get:
------=_Part_0_56667.1248089818390
Content-Type: text/xml; charset=utf-8

<SOAP-ENV:Envelope xmlns:SOAP-ENV="cannot post link"><SOAP-ENV:Body><imin:uploadRequest xmlns:imin="cannot post link"><user>sergioMultiPro</user><operatorName>sergioAdmin</operatorName><operatorPassword>admin</operatorPassword><groupPath>ContattiA1A.ContattiA1 .ContattiA</groupPath><canCreate>false</canCreate></imin:uploadRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
------=_Part_0_56667.1248089818390
Content-Type: application/xml
Content-ID: contactsFile

Moro, Aldo, 393283245862, 393284365789567567
Fico, Gianni, 392345678234asa, 392384349583
------=_Part_0_56667.1248089818390--

What am I doing wrong?!?!

Thanks and bye

Sergio