Noncommutative residues and a characterisation of the noncommutative integral