If you wish to respect their relationship, and if his wife has explicitly said that there will be no other, and they will be monogamous, then you need to set some boundaries for your communication, and, when he oversteps them, be very firm about it. For the friendship to continue, he HAS to respect those.
The problem with "harmless flirting" is that it is rarely harmless. A good question to ask, in situations like this, would be "if his wife saw this, would she be upset?" If the answer isn't an immediate "no", then a boundary has been crossed.
Does that help?
"Listen, or your tongue will make you deaf." - Native American Proverb