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