cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to rename attachment at mapping level?

Former Member
0 Kudos

I have a scenario where sender and receiver both are webservices. Sender will be sending couple of attachments along with payload. I would need to rename the  attchment names to a different name in XI at mapping level so that receiver will receiver and sender will not have same file names.

Can you please suggest if this is possible? If possible, Please share java code to do that?

Thanks and Regards,

Raveendra

Accepted Solutions (0)

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

Hi Raveendra Babu,

You could create an UDF (user defined function) in the graphical mappind and to use the interfaces InputAttachments and OutputAttachments.

You could try with this examples to begin, although you should to debug the code:

To read Yugapreetha T's code in http://scn.sap.com/thread/1341089:

String Content = "";

String AttachmentID ="";

GlobalContainer globalContainer = container.getGlobalContainer();

InputAttachments inputAttachments = globalContainer.getInputAttachments();

if(inputAttachments.areAttachmentsAvailable())

{

     Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);

     Object[] arrayObj = CollectionIDs.toArray();

     int attachmentCount = arrayObj.length;

     for(int i =0;i<attachmentCount;i++)

     {

            AttachmentID =(String) arrayObj<i>;

              Attachment attachments =inputAttachments.getAttachment(AttachmentID);

          Content = Content + attachments.getContent().toString();

      }

}

return Content;

To write: (http://scn.sap.com/thread/1953315 - Rene Pilz answer)

try {

     GlobalContainer globalContainer = container.getGlobalContainer();

     OutputAttachments outputAttachments = globalContainer.getOutputAttachments();

     Attachment attachments = outputAttachments.create(filename, mimeType,content);

     return "Adde1: "+filename+" and attachments is null? "+ (attachments==null);

} catch (Exception e) {

     return e.toString();

}

Javadoc: https://help.sap.com/javadocs/pi/SP3/xpi/index.html

Regards.

Former Member
0 Kudos

how do we get attachment name? in this code, we are reading the content from inputattachments. is there anyway to read input attachment name?

iaki_vila
Active Contributor
0 Kudos

Hi Raveendra,

As far as i know the SOAP attachments inside the PI, the PI-SOAP messages, have no name they have a guid to identify them:

http://help.sap.com/saphelp_nw73/helpdata/en/48/bd87a00e7d0783e10000000a42189d/content.htm

http://www.w3.org/TR/SOAP-attachments

May be I'm wrong, we could expect if someone could give us some light about this issue

Regards.