cancel
Showing results for 
Search instead for 
Did you mean: 

Handling attachments in SOAP to Proxy synchronous interface

ashish_goel4
Active Participant
0 Kudos

Hello Experts,

We have a requirement to validate the attachment size in the incoming web service message.


Attachment size is coming as a field in web service message.

Condition : If attachment size is more than 3 MB , we need to remove the attachment and sends the message to target application after mapping.

If attachment size is less than 3 MB , we need to send message along with the attachment.

Please help how to achieve this. We are not going for BPM.

Thanks,

Ashish

Accepted Solutions (1)

Accepted Solutions (1)

Muniyappan
Active Contributor
0 Kudos

Hi,

You have to create the udf. Pass size as a input to it.

Use remove attachment method to remove if condition is satisfied. Below one can give idea how to use attachment methods.

https://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/OutputAttachments.html

Regards,

Muni.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

Check this for handling SOAP attachments in PI (obviously UDF code is not there but it has already been answered above)

Thanks

Amit Srivastava

former_member181985
Active Contributor
0 Kudos

Hi Ashish,

You can read the attachment size using an UDF and then remove the attachment accordingly.

Sample code:


String attachmentID = null; 

AbstractTrace trace = container.getTrace();  ; 

GlobalContainer globalContainer = container.getGlobalContainer(); 

InputAttachments inputAttachments = globalContainer.getInputAttachments(); 

OutputAttachments outputAttachments = globalContainer.getOutputAttachments(); 

if (<YOUR CONDITION FOR ATTACHMENT SIZE>) //var1 - message size input value

{

  try 

  { 

  if(inputAttachments.areAttachmentsAvailable()  ) 

  { 

  trace.addInfo("Attachments Available"); 

  Collection<String> CollectionIDs = inputAttachments.getAllContentIds(true); 

  Object[] arrayObj = CollectionIDs.toArray(); 

  for(int i =0;i<arrayObj.length;i++) 

  { 

  attachmentID =(String)arrayObj[i]; 

  outputAttachments.removeAttachment(attachmentID);                                                                

  } 

  }            

  } 

  catch (Exception e) 

  { 

  e.printStackTrace(); 

  }

}

return    var1;

Regards,

Praveen Gujjeti