Skip to Content
Image a scenario in witch the the sender system sends two files filenameHEADER.TXT
filename.ZIP
The first file is the master file, it contains header data .
The second file (filename.ZIP) will be treated as an attachment (for example in case of file to mail scenarios).
This means that in the SOAP XI Message we will see two payloads: MainDocument and the our attachment.

The File Sender Communicational Channel is configured in this way:

image

In this way everything works fine. In SXMB_MONI we can see that we have the payload that contains our email address, and the attachment (%F) that is our zip file.

image

At this point we want to change the name and the mime type of the attachment we want to give the same name of our real .ZIP file.

I’ve not found a way to do that with standard SAP modules such as PayloadSwapBean and MessageTransformationBean, so I decided to write my own module.

The RenameAttachmentModule accepts the following parameters:

– Param.AttachmentName: that is the name of the attachment that must be changed. (REQUIRED)
  Possible values:
     – any attachment name present in the XI Message.
– Param.NewAttachmentName : is the new mime type we want to assign to the attachment. (OPTIONAL)
  Possible values:
     – %f -> can be used only for file/FTP adapter, and is the File Name picked up by the communicational channel.
     – any other string.
– Param.NewAttachmentExtension is se to the extension we want to add to the new file name. (OPTIONAL)
  Possible values:
     – any string.
– Param.NewAttachmentMimeType: is the new mime type we want to assign to the attachment. (OPTIONAL)
  Possible values:
     – possible mime type.
– Param.NewAttachmentNameReplace this paramenter work in the same way of the namePart parameter in Additional file
configuration of the File Adapter.
   This parameter must be used only in case of Param.NewAttachmentName is %f and only in File Adapter. (OPTIONAL)

image

The result is that we now have the attachment with the desired name and mime type.

image

Here the code of the adapter module:

References
How To Create Modules for the J2EE Adapter Engine
Example Adapter and Example Module

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Sergio Cipolla
    I think this adapter module could be really useful, especially when struggling with several attachments in a file to mail scenarios.

    Looking forward to see your next blog!

    Sergio

    (0) 
  2. P. Schults
    Your solution looks creat.
    I am using it in a file (xml mailpackage + pdf attachment). on the SXMB_MONI side it looks ok, attachment is renamed to original filename.
    But sending the mail results in 2 attachments.

    1) untitled.txt (containing the mailpackage contentdescription)
    2) untitled.pdf (should be the same as in sxmb_moni but it is not?
    Am i forgetting something?

    (0) 
  3. Francesco Bersani Post author

    Hi Chinna

    Thank you for your comment.

    unfortunally the screens have gone when the scn site was updated.

    I’ll try in the future to adjust all of my blogs and retrieve the missing screens.

    Francesco

    (0) 

Leave a Reply