Attaching file to Web Service

I have the this code inside my web method:

MessageContext context = null;

Message responseMessage = null;

SOAPBody responseBody = null;

SOAPEnvelope responseEnvelope = null;

SOAPElement responseElement = null;

context = MessageContext.getCurrentContext();

if( context!=null )

{

responseMessage = context.getResponseMessage();

if( responseMessage!=null )

{

try {

responseBody = (SOAPBody)responseMessage.getSOAPBody();

} catch (SOAPException e) {

}

try {

responseEnvelope = responseMessage.getSOAPEnvelope();

} catch (AxisFault e) {

}

AttachmentPart attachPart = null;

DataHandler dh = new DataHandler( new FileDataSource("C:/t1.txt"));

attachPart = (AttachmentPart)responseMessage.createAttachmentPart(dh);

attachPart.setContentId("attachment-1");

responseMessage.addAttachmentPart(attachPart);

But a I have this error:

java.lang.RuntimeException: No support for attachments

Help me :(

[1065 byte] By [estrovaa] at [2007-10-2 20:47:04]
# 1

I've just struggled though the same problem.

The Exception handling and logging around this area is a bit dodgy.

Ensure that you have:

-javax.activation.DataHandler (activation.jar)

-javax.mail.internet.MimeMultipart (mailapi.jar)

in your classpath.

If the code cannot find these classes, it thows an exception which is silently handled...

K_S1a at 2007-7-13 23:30:57 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...