Return to doc.sitecore.com

Valid for Sitecore 5.3
Why do I get this webservice error while publishing?

Q:

I wrote some additional code for the OnPublishEnd event. In this event I called a method in a webservice. The webservice is running on the same server as Sitecore. The webservice works fine when called by the URL. However, if I publish the site, I get the following error:

/upload/sdn5/faq/api/webserver error/webservice_error2_mm.jpg

A: 

The problem is not with Sitecore but with ASPNET security. Please take a look at this URL: http://blogs.msdn.com/habibh/archive/2005/05/25/421954.html

There are two ways to fix this error.

  1. Disable NTLM authentication (see below).
    /upload/sdn5/faq/api/webserver error/webservice_error1_mm.jpg
  2. Use the following code before calling WebService (pay attention to the lines in bold):

    Service1 WS = new Service1();
    WS.PreAuthenticate = false;
    WS.Credentials = System.Net.CredentialCache.DefaultCredentials;
    string helloWord = WS.HelloWorld();
    Log.Info("Calling WebService is Ok: " + helloWord, this);