InfoPath 2010 with SharePoint 2010

Recently I was working with a customer where we were auto populating AD attribute values into InfoPath form. We were using this link to do auto populating.

When we tried to preview the InfoPath form, we were hit with the following error

My first guess was that the SOAP connection might be wrong. We double checked that we had the right URL  ( it was http://server/sites/sitename/_vti_bin/userprofileservice.asmx , the site were InfoPath was getting published ).

After a lot of research and searching on the net we found that Anonymous Access was the culprit. Once we disabled Anonymous Access in IIS for that site, it started working.

Hope the information was helpful.