Recovering the real-space correlation function from photometric redshift surveys