Step 1: Placing the Despensers
make a big row of despensers about 10-15 long(don't curve it like I did)
Step 2: Load 'em Up
You need a lot of arrows and then put them in the despensers
Step 3: Making the Mechanics
Put 2 powered rails then 1 detector rail for the length of the defence system, next, put 1 powered rail at each end with a block behond it
(this makes the cart go back and forth).
Then, put redstone wire down to the despensers (each powers 3)
Put a redstone torch down for each 2 powered rails.
Step 4: Start It Up
At one end of the rails, next to the block, put a lever instead of a torch by the last powered rail (this is your on/off switch)
Put a minecart down and push it to get it going.
Now it works.
Step 5: Other Ideas
Another thing you can do is place it in a giant square and put castle walls on top of it.
Then, make a circular track with the same functions.
Smaller model shown below.