我设法从Linux上传文件(crud PUT khe khe :)到Sharepoint。
该文件的绝对路径为:

http://myhost/mysite/reports/2010-04-13/file.txt

现在,我正在尝试向文件中添加一些元数据:
from suds.transport.https import WindowsHttpAuthenticated
url='http://myhost/mysite/_vti_bin/lists.asmx?WSDL'
n=WindowsHttpAuthenticated(username='me',password='password')
from suds.client import Client
c=Client(url,transport=n)

xml="""<Batch OnError='Continue' PreCalc='' ListVersion='0'>
<Method ID='1' Cmd='Update'>
    <Field Name='ID'/>
    <Field Name='FileRef'>%s</Field>
    <Field Name='Jurisdiction'>%s</Field>
</Method>
</Batch>"""
fn = 'http://myhost/mysite/reports/2010-04-13/file.txt'
print c.service.UpdateListItems('reports',xml % (fn,'UK'))

代码返回:
soap:Server

...和没有发生。
我有什么想念的吗?还有其他方法吗?

谢谢

最佳答案

找到了! :)

必须使用 DOM 对象代替纯文本 XML 对象,如下所示:

b = Element("Batch")
b.append(Attribute("OnError","Continue")).append(Attribute("ListVersion","3"))
bm= Element("Method")
bm.append(Attribute("ID","1")).append(Attribute("Cmd","Update"))
bm.append(Element("Field").append(Attribute("Name","ID")).setText(''))
bm.append(Element('Field').append(Attribute('Name','FileRef')).setText('http://.....'))
bm.append(Element('Field').append(Attribute('Name','Jurisdiction')).setText('UK'))
bm.append(Element('Field').append(Attribute('Name','Desk')).setText('Structured Equity Derivatives'))
bm.append(Element('Field').append(Attribute('Name','Business Area')).setText('Back Office'))
bm.append(Element('Field').append(Attribute('Name','Title')).setText('whatever'))
b.append(bm)
u = Element("ns1:updates")
u.append(b)
c.service.UpdateListItems("Reports",u)

现在可以正常使用了!

10-04 12:24