Upload a file upload to a BW server

In this new post we are going to know how to upload file to a TIBCO BusinessWorks Server, so we can learn how to deal with some important aspects like groups, http transport, and so on. We are going use an HTML file to define a form that upload a file to our system.

When we want to upload a file we can use many approaches but the main way is via and HTML page using the input type ‘file’. So you need to write a code like this:


<form action=”upload_file.php” method=”post”
<label for=”file”>Filename:</label>
<input type=”file” name=”file” id=”file”><br>
<input type=”submit” name=”submit” value=”Submit”>


Notice the following about the HTML form above:

  • The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. “multipart/form-data” is used when a form requires binary data, like the contents of a file, to be uploaded
  • The type=”file” attribute of the <input> tag specifies that the input should be processed as a file. For example, when viewed in a browser, there will be a browse-button next to the input field

With this code or a similar one we have the opportunity to receive the file and its contents inside our BW process and do whatever we want with it. So, we must define a Process Definition inside our project that uses an HTTP Receiver Starter, and process the content of its output.


We can iterate over a set of nodes using the group capability of TIBCO BW. The group is a set of BW activities that have a external functionality, like a try/catch block or a loop block in any modern programming language. The concept is the same in here, we can use groups to define behaivour for this groups of activities such as iterate, while, transactions, lock, in this case we’re going to use an iterate group because it’s the best matching our needs but we can do the same with an while-group or another iteration-like group.

We are here iterating over the HTTP response so we can find the parameters that are file related and, in this case, dump it out. After there is a HTTP reponse so the form has its own repsonse. But you must be aware that the behaviour of the HTTP Receiver activity its not the same if there is only one field in the form or it exist more than one (this is not due to BW, its a HTML definition in the form-data/multipart option). Ok We are going to take a deeper look of this behaivor. If we have an HTML form like that:

<form method=”post” enctype=”multipart/form-data” action=”http://localhost:9876/test“>
<table cellpadding=”5″ cellspacing=”0″ border=”0″>
<td>Input File</td>
<td><input type=”file”
<td>Input Submit</td>
<td><input type=”submit”></td>

The output of the HTTP Receiver Output will be similar to the following:


And it differs when the form has more fields, in this case we have the following:


You can see there is a lot of difference between the two output, while in the first output all the content of the file is in the BinaryContent field, in the other output is there inside the mime part estructure, with much more options, like the name of the file (parameter file name) and so on.

So, the first thing we have to do is to have a branch to identify the two types of request we can have inside our process, and we do this, counting the number of mimeParts we have in our response, setting the following condition in our transition:

count($HTTP-Receiver/ProcessStarterOutput/pfx:mimeEnvelopeElement/mimePart) = 0

Now, we can process the different output as we need it. Now, I am going to show a image of the process definition I’ve created to process the content:


If you want to take a deeper look to this process I left you the BW Project so you can test it, and improve it, and we can discuss anything you want it this blog or vía email. You can download it here: Download!

I hope you can use these information in your new developments! See you in the next post!


One thought on “Upload a file upload to a BW server

  1. I am not able to pass chinese characters through html form.I have set the UTF-8 encoding in form. In Http Receiver output it shows some junk data in place of chinese characters.Can you try this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s