on 09-14-2016 12:11 PM
Hello Folks,
I have File sender Channel and it is having additional files concept. So I have total 4 files on Sender side.
Lets say these are :
Attachment Files :
Student_1.txt
Student_2.txt
Student_3.txt
Main payload file : Student_Final.txt
These files are getting picked up without any issue and I am getting Student_Final.txt as main Payload and others are as attachment. I am fine till now.
SOAP Header :
Now I need to access the file attachment name in Java Mapping before reading the content of the file. So here I need to access the filename which is inside the <sap:name> tag i.e. Student_1.txt or Student_2.txt or Student_3.txt
.
I tried with the below methods and getting the values :
Method : attachment.getContantType()
Value : application/xml;
Method : attachment.getContentId();
Value is different for the each attachment and looks like :
I had look in message monitor :
So Content Type is not containing the file name here.
Please suggest how to get attachment file name.
Thanks.
Best Regards
Om Heerani
Om,
Can you try with this UDF.
String attachmentID = null;
GlobalContainer globalContainer = container.getGlobalContainer();
InputAttachments inputAttachments = globalContainer.getInputAttachments();
if(inputAttachments.areAttachmentsAvailable())
{
Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true);
Object[] arrayObj = CollectionIDs.toArray();
attachmentID = (String)arrayObj[0];
Attachment attachment = inputAttachments.getAttachment(attachmentID);
int attachmentsize = attachment.getContent().length;
return "Attachment Name : "+attachmentID +" Attachment Size : "+attachmentsize+" bytes";
}
else {
return "no attachment found";
}
In OM make sure you mark "Read Attachments".
Br,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Manoj,
I am using File sender with option "Additional File" to pick the attachments.
Even I have tried with the SOAP Sender channel and the above code is working fine and file name is accessible.
However With the file sender channel, Attachment file name is not accessible. Could you please try with the File sender channel.
Below is sender channel configuration. In my case
Unfortunately ,
I wont be able to test with NFS now , however can you try to add the Module in your sender channel as below . once you have added Please provide the screenshot of Dynamic Configuration from your MONI/RWB to assist you further. I want to check is this module works with File Adapter or not.
Module:
Dynamic:
Br,
Manoj
Hello Manoj,
Yes. It worked. As per your suggestion I used the MultipartHeaderBean Module in Sender File channel. This module worked fine with the file Sender channel.
All Header information of Main Payload & Attachments appeared in Dynamic Configuration tab as below.
Now I checked the file name on the basis of Content-Disposition using Dynamic Configuration and got the corresponding Attachment data using the Content-ID.
In the below method, I put the Content-ID which was retrieved from Dynamic Configuration instead of putting the Attachment ID because both values are same.
Attachment attachment = inputAttachments.getAttachment(key_id);
Thanks for your help.
Best Regards
Om Heerani
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.