This idea has been suggested a handful of times in other threads with slight variations, but I would like to generalize this to a suggestion that I think we can all agree with: there should be an XP gain from successfully defending against attacks!
I have read a few older suggestions which requested similar features. One suggested that users should get experience for both successful defenses and unsuccessful defenses. This idea was rejected because, "It enables a scenario which makes a player reach level 100 without arming up or winning." The other suggested that successful defenses should award 2 XP and unsuccessful defenses should subtract 1 XP. (This suggestion never had a final verdict, but I am personally opposed to the idea of losing XP for losing a fight.) I am not necessarily in support of either of these ideas.
Instead, I would recommend a system in which a successful defense would result in an experience gain. This would require some conditions, though. For example, experience should only be gained if the defense is a result of an attack from a player of a similar level. After all, without that condition, anyone who was attacked by a level 5 account would earn experience, which does not seem balanced. By applying the level limitation, only successful defenses against worthy adversaries, so to speak, would result in an experience gain.
I believe such a system should pay out a random amount of experience between 1-3 XP to the defender. 1-3 XP is half of the possible range of experience that one earns from a successful attack. I do not think a defender who passively defends should earn experience as quickly as someone who actively attacks, hence why I would suggest cutting the the experience range in half compared to a successful attack. However, a big part of the game is defending and being able to hold your own. Thus, I think those who choose to go down the path of building up strong defenses should be rewarded for such, just as someone who chooses to go down the path of strong offense is rewarded.
Contrary to older suggestions, though, I do not think players should either lose or gain experience from unsuccessful defenses. Among other reasons, a player does not choose when or who they are attacked by. Players can be attacked at random by any other player within a valid level range, and if the attacker has diamond items, a lot of mercs, more gang arsenal, a larger mob, etcetera, then it might be an unfair battle to begin with, tilted in favor of the attacker, so it would not make sense, in my opinion, to remove experience points from the defender because the defender was not able to defend against an unfair opponent. If a player did lose experience from losing a battle, there would also be issues such as "leveling down" and then concepts would have to be implemented on how to handle level-restricted items, weapons, and properties that the user unlocked and purchased before being leveled down. On the other hand, it would not make sense to grant the defender experience points because they lost the battle. As Jim of DynamicNext said three years ago, this would be a system in which a player could grow without ever arming up or attacking. So, that does not seem proper either.
I would encourage DynamicNext and the developers of the game to consider adding in a feature which rewards a player with experience for defending if, and only if, the defense is successful and attacker is in a similar level range as the defender.