A method for the evaluation of strongly inhomogeneous residual stress fields in the near-surface region of polycrystalline materials is introduced, which exploits the full information content contained in energy-dispersive (ED) diffraction patterns. The macro-stress-induced diffraction line shifts Delta E-psi(hkl) observed in ED sin(2)psi measurements are described by modeling the residual stress state sigma(ij)(z) in real space, based on Rietveld's data analysis concept. Therefore, the proposed approach differs substantially from currently used methods for residual stress gradient analysis such as the 'universal plot' method, which enable access to the Laplace stress profiles sigma(ij)(tau). With the example of shot-peened samples made of either 100Cr6 steel or Al2O3, it is demonstrated that the simultaneous refinement of all diffraction patterns obtained in a sin(2)psi measurement with hundreds of diffraction lines provides very stable solutions for the residual stress depth profiles. Furthermore, it is shown that the proposed evaluation concept even allows for consideration of the residual stress component sigma(33)(z) in the thickness direction, which is difficult to detect by conventional sin(2)psi analysis.