A moment problem for self-adjoint operators