1

I extended the DataFormWebPart to use a SoapDataSource and get the data from the lists.asmx webservice

it works fine as long as i access data from the same webapplication but as soon as i try to get some data from another webapplication i get the execption.

System.Net.WebException: The remote server returned an error: (401) Unauthorized

My code looks like this:

private SoapDataSource CreateDataSource(string webUrl, string listName)
{
    SoapDataSource source = new SoapDataSource();
    source.WsdlPath = string.Format("{0}_vti_bin/lists.asmx?wsdl", webUrl);
    source.SelectUrl = string.Format("{0}_vti_bin/lists.asmx", webUrl);
    source.SelectAction = "http://schemas.microsoft.com/sharepoint/soap/GetListItems";
    source.SelectPort = "ListsSoap";
    source.SelectServiceName = "Lists";
    source.AuthType = "None";
    source.SelectCommand = string.Format(@"<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""><soap:Body><GetListItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/""><listName>{0}</listName></GetListItems></soap:Body></soap:Envelope>", listName);

     return source;
 }

When i change the type to "Basic" and set the AuthUser and AuthPassword to an authorized user it works (but not with Auth="Windows" The Webapplications have the same apppool user and are on the same farm (i already checked that registry DisableLoopbackCheck-thing))

2 Answers 2

1

This sounds like it may be the double hop issue. In this instance you're asking the web server to impersonate the user with a request to another web service (regardless of whether its on the same machine or not)

Unless you're using Kerberos, then you won't be able to use windows authentication as NTLM won't delegate. The fact that when you set a Username and Password in the code it works i think confirms this theory.

Use Kerberos, or Use a static username and Password are I think your only options.

Paul

-1

There are many possibilities for this error. Check out these link, maybe it could help you. http://sharepointconnoisseur.blogspot.com/2011/04/how-to-resolve-401-unauthorized-error.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.