Yes, if you're purely on the defensive you can be at war with the Papacy but in good Christian standing. One other thing to keep in mind regarding excommunication, just a sidenote really, check out your king's age and that of the pope before launching an attack that will probably get you excommed. If either are in their twilight years it might be worth it to bite the bullet and then let them die off afterwards to restore your communion with the faithful. One of numerous ways to deal with the pope's annoying tendencies.

Ajax