0
votes

Please help to solve the problem. I have application. It calls SharePoint web-service List.asmx to get list elements. Here the code:

Lists listService = new Lists();

NetworkCredential credentials = new NetworkCredential();
credentials.UserName = serviceUserName
credentials.Password = servicePassword;
credentials.Domain = domain;

listService.Credentials = credentials; 
listService.Url = serviceUrl.ToString();
XmlDocument xmlDoc = new XmlDocument();
XmlNode nodeListItems = listService.GetListItems(categoryListName.ToString(), null, null, null, "10000", null, null);

The credentials user has access to the list site. If I deploy application on any server, is's ok. I get elements of List. But if I deploy application one the same server with list site, I get an Error 401: Unauthorized.

How can I solve the problem? I realy need to deploy application on the same server.

1
Is it SharePoint 2010 or SharePoint 2013 or SharePoint O365??Saratchandra

1 Answers

0
votes

A bit of research and I found the reason behind it. The .Net 3.5 framework introduces a loop-back problem that affects web service authentication in SharePoint. This issue doesn’t allow web services to be accessed by any mode (client/tool/server). Microsoft decided to introduce this, but unfortunately it breaks a number of different things in SharePoint. Hence a registry entry has to be created in the web front end servers to resolve the loop back issue.

Implementation Perform below steps on each of the SharePoint Web Front End Servers.

  1. Click Start, click Run, type regedit, and then click OK.
  2. In Registry Editor, locate and then click the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. Right-click Lsa, point to New, and then click DWORD Value.
  4. Type DisableLoopbackCheck, and then press ENTER.
  5. Right-click DisableLoopbackCheck, and then click Modify.
  6. In the Value data box, type 1, and then click OK.
  7. Quit Registry Editor, and then restart your computer.

https://askmanisha.wordpress.com/2014/03/26/401-unauthorized-error-while-calling-a-web-service/