SharePoint has many services and list.asmx is one service which lets you deals with its list and document libraries. In following example we will see how to call GetListItems method in list.asmx service
Lets start by creating a Console application in VS 2010. We will name this project as ConsoleApplication1
Next thing we will add is the reference to service list.asmx
Above service reference will also add a app.config file. We need to edit some its setting for our NTLM SharePoint site.
<transport clientCredentialType="None" proxyCredentialType="None"
<message clientCredentialType="UserName" algorithmSuite="Default" />
After changes we should have something like following
<transport clientCredentialType="Ntlm" />
<!--<message clientCredentialType="UserName" algorithmSuite="Default" />-->
Above changes will help you get past following error
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'.
Now we will write implement our service call. We will query list with name TestList. GetListItems method will return all the items under request list in XML format.
static void Main(string args)
Following will be the output of above code