That sound suspiciously like dogs with bees in their mouths and when they bark they shoot bees at you.
Do I detect the martian chronicles?

Just to play, solders will carry guns whilst their main targets are vulnerable to guns. I can't see any possibility that all over body armour will be able to defeat a bullet (bearing in mind that if armour could defeat current bullets, it would be relatively easy just to increase the energy of the round. In fact modern infantry weapons have been going the other way so it could be as easy as just going back to a good old .303). Therefore all the while soldiers fight soldiers they are going to carry guns of some sort.

If the main adversary changes then I guess guns could become obsolete/change radically. There was a story a while back about the US continuing to work on pilotless drones and battlefield robots, and supposing they became the major feature on the battlefield then I guess you can at least imagine there might be better ways of disabling them than shooting projectiles at them. Maybe a heavily armoured robot could be best disabled by overloading its sensors in some way, for instance. Or, IIRC, there are artillery rounds which "loiter" over a battlefield, only to direct themselves down onto a target when it is illuminated with a laser designator by an infantryman. So the weapon of the future could be a laser pointer...

Mind you even then for morale reasons if no other I bet soldiers will still be carrying a gun of some kind.