The foundation of military law is the Constitution of the United States.
The Constitution provides that Congress has responsibilities to make rules to regulate the military. Congress implemented its responsibilities over military justice by enacting the Uniform Code of Military Justice (UCMJ), a federal law that is contained in Title 10 of the United States Code, Sections 801 through 946.
See www.hqmc.marines.mil - MILITARY JUSTICE FACT SHEETS for more info.
When one enlists in the United States Military, they take the following oath:
I do solemnly swear (or affirm) that I will support and defend the Constitution of the United States against all enemies, foreign and domestic; that I will bear true faith and allegiance to the same; and that I will obey the orders of the President of the United States and the orders of the officers appointed over me, according to regulations and the Uniform Code of Military Justice.
Article 90 of the Uniform Code of Military Justice (UCMJ) makes it a crime for a military member to willfully disobey a superior commissioned officer.
Article 91 makes it a crime to willfully disobey a superior Non-commissioned or Warrant Officer.
Article 92 makes it a crime to disobey any lawful order (under this article, the disobedience does not have to be "willful").
The Code of Conduct (not part UCMJ) is the legal guide for the behavior of military members who are held by hostile forces. It is a personal conduct command for members of the American armed forces throughout the world.
It takes account of basic information useful to U.S. POWs in their struggles to live on while fighting their captor's efforts to exploit them.