Apparently, a predominant view is that the ordinary soldier who follows decent military orders (ones that do not transgress jus in bello) in an unjust war does not do wrong.
This view seems quite clearly mistaken, though. First of all, it is always wrong to formally cooperate with an evildoer, where to "formally cooperate" is to share an intention in virtue of which the evildoer counts as an evildoer. But in an unjust war, the leaders of one's country are evildoers (perhaps non-culpable ones, but that doesn't matter), and they are evildoers in part because they intend the deaths of enemy soldiers. Thus the ordinary soldier in intentionally killing enemy soldiers is formally cooperating with evil. Moreover, even if the cooperation were not formal but material (i.e., the cooperator did not share any of the evil intentions of the evildoers, but nonetheless materially contributed to the evil), given the fact that few evils on the face of the earth are as bad as an unjust war, the presumption against such cooperation would still be almost indefeasibly strong.
Second, the state lacks the authority to permit one to intentionally kill those who are doing nothing wrong. That is simply an invalid exercise of the state's authority. This is particularly clear when the unjust military action takes place on the territory of the victim state, since except in cases like lawful self-defense or of embassies, one is bound by the laws of the state that one is in the territory of, but it is also true when the action takes place within the territory of the unjustly warring state. To kill those who are doing nothing wrong is, simply, wrong. So it is wrong to kill in an unjust war when the other side is acting justly (there are wars that are bilaterally unjust--this argument does not apply to those), since then one is killing soldiers who are acting in a morally permissible manner, viz., by engaging in a just war.
But suppose that it is objected that while the state waging the unjust war acts impermissibly in authorizing the killing of the enemy, the authorization nonetheless "succeeds", i.e., the individual soldiers on the unjust side do become authorized. This seems mistaken, but suppose it. Then we get a third argument. If it were not wrong to engage in combat on the unjust side, there would be no such thing as a just war. For in a just war, the state permissibly authorizes the killing of enemy soldiers. But it is wrong for the state to authorize the killing of people who are doing nothing wrong. Hence if the soldiers on the unjust side are doing nothing wrong, it is wrong for a state with justice on its side to authorize killing them. And that is absurd.
Objection: One can defend oneself lethally against someone who is doing nothing wrong. Response: That seems mistaken. If I have broken legs and can't move, and a toddler with a deadly communicable disease is running towards me, I do not have the right to shoot the toddler before he gets to me.
Note that it seems that what I said is compatible with the claim that the soldiers on the unjust side are, frequently, not culpable for their wrongful actions. It seems to me--and I could very well be wrong--that lethal state-authorized self-defense is concerned with stopping evildoers, rather than with stopping culpable evildoers. Culpability requires an individual judgment that is not practicable. Alternately, one might here make the move that Cardinal Ratzinger does in an essay on conscience, which is that even those who are ignorant of the moral law are guilty of having blinded themselves to the moral law. However, in some cases, the enemy soldiers are not ignorant of the moral law, but of the relevant facts of the situation (e.g., some German soldiers may have falsely believed that Poland invaded Germany).