This is very straightforward. You may need to review the StringTemplate docs to fully understand the templates, but they are quite self explanitory. Also, take a look at the .cdrl configurations below. These configs describe how the beans above get populated, and when the StringTemplate scripts get executed.
For transforming the request, we have the TrackingNumberIn.st StringTemplate script. This script will use the "current" TrackingNumber bean instance.
For transforming the response, we have the HistoryTrans.st and TrackingNumberOut.st StringTemplate scripts. The TrackingNumberOut.st script will use the "current" Heading bean instance.
So, as you may have noticed, the TrackingNumberOut.st is called/included from the HistoryTrans.st script to output the multiple "trackingNumber" elements from the TrackingNumber bean list available from the History bean.