How can we upload files to the pipeline when using JBoss FSW 6?

Solution Verified - Updated -


  • Red Hat JBoss Fuse Service Works (FSW)
    • 6.x


  • We would like to upload a file to be processed by FSW pipeline. What could be used to achieve that?

  • We are developing a Switchyard REST application. We have no issue in consuming "text/plain". But when we try to consume "multipart/form-data", we are getting the following error: "Could not find message body reader for type".


It is possible to use a REST Binding to receive an HTTP body as an input stream:

  • Create the REST Resource:
 * REST resource to receive the binary content. You could receive in another
 * ways, like use Multipart. See resteasy 2.3.x docs for more information
 * @author wsiqueir
public interface ByteResource {

    public void receiveBytes(InputStream is);

  • Make the Service:

public interface ByteService {
    public void receiveBytes(InputStream is);
  • And an implementation for this service, for example:
import javax.activation.DataSource;
import org.switchyard.component.bean.Service;

public class ByteServiceBean implements ByteService {

    public void receiveBytes(InputStream is) {
        System.out.println("RECEIVING DATA...");
        // WARNING: not the best impl.., but works as a test
        try {
            File f = File.createTempFile("switchyard", "");
            FileOutputStream fos = new FileOutputStream(f);
            byte buffer[] = new byte[2048];
            while (( != -1)) {
            System.out.println("-- Data written on " + f.getAbsolutePath());
        } catch (IOException e) {
            throw new Error(e);
  • Now use the REST Resource as a gateway for your service:
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-config:1.0" xmlns:resteasy="urn:switchyard-component-config:1.0" xmlns:bean_1="urn:switchyard-component-bean:config:1.0" xmlns:resteasy_1="urn:switchyard-component-resteasy:config:1.0" xmlns:sca="" xmlns:soap="urn:switchyard-component-soap:config:1.0" xmlns:transform="urn:switchyard-config:transform:1.0" xmlns:validate="urn:switchyard-config:validate:1.0" name="ByteService" targetNamespace="urn:switchyard-quickstart:bean-service:0.1.0">
  <sca:composite name="ByteService" targetNamespace="urn:switchyard-quickstart:bean-service:0.1.0">
    <sca:component name="ByteServiceBean">
      <bean_1:implementation.bean class="com.redhat.gss.fsw.ByteServiceBean"/>
      <sca:service name="ByteService">
        < interface="com.redhat.gss.fsw.ByteService"/>
    <sca:service name="ByteService" promote="ByteServiceBean/ByteService">
      < interface="com.redhat.gss.fsw.ByteService"/>
      < name="rest">

Attached are two sample applications which demonstrate how to receive a file in Switchyard, and how to handle multipart form requests.


This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.