As per thread: Stefan Grube mentioned in the thread, this is the default SOAP adapter behavior since it was hardcoded in SOAP adapter for incoming attachments to XI. But most of the times, the business needs the original attachment names at the receiving target application. So, how can we achieve this.
discussion, SOAP sender Adapter always replaces the incoming attachment names with attachment-1, attachment-2 etc.. And as
In this blog, I am providing UDF code snippet using which we can retain original attachment names in the mapping by reading incoming attachments using mapping API for attachments (applicable from PI7.1 onwards). Also, with this procedure we can overwrite existing attachments with any content as bytes. Note:- the same can be achieved with a java mapping/XSLT with java enhancements as well.
String attachmentID = null; java.util.Map map; AbstractTrace trace; //gets the input attachment from the source message GlobalContainer globalContainer = container.getGlobalContainer(); InputAttachments inputAttachments = globalContainer.getInputAttachments(); OutputAttachments outputAttachments = globalContainer.getOutputAttachments(); trace = container.getTrace(); //map = globalContainer.getParameters(); try { //checks for the availability of attachments in the input message if(inputAttachments.areAttachmentsAvailable()) { trace.addInfo("Attachments Available"); //gets the attachmentIds and store it in an Object array Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true); Object[] arrayObj = CollectionIDs.toArray(); //Loops at the input attachments to get the content of the attachment for(int i =0;i<arrayObj.length;i++) { attachmentID =(String)arrayObj[i]; trace.addInfo((i+1) + ") Attachment Name: " + attachmentID); Attachment attachment = inputAttachments.getAttachment(attachmentID); String contentType = attachment.getContentType(); byte[] attachmentBytes = attachment.getContent(); Attachment renameAttachment = outputAttachments.create(attachmentID, contentType, attachmentBytes); outputAttachments.setAttachment(renameAttachment); //remove each attachment if required. Uncommonent below //trace.addInfo("Removing Attachment no: " + (i+1) + " & Name: " + attachmentID); //outputAttachments.removeAttachment(attachmentID); } } } catch (Exception e) { e.printStackTrace(); } return var1;
Attachments sent from SOAP UI as SOAP message to XI.
With the above UDF in the graphical mapping, the results will be as shown below for the inbound/mapping pipeline stages in MONI
Regards,
Praveen Gujjeti