General N-soliton solution of the AKNS class on arbitrary background