cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP Receiver response-How to read and map multiple attachments using PayloadSwapBean?

nitinlpatil12
Participant
0 Kudos

Hi Experts,

My scenario is to get Order Confirmations with multiple attachments from Ariba, when Dat Request is sent to Ariba all the pending Order confirmations are sent as an attachment.

I am using SOAP Receiver adapter to get the pending Order confirmations with Keep Attachments and Do Not Use SOAP Envelope parameters.

Payload contains MainAttachment and multiple attachments attachment-2, attachment-3, attachment-3....

Also I am using Payload Swap Bean - AF_Module/PayloadSwapBean with following parameters after standard SOAP adapter module,

swap.keyName: payload-name

swap.keyValue: attachment-2

I am able to swap MainAttachment with attachment-2 but I have following issues,

  1. I need to have all the attachments (multiple order confirmation) in Payload so that it can be mapped to Target structure
  2. after swap of attachment-2, payload only contains Header section, first tag and subsequent tags are omitted from payload

Please guide on what changes can be done in PayloadSwapBean so that all the attachments are swappend in payload with entire content.

Let me know if there is any other approach can be adapted to meet the above requirement.

Thanks and Best Regards,

Nitin Patil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Nitin,

Do you have any specific reason to go for SOAP adapter instead of standard ARIBA adapter for connecting to ARIBA?

Your requirement is very simple to handle when you go with standard ARIBA adapter which has in built features to handle this scenario.

Regards

Venkat

nitinlpatil12
Participant
0 Kudos

Hi Venkat,

Customer is not willing to purchase Ariba Network Adapter because of budget constraints and want us to implement using the existing PI capabilities.

Can you please let me know if you have any idea on how to correct the above error or any other way for handling multiple attachments?

Thanks!

Regards,

Nitin Patil

Shabarish_Nair
Active Contributor
0 Kudos

the mapping api now supports the reading of attachments using java code

refer -

Generated Documentation (Untitled)

nitinlpatil12
Participant
0 Kudos

Hi Shabarish/Experts,

thanks for your help, However I was unable to find java code details in one of the link you had provided but somehow was able to manage Java code.

Currently using Java mapping and trying to load the attachments in payload and store it on to the server using FilePath parameter in Java code.

FilesPath parameter is is defined in Operation Mapping and parameter is passed through the Interface determination but at runtime parameter is not passed from configuration. Also below are the screenshot of error and configuration in operation mapping and interface determination for your reference.

<!-- Request Message Mapping --> 

- <SAP:Error SOAP:mustUnderstand="1" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>

<SAP:P1>com/sap/multipleattachment/MultipleAttachment</SAP:P1>

<SAP:P2>java.lang.RuntimeException: The input-parameter Fi</SAP:P2>

<SAP:P3>lesPath does not exist.</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:Stack>Runtime exception occurred during application mapping com/sap/multipleattachment/MultipleAttachment; java.lang.RuntimeException: The input-parameter FilesPath does not exist.</SAP:Stack>

<SAP:Retry>N</SAP:Retry>

</SAP:Error>

Operation Mapping:

Interface Determination:

Part of Java code for your reference,

      /*Reading parameter File Path of application server where files are to be downloaded from parameter given in Iflow configuration*/
            String FilesPath = arg0.getInputParameters().getString("FilesPath");
            getTrace().addInfo(String.valueOf(arrayObj.length));
          
            if(arrayObj.length == 0)
            {
           throw new RuntimeException("No Attachments Available");
            }
            for(int i =0;i<arrayObj.length;i++) 
           
                attachmentID =(String)arrayObj[i]; 
                Attachment attachment = inputAttachments.getAttachment(attachmentID); 
                String attchName = attachment.getContentType(); 
                if(attchName.indexOf("\"") !=  -1)
   {
   attchName = attchName.substring(attchName.indexOf("\""));
   attchName = attchName.replaceAll("\"","");
   }
            //if (attchName.substring(attchName.length()-3).equals("xml"))
              //Above if statement is on case to check the attachment with extnsion{
          
                /* below lines for downloading the XML attachments content to FilePath location with the name retrieved from attachment*/
           try
           {
           byte[] attachmentBytes = attachment.getContent();
           File path = new File(FilesPath+attchName);
           FileOutputStream fos = new FileOutputStream(path);
           fos.write(attachmentBytes);
           while(!isCompletelyWritten(path));
           }
           catch(IOException IOE)
           {
           StreamTransformationException STE = new StreamTransformationException(IOE.getMessage(),IOE);
                STE.setStackTrace(IOE.getStackTrace());
                throw STE;
           }

Please help.

Regards,

Nitin Patil

former_member184720
Active Contributor
0 Kudos

Did you create the binding? Pt:5

Parameterized Java Mappings - Enterprise Services Repository - SAP Library

don't wait for this, first do an end-end to test by hard-coding the value in java code.

We have several SAP notes reg paramterized mapping. You can look for them and see if any of them are applicable to your installation.