Corroding casings of wells generate negative self-potential (SP) anomalies, increasing from about -10 to -500 mV in the vicinity of the well to 0 mV at large distances. As reported in previous laboratory experiment, SP can be used to retrieve the distribution of electrical potential along the casing, which is somehow a proxy for the corrosion state of the casing. These studies used 3D (whole space) or surface 2D (whole surface) measurements of SP distribution; here we reported a field example, for which only a 1D surface SP profile is available. In order to retrieve the most probable associated potential distribution (defined by a spline) along the 11.1-m long metallic casing, we develop a direct model based on geometrical and geoelectrical properties of the medium, which was then used in a (non-deterministic) optimization procedure by simulated annealing, including some physical constrains. Tests carried out on a synthetic case allowed the initial source to be correctly retrieved, provided that the number of nodes used for the spline defining the potential distribution along the casing is large enough. The inversion of real field data provided a dipolar anomaly, with minimal negative amplitude of around -600 mV at 5 m, and maximal positive amplitude of about 1100 mV at 9 m (close to the level of the water table), this shape being in agreement with the results of previous laboratory studies.