You are correct
From the Attacks of Opportunity rule in the Combat chapter of the Core Rulebook:
An attack of opportunity “interrupts” the normal flow of actions in the round. If an attack of opportunity is provoked, immediately resolve the attack of opportunity, then continue with the next character’s turn (or complete the current turn, if the attack of opportunity was provoked in the midst of a character’s turn).
So the sequence would be, character B announces his action. Character A interrupts, and makes the AoO. If character B is still able to after resolving the attack, he can continue with his turn. As another example, character A might choose to use the Sunder maneuver as his AoO. If he does, he might destroy B's bow, rendering him unable to shoot, but still able to complete his turn.
In normal play, and depending on the terrain and situation, a character with a ranged attack who is threatened by another would normally just step back out of reach, and then shoot without provoking an AoO. Obviously, there are a myriad of reasons why this might not be practical or possible.