In this article written in 1983, Rav Ariel deals with the question of whether or not soldiers are allowed to refuse orders. Specifically, he grapples with the issue of refusing the order to clear out Yamit and to invade Beirut. He also discusses following an order to begin a siege on Shabbat, as well as doling out collective punishment to Arabs in Yehuda and Shomron. The common denominator of all of these cases is the presence of a religious, halachic, or national consideration that stood in opposition to the official military order.
Rav Ariel's first approach is to consider a military order in the context of being a גזירת המלך. Rambam, based on the Gemara in Sanhedrin says that one may disobey a military assignment if it contradicts a mitvza, since דברי הרב ודברי התלמיד דברי מי שומעין - we obviously listen to God over listening to any of His subjects if the two are in contradiction to one another. In this vein, he cites a teshuva of the Chacham Tzvi who compares listening to a royal decree to the mitzva of כבוד אב ואם, specifically with regard to the fact that in neither case may one violate another mitzva in order to obey or respect another human. However, there are Rishonim who qualify this. The Meiri in Moed Katan writes that one may set learning Torah in order to do a mitzva that cannot be done by someone else, such as respecting one's parents, and in Sanhedrin he writes that a royal edict cannot override the public study of Torah, but it can override study by an individual.
Rav Ariel then distinguishes between כבוד and מורא, between respecting one's parents and fearing them, noting that in the former case one can set aside a mitzva, but not in the latter. As such, when it comes to following a royal order, since we are only commanded to fear a king, we can ignore the order we are doing so in order to perform a mitzva. Extending this line of thinking to our cases, Rav Ariel rules that refusing orders for a subjective לשם שמים purpose would not constitute a rebellious act.
From there, Rav Ariel considers a view of the Netziv that refusing an order contains an element of פקוח נפש, to the possible extent that someone who refuses an order is considered to be a rodef insofar as he is potentially endangering others while he remains safe at home (based on the story in Bamidbar of Bnei Gad and Bnei Reuven). However, Rav Ariel also considers the spiritual peril that is brought about by an order that demands that someone violate halacha. As such, he advises soldiers to determine whether an order is objectionable from a subjective or an objective perspective, and to take counsel with a posek if they are not capable of making such a determination. Furthermore, he concludes that if it is too close to call, then the danger posed by refusing an order outranks the danger of fulfilling an order that seems to violate a halachic position, and in such a case the soldier should fulfill the order given to him.
In the conclusion, Rav Ariel deals with the specific cases that were brought to him:
1) With regard to a siege in the Sinai that was to begin on Shabbat, apparently this particular order was not an emergency situation, and thus Rav Ariel felt that one could refuse such an order. However, he noted that in general one can violate Shabbat for a military mission under emergency conditions.
2) With regard to evacuating the Yamit settlement, Rav Ariel ruled that soldiers were obligated to follow orders, based on the reasoning that the governmental decision to give over Yamit may have been a mistake in judgement, but was not intended to harm the Jewish people or the State of Israel. (See the statement by Mori V'Rabi HaRav Aharon Lichtenstein on the disengagement from Gaza in 2005 for more on this issue.)
3) With regard to soldiers who did not want to go to Beirut, Rav Ariel ruled that they are required to go, as refusing an order in a wartime situation is a particularly egregious act. Since one cannot prove objectively that the war is wrong and any arguments on that issue are based on one's political worldview, there is little room to allow for someone to be a conscientious objector.
4) With regard to soldiers asked to adminsiter collective punishment to Arab residents of Yehuda and Shomron, Rav Ariel permitted them to refuse the order assuming that the order was objectively in error. He felt that most of the Arabs living there were not actively at war with Israel and thus we nee to consider the idea of maintaining דרכי שלום with our non-Jewish neighbors.