Rename Attachment Adapter Module
Image a scenario in witch the the sender system sends two files filenameHEADER.TXT
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:
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.
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)
– any attachment name present in the XI Message.
– Param.NewAttachmentName : is the new mime type we want to assign to the attachment. (OPTIONAL)
– %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)
– any string.
– Param.NewAttachmentMimeType: is the new mime type we want to assign to the attachment. (OPTIONAL)
– 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)
The result is that we now have the attachment with the desired name and mime type.
Here the code of the adapter module:
How To Create Modules for the J2EE Adapter Engine
Example Adapter and Example Module
Would you like to access Full Article?
If you are already a member in this website, Please Click here to loginIf you are not yet a member, Please Click here to Sign up
New NetWeaver Information at SAP.com