on 03-28-2023 5:43 AM
Hi All,
I have requirement where ARIBA is sending xml payload along with pdf attachment to CPI. Requirement is to convert this attachment to Hexcode and send in some target field of MDG webservice along with other fields which are coming from ARIBA.
How can we achieve this in SAP CPI.
Note:- ARIBA sending this attachment over HTTP call and on Receiver MDG side we are connecting MDG webservice over SOAP call.
Hi Mahesh
I've blogged about how to access attachments here. Here's some quick and dirty code that reads the attachment, Base64 encodes it and stores the result in a property:
import com.sap.gateway.ip.core.customdev.util.Message
import javax.activation.DataHandler
def Message processData(Message message) {
// Note: The next line assumes that there is exactly one attachment.
DataHandler attachment = message.getAttachments().values().iterator().next()
// Read the binary content of the attachment into memory. Don't do this for huge attachments!
byte[] content = attachment.getInputStream().getBytes()
// Base64 encode the binary content.
String base64 = content.encodeBase64().toString()
// Store the Base64 in a property.
message.setProperty('EncodedAttachment', base64)
// All done.
return message
}
You can then access the Base64 value through the property afterwards.
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.