Complete Arcane pg 72
"Any spell that requires an attack roll and deals damage functions as a weapon in certain respects."
How dare you quote something I really haven't read that much!
(Though I thought this had been covered in the PHB, hadn't it? Or is it simply that I'm such a genius I already did it this way

)
Now to be serious.
The crux of the situation:
It is not strictly the "type" of action being used that generates an AoO it is the action of making an attack with a ranged weapon. A rules terminology peculiarity.
You're not going to like this, I guarantee it. Very few people here have (though strangely everyone I've spoken to, face to face, agrees with me. Maybe it's just my personal charm.

). From the
glossary:
Action
A character activity. Actions are divided into the following categories, according to the time required to perform them (from most time required to least): full-round actions, standard actions, move actions, and free actions.
Under strict RAW, a single ranged attack is a standard action that provokes an AoO.
Likewise, casting a spell with a casting time of a standard action provokes an AoO.
Therefore, casting a spell, with a casting time of a standard action, that has the effect of a ranged attack is two standard actions. Yet, a creature may not (usually) perform two standard actions in a given round.
This basically means only three things:
1) Either the creature cannot perform both actions in a single round.
2) Or, one of the actions is not a standard action, such as a free action.
3) Else, a creature can cast a spell with the effect of a ranged attack as a single action.
So for there to be two AoOs provoked, then either #1 or #2 applies. If #3 applies then there must be some rule, somewhere, that says that either casting a spell, or making a ranged attack that is not an action by iteself provokes an AoO. For example, one provokes by making a move action, yet one can also provoke for movement not specifically addressed as an action (e.g. as part of a move action).
I prefer a literal, strict gamist perspective on the rules as I believe the writers intended (hence, specific keywords and the like). So, to me, it must be a single action (#3). Therefore, it provokes a single AoO since AoOs are (usually) provoked for actions.
For example an archer with multiple attacks is using a full attack action in order to do so with his longbow. The full attack action does not generate an AoO but attack (Ranged) does. Does he generate an AoO by attacking with his bow for attacking someone at range? Or ar you claiming that he does not generate an AoO when using the full attack but only when making a single attack?
I have an answer for this, but I want to see what you say about the rest first.
It doesn't say attack action with a ranged weapon it says attacking with a ranged weapon.
Yes, but any rules lawyer would point out that in none of the rules you mentioned does it ever say that a ray and the like
are ranged weapons, simply that they are weapon-like, "as if a ranged weapon", and "function as ... in certain respects." What I would prefer from the rules is a more specific contextual based explanation of how they are similar. For example, the "as if" is clear because you aim "as if" meaning, contextually, they are talking about LOE, etc. (and they address LOS subsequently).
In the end, though, as everyone agrees, no seems to play it that way. To me, this seems to give a strong indication that perhaps, just perhaps it isn't RAW. Then again, it used to be pre-3.x RAW that dead was 0 (-1?) hps, yet no-one, generally speaking, ever played it that way.