Zombies, Zombie Pigmen, Skeletons, and Wither Skeletons all have an inner limit to their (melee) attack area. This means that if you get too close to them, they aren't able to hit you. It's difficult to do normally, due to the attack knockback, but if you use an item with a knockback modifier it's easy.
/give @p minecraft:bedrock 1 0 {AttributeModifiers:[{AttributeName:"generic.knockbackResistance",Name:"generic.knockbackResistance",Amount:100,Operation:0,UUIDLeast:713578,UUIDMost:353488}]}"Environment
Operating system: OSX 10.9.5
Java Version: 1.6.0_65
sounds like MC-97754