on 08-15-2012 4:07 PM
Hello All,
Is it possible to create an attachment from incoming XML file and send the resulting XML + Attachment via an adaptor like(File adaptor/Proxy) to another system .
Example:
If I have an incoming XML with normal text data and it also has a <!cdata> tag containing binary data.
So in PI, I want retain the normal XML data but convert the binary data(part of cdata tag) into an attachment and then send the XML data along with this attachment to receiver adaptor/system.
Appreciate any pointers on :
1. If it is possible to do this.
2. any blogs/threads which might point me in right direction.
Thanks
two things (works only if PI version >= 7.1)
1. First read the CDATA section base64 string data and convert to byte array using standard SAP Base64 API class.
2. then create attachment using SAP's mapping API
Ensure that you enable check box "Read Attachments" in operation mapping
UDF Code Snippet:-
import com.sap.aii.utilxi.base64.api.*; //only in UDF import section not in code section
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(Base64.decode("<base64stringdata_from_CDATATags>")); //write your logic to get CDATA string here
GlobalContainer globalContainer = container.getGlobalContainer();
OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
try
{
Attachment newopAttachment = outputAttachments.create("attachmentName", baos);
outputAttachments.setAttachment(newopAttachment);
}
catch (Exception e)
{
e.printStackTrace();
}
return "1";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.