12V at 4A works out to a 3 ohm load. 48 watts.
You can store the energy in a capacitor. It would need to be a lot of uF.
How many uF? I calculate about 330,000. One-third farad.
How? I estimate a time constant of 1 should maintain the load above 6V for a second. Since TC=RC, and load is 3 ohms, then capacitance = 1/3.
Better to use maybe 4 capacitors, each delivering 1A. Such a bank might take up as much room as a C battery. You can fire it once, and then it will need time to charge to 12V again.
This may take several seconds. A popular way to obtain low V from mains is to use a capacitor. It generates reactance. Far less heat is involved. The schematic at this link would need several changes, in order to charge your capacitor fast enough to be practical. To limit it to 12V, you would substitute two 12V zener diodes in the diode bridge.
Transformerless power supply (electroschematics.com):
TransformerLess Power Supply 12V 100mA
---------------
In considering other methods:
Resistance: To drop 220VAC to 12VDC at 4A implies that you will put in a resistance of 55 ohms, which can handle 832 W for one second. It may be okay for a second, if you parallel several power resistors.
Reactance: Put a coil, or capacitor, inline with your solenoid. Not too practical since current is 4 amps. Needs either a beefy coil or a beefy cap.