如何使用Workflow Foundation从Sharepoint文档库下载文档?

时间:2011-10-10 16:15:11

标签: sharepoint sharepoint-2010 tfs2010 tfsbuild workflow-foundation

我在Documents文件夹下的TFS2010源代码管理中有一些测试,安全性,项目管理和一些其他word文档。有人知道如何访问它们以便下载并复制到本地路径吗?

这些文件实际上不在$ / ...文件夹下,但它们有一个Sharepoint Web服务器路径,如:“http://myServer/sites/MyProyect/Test/Tests_P13_F00120.doc”。我试图使用DownloadFiles活动但没有成功,因为它需要一个以$ /开头的路径。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

DownloadFiles不是您可以使用的活动,它用于处理驻留在Source控件中的文件。

相反,您需要建立与TFS的Sharepoint Copy服务的连接,该服务位于http://<Site>/_vti_bin/Copy.asmx。我们通过在构建解决方案中添加服务引用来实现此目的。

然后,我们实现了一个基本上与您完成相反的构建活动:在TFS构建期间,它将文档上载到Sharepoint中。

实例化如下:

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);

此复制服务公开GetItem方法,这是您应该调用的方法。

我不知道这个GetItem能否支持http://myServer/sites/MyProject/Test/*.doc种事