Geeks With Blogs
Awai, delivery guy 1 hour for cheese, 1 hour for supreme. What the heck?

Having just gone through this, I thought I'd share the basic procedure when calling WSS 3.0 Web services such as lists.asmx and views.asmx from a WCF client.  As you may know, the exceptions returned by the WSS Web services are terse.  Hopefully, this post will help someone trying to avoid those in their own project.

Step 1 - Add a Service Reference to the WCF service you want to call (Duh)

Note that I included the "?wsdl".  If you don't VS will be redirected to /_vti_bin/Lists.asmx.  That doesn't matter from a service client code generation standpoint, just that the WCF endpoint addresses in App.config will need to be changed as they'll be pointing to the wrong URL, and none of the lists and other objects in your site will be found by the Web services.   

Step 2 - Modify the App.Config file to change the security binding configuration used by the client

In the basicHttpBinding section, replace:

<security mode="None">
    <transport clientCredentialType="None"
               proxyCredentialType="None" realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
</security>

With:

<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm" />
</security>

Step 3 - Allow the Web service to impersonate the user

WssList.ListsSoapClient listService = new WssList.ListsSoapClient("ListsSoap");
listService.ClientCredentials.Windows.AllowedImpersonationLevel
    = System.Security.Principal.TokenImpersonationLevel.Delegation;

XmlElement elem = listService.GetListCollection();

 

End transmission...

Posted on Friday, July 6, 2007 9:47 AM SharePoint 2007 , Web Services | Back to top


Comments on this post: Calling WSS 3.0 Web Services from WCF clients

# re: Calling WSS 3.0 Web Services from WCF clients
Requesting Gravatar...
You can also configure the allowed impersonation level using the configuration file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NtlmEndpointBehavior">
<clientCredentials>
<windows allowedImpersonationLevel="Impersonation" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<services />
<bindings>
<basicHttpBinding>
<binding name="ListsSoap">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://yourserver/_vti_bin/Lists.asmx"
behaviorConfiguration="NtlmEndpointBehavior" binding="basicHttpBinding"
bindingConfiguration="ListsSoap" contract="ListsSoap"
name="ListsSoap" />
</client>
</system.serviceModel>
</configuration>
Left by Ashkan on Jul 11, 2007 8:39 PM

# re: Calling WSS 3.0 Web Services from WCF clients
Requesting Gravatar...
Thanks for the tip Ashkan
Left by Michael Awai on Jul 30, 2007 9:00 PM

# re: Calling WSS 3.0 Web Services from WCF clients
Requesting Gravatar...
you saved my job !! thanks :))
Left by Aref on Jan 13, 2010 12:35 AM

# re: Calling WSS 3.0 Web Services from WCF clients
Requesting Gravatar...
Thanks you saved my client visit
Left by Girish on Apr 22, 2010 2:03 AM

Your comment:
 (will show your gravatar)
 


Copyright © Michael Awai | Powered by: GeeksWithBlogs.net | Join free