I don't know how others did it, but I once caught an engineer of the CZ on big ten relieving himself of his body's solid waste on one of the F-9's, he was hanging on to the grab irons while poking his posterior out the door in pursuit of bodily relief. This being on the outside of the curve, he could not be seen by the passengers on the train. I suppose that he either brought his own TP or used a train order.
On steam locomotives, I am told that it was commonplace for one of the crew to adjourn to the tender, relieve himself in a scoop shovel and throw the evidence into the firebox with a load of coal.
Urination is simple, pretend that you're a dog, whip it out and pee on anything that will drain to the ground.
Rick