如何使用Python从SharePoint(通过SOAP)访问?

10

我想使用 Python(C-Python)与 SharePoint 进行集成。

有没有人尝试过这种方法?

4个回答

10

我怀疑自从这个问题得到回答以来,SUDS库已经更新了,可以自行处理所需的身份验证。在经过各种困难的跳跃后,我发现以下方法可以解决问题:


from suds import WebFault
from suds.client import *
from suds.transport.https import WindowsHttpAuthenticated


user = r'SERVER\user'
password = "yourpassword"
url = "http://sharepointserver/_vti_bin/SiteData.asmx?WSDL"


ntlm = WindowsHttpAuthenticated(username = user, password = password)
client = Client(url, transport=ntlm)


不幸的是,suds似乎与python3不兼容,而suds-jerko可以被强制使用,但需要python-ntlm库,该库无法在Windows上安装。 - Basic

9
获取wsdl文件:
import sys

# we use suds -> https://fedorahosted.org/suds
from suds import WebFault
from suds.client import *
import urllib2

# my 2 url conf
# url_sharepoint,url_NTLM_authproxy 
import myconfig as my 

# build url
wsdl = '_vti_bin/SiteData.asmx?WSDL'
url = '/'.join([my.url_sharepoint,wsdl])


# we need a NTLM_auth_Proxy -> http://ntlmaps.sourceforge.net/
# follow instruction and get proxy running
proxy_handler = urllib2.ProxyHandler({'http': my.url_NTLM_authproxy })
opener = urllib2.build_opener(proxy_handler)

client = SoapClient(url, {'opener' : opener})

print client.wsdl

主要问题: SharePoint服务器使用NTLM身份验证[:-(],因此我不得不使用NTLM身份验证代理。

感谢Rob和Enzondio给予的提示!


4

使用Python编写SOAP非常容易。这里有一篇来自Dive Into Python的教程


2
这已经非常过时了,它使用的SOAPpy库已被弃用。 - Basic

3

SharePoint提供了几个Web服务,您可以使用这些服务来查询和更新数据。

我不确定Python有哪些Web服务工具包,但它们应该能够轻松地为这些服务构建代理。

本文应该为您提供足够的信息以便开始使用。

http://www.developer.com/tech/article.php/3104621


不幸的是,Python与NTLM身份验证不兼容(甚至与Kerberos更不兼容!),因此SOAP部分很容易,但身份验证存在问题。 - Basic

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接