如何使用curl从sharepoint文档库中签出文件?

时间:2013-07-21 12:55:36

标签: sharepoint soap curl

可以使用curl通过this question中提到的以下命令将文件签入共享点文档库:

curl --ntlm --user username:password --upload-file file.txt https://mysharepointserver.com/sites/mysite/myfile.txt -k

但是如何从文档库中首先签出文件(使用curl)?

我通过传递SOAPAction checkoutfile头和数据尝试了一个方法,如下所示,但是当服务器返回响应时它没有任何效果:'200 OK'

curl --ntlm --user username:password -d @soapdata.xml -H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOutFile"  -H "Content-Type: text/xml; charset=utf-8" https://mysharepointserver.com/sites/mysite/myfile.txt -k

soapdata.xml包含WSDL描述的checkout所需的SOAP数据。在上面的命令中是否有问题,或者有更简单的方法来处理CURL,如签入案例?

1 个答案:

答案 0 :(得分:3)

example发现,使用SOAP方法,CURL命令中的URL应该是sharepoint站点Lists.asmx的路径,而不是要检出的文件的URL。文件URL只需要在soapdata xml的pageUrl字段中,如下所示:

curl --ntlm --user username:password -d @soapdata.xml -H "SOAPAction: http://schemas.microsoft.com/sharepoint/soap/CheckOutFile" -H "Content-Type: text/xml; charset=utf-8" -k -v https://mysharepointserver.com/sites/mysite/_vti_bin/Lists.asmx

其中soapdata.xml的内容:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <CheckOutFile xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <pageUrl>https://mysharepointserver.com/sites/mysite/myfile.txt</pageUrl>
      <checkoutToLocal>true</checkoutToLocal>
      <lastmodified/>
    </CheckOutFile>
  </soap:Body>
</soap:Envelope>