The vote against the war is the latest in a series of setbacks for a president who has bent Congress to his will for most of his second term.