Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: SAP PI File to SOAP attachment

$
0
0

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());        }    }
}

Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>