Skip to Content

How to get rid of JPFDocument.xml attachment?

Hi,

I am using a java mapping to create a mail with two attachments.

I am able to get two attachments in the end, but there is a third attachment JPFDocument.xml in my mail which is blank. Can anyone please help me to get rid of this attachment.

Here is the sample code.

Map mapParameters = (Map) in.getInputHeader().getAll(); mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic", StreamTransformationConstants.DYNAMIC_CONFIGURATION), ""); DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

// Recipient Address

DynamicConfigurationKey recipients = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "THeaderTO"); conf.put(recipients, "abc@test.com");

InputStream ins = in.getInputPayload().getInputStream();

OutputStream outs = out.getOutputPayload().getOutputStream();

ins.close();

String ResponseXML = "This is a test";

byte[] ResponseByte = ResponseXML.getBytes();

String ResponseFilename = "File1_out" + ".xml";

OutputAttachments outputAttachments = out.getOutputAttachments();

Attachment ResponseAttch = outputAttachments.create(ResponseFilename, ResponseByte);

outputAttachments.setAttachment(ResponseAttch);

String ResponseXML = "This is a test1";

byte[] ResponseByte = ResponseXML.getBytes();

String ResponseFilename = "File2_out" + ".xml";

OutputAttachments outputAttachments = out.getOutputAttachments();

Attachment ResponseAttch = outputAttachments.create(ResponseFilename, ResponseByte);

outputAttachments.setAttachment(ResponseAttch);

Regards,

Prashant

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 23, 2017 at 12:31 AM

    Thanks for all your help guys.

    I managed to fix this by adding MessageTransformBean and set the contentDisposition to inline.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 14, 2017 at 08:28 PM

    Hi Prashant!

    It looks like you don't compose any xml/text/html document as output payload. I guess that mail adapter creates third attachment for your empty main payload and as far as it's not in xml format it uses JPFDocument instead of MainDocument as attachment name. But it's just a guess.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 21, 2017 at 04:23 AM

    Thanks for your reply Evgeniy,

    Both if the files which I am attaching are xml files. I tried to remove all the content and tried to add the Xheadername1 and set the content type, but the result is still the same.

    DynamicConfigurationKey mailHeader = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "XHeaderName1"); mailHeaderValue = "attachment; filename=\"Testfile.xml\"";

    conf.put(mailHeader, mailHeaderValue);

    CompositeContentType = "text/xml" + ";charset=\"" + "UTF-8" + "\";filename=\"Testfile.xml\""; out.getOutputHeader().setContentType(CompositeContentType);

    String MsgPrefix = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DummyMessageMT><Dummy><Dummyfield>";

    String MsgSuffix = "</Dummyfield></Dummy></DummyMessageMT>";

    ResponseByte = (MsgPrefix + "This is test"+ MsgSuffix).getBytes();

    outs.write(ResponseByte);

    Please let me know if I am missing anything.

    Regards,

    Prashant

    Add comment
    10|10000 characters needed characters exceeded