How do I solder a wire to a motor body?
There are two problems:

Heat

A motor is a large piece of metal, so the heat applied to one spot will quickly spread to the large volume. As you don't want to heat the complete motor to soldering temperature, you have to apply the heat as fast as possible. Choose a high power solder iron or at least set your iron to the highest possible temperature. I also prefer a small torch. (But be careful, it can easily overheat your motor and damage it)

As said in the comments, it also takes long to cool down, so make sure that the motor and the wire don't move while the tins is not yet solid. Holding by hand is not a good idea.

Material

Solder/flux used for electronics works well for metals found in electronics, e.g. copper, tin, gold, but also zinc. 

On the other side, iron can not be soldered that easy. The tin will roll off just like water from a waxed surface. To solder iron, solder tins with a high fraction of lead are used, as well as flux based on zinc-chloride. In my experience, electronics solder tin and zinc-chloride based flux usually work fine for a reasonable conductive connection. The special solder tins for iron also require a higher solder temperature. Note that zinc-chloride is quite aggressive and you should carefully remove it after soldering.

However, many iron parts have a zinc coating and can be soldered without problem. But parts are often also coated with some painting, e.g. a thin yellow-greenish painting to prevent corrosion, and of course, you have remove it before painting. May be, you manage to remove the painting but keep a zinc coating.

There are also other metals like aluminum which are quite impossible to solder.