I am trying to create a soap message with attachments and running into a
problem I cannot figure out. Below is a fragment of code used to add an
attachment to a SOAP message. It throws a nullPointer Exception in the
createAttachmentPart method. Any ideas?
URL report = new File(filePath).toURL();
DataHandler dataHandler = new DataHandler(report);
System.out.println(dataHandler.getContentType());
// Exception thrown at this point
AttachmentPart attachment =
message.createAttachmentPart(dataHandler);
System.out.println(attachment.getContentType());
attachment.setContentId("report_id");
message.addAttachmentPart(attachment);
Thanks
Martin