cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI File to SOAP attachment

Former Member
0 Kudos

We have a scenario where we need to pick the xml file then send the same file as an attachment, but file sender will pick the file as an payload, how we can pick the xml file as an attachment to soap receiver. Do we have any standard modules for this or we need to write modules.

Accepted Solutions (0)

Answers (4)

Answers (4)

RaghuVamseedhar
Active Contributor
0 Kudos

Use below sample Java mapping.


package javaapplication1;

import java.io.InputStream;

import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class JavaApplication1 extends AbstractTransformation {

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

            throws StreamTransformationException {

        try {

            InputStream inputstream = transformationInput.getInputPayload().getInputStream();

            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

            // a) Just copy Input file content to Output attachment content

            byte[] b = new byte[inputstream.available()];

            inputstream.read(b);

            transformationOutput.getOutputAttachments().create("FileAttachment", b);

            // b) Populate output SOAP payload.

            //Option 1: If you want input file contant  as output SOAP payolad. Just write byte[] b (above) to output.

            //Option 2: After this Java mapping, use another Graphiical mapping to generate SOAP payload.

                       

            outputstream.write(b); //This option 1.

        } catch (Exception exception) {

            getTrace().addDebugMessage(exception.getMessage());

            throw new StreamTransformationException(exception.toString());

        }

    }

}

Former Member
0 Kudos

Hi Rudra Singh

Exclusion Mask option is not use, it is used to exclude particular files from the selection.

Former Member
0 Kudos

Dear Lakshman,

Please check below link

Specifying Additional Files in the Sender File Adapter - Advanced Adapter Engine - SAP Library 

U can achieve the same without AAE alos .

Got confused with exclusion mask n additonals files option

Regards,

Former Member
0 Kudos

Dear Lakshman,

Since its file to soap scenario. You can use Exclusion Mask option to add file as an attachment in file sender adapter.

Regards,

former_member184720
Active Contributor
0 Kudos

Please check below blog to set main document as attachment and then you just need to select keep attachments in soap adapter.