We have WCF SOAP web service hosted in Sharepoint 2010 using service factory method and observe behavior which we cannot explain.
When authenticated web client invokes our service method “Generate” (synchronously) it is first get called with Anonymous credentials (SPContext.Current.Web.CurrentUser
== null). Anonymous users don’t have enough permissions, so the first attempt of the service method to access a folder (SPContext.Current.Web. GetFolder("Shared Documents")) throws ThreadAbortException. But control does not return to the client. Instead
the service method gets called AGAIN, now with correctly set SPContext.Current.Web.CurrentUser. Nowit works successfully to the end and result returns to the client.
The question which puzzles us a lot is WHY the service is called first time with Anonymous creds? We’d rather avoid this first invocation if possible.