I'm having difficulty setting up a WCF service to talk to Sharepoint web services, in particular, I'm trying to use List.asmx and Copy.asmx services.
I worked using the http link for sharepoint for development, but now we need to switch to the HTTPS link. I got the configuration of web links and updated this link, but when it tries to call a service (for example, GetListItems), it gives an error with the following error: Request failed with HTTP status 401: Unauthorized.
Then I tried to figure out what type of authentication our Sharepoint server uses, which turned out to be NTLM. Then I tried to configure the web.config file for this. Here is the whole web.config file:
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="InventoryService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> </sectionGroup> </configSections> <appSettings/> <connectionStrings/> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> <authentication mode="Windows"/> <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="NewBinding0"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Ntlm" proxyCredentialType="None" /> </security> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration="InventoryService.Service1Behavior" name="InventoryService.InventoryService"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0" contract="InventoryService.IInventoryService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="InventoryService.Service1Behavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <applicationSettings> <InventoryService.Properties.Settings> <setting name="InventoryService_WSCopy_Copy" serializeAs="String"> <value>http://site/_vti_bin/Copy.asmx</value> </setting> <setting name="InventoryService_SharepointLists_Lists" serializeAs="String"> <value>https://site/_vti_bin/Lists.asmx</value> </setting> </InventoryService.Properties.Settings> </applicationSettings> </configuration>
If anyone has a key, if I configure this configuration file for NTLM correctly, it will be really useful.
If this is configured correctly, I think I will move on to the next question about whether I will configure the credentials correctly:
inventoryList = new SharepointLists.Lists(); inventoryList.Url = "https://fullsiteurl/_vti_bin/Lists.asmx"; inventoryList.Credentials = new System.Net.NetworkCredential("user", "pass", "domain");
If someone can solve this, it will also be very helpful.
Again, I know that the configuration file is quite long, and I really appreciate if you go through it, let me know if I am setting up NTLM authentication correctly.
If all this is checked in order, then I donβt know where to start when the HTTPS connection with the working environment works (the existing HTTP sharepoint link is still available until I can get the service to work with HTTPS).