Skip to Content
avatar image
Former Member

PayloadZipBean - variable filename inside the archive


I'm using the Adapter-Specific Message Properties in a sender fileadapter to determine the incoming filename, which has variable components (i.e. date and time). After changing the prefix and suffix in a Message-Mapping the new name is applied in a receiver fileadapter. The new name is now part of the payload in the tag <Filename>. The receiver fileadapter contains the PayloadZipBean to compress the output file, everything works fine.

Now I want the file inside my compressed archive always to have the same name as my archive has. In Stefan Grube's blog about the PayloadZipBean I only found the possibility to choose a fix name by using the MessageTransformBean (name="file.txt").


1. variable input filename: IN_RNK_20080227_1006.txt

2. filename after Message-Mapping: OUT_RNK_20080227_1006.gz

3. archive filename after receiver adapter: OUT_RNK_20080227_1006.gz

filename inside the archive: MainDocument (this is the default (payload-name))

I would like to name the file inside the archive OUT_RNK_20080227_1006, too.

Question 1: Is there any possibility to read out the mapped <Filename>-tag from the payload to use it for the element inside my archive (File Name Scheme and Variable Substitution don't work when using Adapter-Specific Message Properties).

Question 2: Is there a way to modify the name of the payload so that I can change "MainDocument" to "OUT_RNK_20080227_1006"?

I'm on XI 3.0 - SP19.

Many thanks,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Feb 28, 2008 at 03:57 PM

    This is not possible with standard functionality.

    You have to write an adapter module that stores the file name for example in the content type.



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Stefan Grube


      > In this thread there is a module for reading the content type and setting the dynamic configuration:

      > sender-mail-adapter-attachment-name

      > It should be not be so difficult to derive the reverse way

      Thanks for this info Stefan.

      [Stefan Grube's webinar on custom adapter module development|]

      The code of the EJB module we had to write to get the filename from the Dynamic Configuration (ASMA) and then set the content type of the message is given below.

       * Created on Apr 23, 2008
      package zfilezipper;
       * @author Krishneel Goundar
      import javax.ejb.CreateException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
       * @ejbHome<{}>
       * @ejbLocal<{}>
       * @ejbLocalHome<{}>
       * @ejbRemote<{}>
       * @stateless
      public class SetContentTypeEJB implements SessionBean, Module{
      	private SessionContext myContext;
      	public void ejbRemove() {}
      	public void ejbActivate() {}
      	public void ejbPassivate() {}
      	public void setSessionContext(SessionContext context) {
      	myContext = context;
      	public void ejbCreate() throws CreateException{}
      	public ModuleData process(ModuleContext moduleContext,ModuleData inputModuleData) throws ModuleException{
      		try {			
      			Message msg = (Message) inputModuleData.getPrincipalData();	//Used to read dynamic configuration data
      			TextPayload payload = msg.getDocument();	//Used to set 'contentType' value
      			//The name of the file to be zipped is read from the dynamic configuration.
      			String fileName = msg.getMessageProperty("", "FileName");
      			if(fileName == null)	//If no file name can be determined we set 'contentType' to "defaultbeanile.txt"
      				payload.setContentType("text/plain;charset = \"UTF-8\";filename=\"defaultbeanfile.txt\"");	
      			else	//If a file name can be found we set 'contentType' to the name of the file.
      				payload.setContentType("text/plain;charset = \"UTF-8\";filename=\"" + fileName + "\"");	
      			//After setting the value of 'contentType' we need to update the ModuleData object (inputModuleData).
      		} catch (Exception e) {
      			ModuleException me = new ModuleException(e);
      			throw me;
      		return inputModuleData;		//Return the updated ModuleData object.

      Edited by: Charu Kulkarni on Apr 28, 2008 1:41 AM