views:

709

answers:

1

Sharepoint is setup to use NTLM authentication.

When I reference http://myserver/Sites/Ops/_vti_bin/Lists.asmx?WSDL as a Web Reference, I can call the methods and get valid responses.

When I reference the same url as a Service Reference, the server throws an exception when calling methods.

My account is admin on the Sharepoint Farm.

This is the app.config for the service reference (mostly auto generated):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="TransportCredentialOnly">
                    <transport clientCredentialType="Ntlm" />  
                  </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://myserver/Sites/Ops/_vti_bin/Lists.asmx"
                binding="basicHttpBinding" bindingConfiguration="ListsSoap"
                contract="SharepointLists.ListsSoap" name="ListsSoap" />
        </client>
    </system.serviceModel>
</configuration>

Saddly, the only information the exception provides is this:

"Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown."

No other details.

The code that I'm using is:

 public ListClass()
    {

        _Client = new SharepointLists.ListsSoapClient();

    }

    public System.Xml.Linq.XElement GetTaskList()
    {
        return _Client.GetList("Tasks");

    }

Any thoughts? I would like to use the Service Reference rather than the Web Reference.

UPDATE:

I tried Rob's suggestion and got this error:

HTTP GET Error
    URI: http://myserver/Sites/Ops/_vti_bin/Lists.asmx

    The document at the url http://myserver/Sites/Ops/_vti_bin/Lists.asmx

was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'http://myserver/Sites/Ops/_vti_bin/Lists.asmx' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'. - Report from 'DISCO Document' is 'There was an error downloading 'http://myserver/_vti_bin/Lists.asmx?disco'.'. - The request failed with HTTP status 404: Not Found. - Report from 'WSDL Document' is 'The document format is not recognized (the con tent type is 'text/html; charset=utf-8').'. - Report from 'XML Schema' is 'The document format is not recognized (the conten t type is 'text/html; charset=utf-8').'.

+1  A: 

The Add Service Reference dialog does not generate the proper configuration for an ASMX service. You need to use svcutil instead.

This blog post should help you http://nayyeri.net/integrating-wcf-clients-with-asmx-services

Rob Windsor
@Rob I appreciate the suggestion Rob, but unfortunately this did not work. I updated my post with the error.
Darien Ford
@Rob: that blog post is from 2007. "Add Service Reference" works quit well with ASMX web services or any other basic SOAP web services. It simply uses `basicHttpBinding`.
John Saunders