I can give personnal insight on this.
In the united states military hand book I believe there is a cluase that covers this. If a superior officer or authoirty gives a order, that is unjust the ones who are supposed to carry it out can deny the order and refuse to do it. However VERY TIMES has this happened, mainly because well for one you can do it by yourself, but a lone man doing it does no good and he'll merely recieve the proper punishment. However if a large enough force denies a order, the order is kinda void. My dad says that he has only seen one direct order rejected like this in the past, and that was because the CO was demanding a guy do somthing very unsafe. The guy was court martialed for going aganist the officer, but instead the officer was punished for bad leadership and reckless behavior.
If enough poeple laid down arms, well heh then guess what no ones fighting. Laying down arms however does not mean you don't carry them. If I decided to walk out of enemy terrioirty i'd try and make it clear to the enemy I wanted to leave and back up I wouldn't drop my weopon.
The military commanders know that once moral hits a all time low, this will happen (happened in vietnam soilders started refusing to fight, so many were refusing to fight they couldn't punish them all)
Honsetly however the moral among military people is not at all time "high" but from what i've seen I don't see a mass AWAL happening anytime soon. Its not like WW2 where poeple WANT TO FIGHT, but they don't put up any resistance to being sent. However if the war goes on too long it'll start happening. I'm guessing teh military has a good 4 to 5 years before we have to worry about this if the sitution stays consant.
And truly if you had the entire military lay down arms WTF is their gov going do? Jail em? I believe this, and this true thoughout military history once your entire army ditches you, you've really messed up.
A example of a legal denying a order would be if a officer ordered you to kill a civilian who did not par-take in the fight, was un-armed or a POW. But then again even if you did kill him you could get off as well by saying "I am a solider and was merely following orders" if a order violates basic human rights you have a right to deny it, or if you consider the order to be unjust (just need to convice the judges in your court martial that you it was unjust)
A example of a illegal denying a order would be if your CO told you to move to a certain position in a battle that could mean you'd die. Example if you were under heavy fire, your CO orders you to go take right flank to give cover fire and you refused because you didn't wanna risk getting your head blown off then that would result in you getting to spend some time in jail, but then again you could always cry out that you were shell shocked or claimed to have some temopary mental illness.
90% of the time when a order is denied the person gets in trouble. So its not very common. My dad didn't get in trouble because the CO wanted to cut time, and his order would of risked the lives of several poeple., and voilated several safety measures.