There are some really good suggestions in this thread. Neither do I have anything against the use of soap 'n water—Just as long as you remember NOT to use hot water. Hot water and Glock's D6 polymer do NOT get along well together.
I'm, also, going to remember that baking soda trick; it sounds pretty neat!
Years ago I used to buy military rifles, take them apart and rebuild them for resale. Cosmoline removal was always a problem; and, for the life of me, I can't imagine anything stickier or more viscuous than cosmoline.
After removing all the metal parts from the wooden ones, I used just plain, good old fashioned, 'white' kerosene in order to clean the metal. (It was a messy job; and I had to use a lot of old rags and paper towels.)
Soap and water would work too; but that really made for a real mess, and took a lot of extra effort.
There are a number of commercial products to make this job a little bit easier. Many automotive stores carry 'A&L Cosmoline Remover', which is also safe to use on painted surfaces.
Two other commercial products that will remove both Cosmoline, as well as all different sorts of other adhesives and sticky goo-goo are 'SL245' and (Ready?) WD-40.
Finally, it's always a good idea to make sure you've got plenty of old rags, along with a large roll of paper towels before you begin a job like this. Give some thought to how you're gonna get rid of all of the [often flammable] clean-up garbage, too.