Ashley Cole has retired from international football after being told he would not be in England's World Cup squad.