Reconciliation of dispersion theory with experiment in anomalous x-ray scattering