Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Only 1 attachment detected in CXF Soap headers

Hello,
In the mediation view I created a CXF SOAP endpoint (payload) that I route to a job. In the Job I set the routeinput to pass the headers as a raw format (object type) that I connect to a tJavaFlex. In the tJavaFlex I then search for attachments. Everything works ok for 1 attachment. But if I send 2 attachments only the first one is detected.
Here is the code of the tJavaFlex (part of it I found in the forums) :

CaseInsensitiveMap headers = (CaseInsensitiveMap)to_attachment.headers;
Iterator<Object> it = headers.values().iterator();
SoapMessage msg = null;
while (it.hasNext()) {
    Object obj = it.next();
    if (obj instanceof SoapMessage) {
        msg = (SoapMessage)obj;
    }
}
if (msg != null) {
    Collection<Attachment> attachments = (Collection<Attachment>)msg.getAttachments();
    if (attachments != null) {
        System.out.println("Found Attachments-->");
        File dataDir = new File(context.appdir + "/" + to_attachment.flowid);
        dataDir.mkdir();
        Iterator<Attachment> iter = attachments.iterator();
        while (iter.hasNext()) {
            Attachment attachment = iter.next();
            DataHandler data = attachment.getDataHandler();
            InputStream is = data.getInputStream();
            File dataFile = new File(dataDir + "/" + data.getName());
            System.out.println("Writing data to:\n\t" + dataFile.toString());    
            FileOutputStream fos = new FileOutputStream(dataFile);
            IOUtils.copy(is, fos);
            fos.close();  
        }
    } else System.out.println("No Attachment!");
}

Product : "Talend Open Studio for ESB" Version: 5.6.1 Build id: V5.6.1_20141207_1530
Product :TESB_SE-V5.6.1
Is there anything I can do or is it a bug ?
Thanks,
JGS
Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Just a reply to myself, it is not a bug : the attachment can be a MultiPart object that has to parsed for every Part contained.
Done!

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Just a reply to myself, it is not a bug : the attachment can be a MultiPart object that has to parsed for every Part contained.
Done!
Anonymous
Not applicable
Author

Thanks for sharing the resolution before we had the time to step in! 0683p000009MACn.png
Elisa