Is it ok to use a ground rod at a subpanel instead of a fourth wire?
To make this easier, consider the grounding conductor (the ground wire) as a backup neutral. It's not used unless a ground fault occurs, in which case it's only purpose is to provide a path back to the source so that a protective device will trip. (breaker, fuse, etc.)
Your grounding electrode system on the other hand, the ground rod here, is only used for over-voltages on the line such as static or potentially lightning. Although we bond the grounding system, they serve two different purposes.
So for your first question: no, it is not against code to install a ground rod at the subpanel. It is actually required by code.

NEC 2014 - 250.32(A)
Grounding Electrode. Building(s) or structure(s) supplied
by feeder(s) or branch circuit(s) shall have a grounding
electrode or grounding electrode system installed in
accordance with Part III of Article 250. The grounding
electrode conductor(s) shall be connected in accordance
with 250.32(B) or (C). Where there is no existing grounding
electrode, the grounding electrode(s) required in 250.50
shall be installed.

The only exception to that being that if you were only running a single circuit (or multiwire branch circuit) with a ground wire, then you would not need an electrode system.
Now on to your next question on if a metal stake/metal building works as an electrode: yes and no. There are a few conditions were these could apply, but they do have to have direct contact to the ground (the earth itself, the dirt or concrete below). Check out 250.52 (NEC 2014) for the list of electrodes that can be used.
Lastly, all new feeders to outbuildings must contain a ground wire. Previously they were not required, but this is no longer legal or up to code for new installations. However, modifications to existing 3-wire systems do not require the pulling of a new ground wire as long as it fits a few requirements for the exception; as seen in 250.32(B) (NEC 2014)