Search code examples
sharepointsharepoint-2010tfsbuildworkflow-foundation

How to Download Documents from a a Sharepoint Document Library using Workflow Foundation?


I have some Test, Security, Project Management and some other word documents in TFS2010 source control under Documents folder. Does anybody know how to access them in order to download and copy to a local path?

Those files are not physically under $/... folder, though they have a Sharepoint web server path like: "http://myServer/sites/MyProyect/Test/Tests_P13_F00120.doc". I have tried to use DownloadFiles activity without success due to it needs a path which starts with $/. Any suggestion please?


Solution

  • DownloadFiles is not an activity you can make use of, it's meant to deal with files residing in Source control.

    Instead, you need to establish a connection to the Sharepoint Copy service of your TFS, which resides at http://<Site>/_vti_bin/Copy.asmx. We did this by adding a Service Reference in our build solution.

    We then implemented a build activity that does basically the opposite of what you are after: during TFS build it uploads documents into Sharepoint.

    The instantiation looks like this:

    BasicHttpBinding binding = new BasicHttpBinding();
    binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
    binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
    
    EndpointAddress endpointAddress = new EndpointAddress("http://<Site>/_vti_bin/Copy.asmx");
    
    CopySoapClient copyService = new CopySoapClient(binding,endpointAddress);
    

    This copy service exposes a GetItem method, this is the one you should probably be invoking.

    I 'm not aware if this GetItem is capable of supporting a http://myServer/sites/MyProject/Test/*.doc kind of thing