The army men

Puzzle Question: 

There are 4 army men. They have been captured by a rebel group and have been held at ransom. An army intelligent officer orders them to be burried deep in dirt up to their necks. The format of their burrial are as shown in the figure.
Conditions
• They each have hats on their heads. either black(b) or white (w) look at diagram above. There are total 2 white hats and 2 black hats.
• They only look in front of them not behind. They are not allowed to communicate by talking.
• Between army man 1 and 2, there is a wall.
• Captive man 4 can see the colour of hats on 2 and 3
• 3 can only see 2's hat
• 2 can only see a wall and 1 can see a wall too, but is on the other side
The officer speaks up, "If one of you can correctly tell me the colour of your hat, you will all go scott free back to your contries. If you are wrong, you will all be killed.
How can one of them be certain about the hat they are wearing and not risk the lives of their fellow souldiers by taking a 50/50 guess!

Toughness: 
Intermediate