It's a tight fit; you'll have to avoid damaging the rather delicate end of the axle by using a wooden block or similar. I find the big thing most often overlooked is that the hammering force goes into bouncing the spokes unless you support the hubshell on something solid and heavy; otherwise you're just hammering a pillow. Maybe a short length of the right size plastic pipe.
It's not actually 'legal' to hammer on the inner race of any bearing. The balls will indent the races and possibly shorten their life. So hammering this axle out pretty much assumes that you would be tossing the bearings, which is what any shop would do anyway, considering the labor/parts cost ratio. However, if you pop the seals off, clean the grease out and they don't feel notchy under end load you can probably repack and reuse.
Then the subject of refitting the axle without pounding it back in comes up. Usually you can come up with some combination of long bolt or threaded rod and nuts, washers and tubing to make a press like a BB or headset press.
Something like that can also be fabricated to press the axle out in the first place as it is just the same tool fitted to go the other direction. Considering that the cost of the bits to make the tool is cheaper than the bearings and can be adapted to other things, why hammer unless you're tossing the bearings anyway. Pressing doesn't put the same high impact loads on bearings that hammering does. Plus, making your own tools is creative and fun.