code_junkie

how can i use sharepoint (via soap?) from python?

Nov 11th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import sys
  2.  
  3. # we use suds -> https://fedorahosted.org/suds
  4. from suds import WebFault
  5. from suds.client import *
  6. import urllib2
  7.  
  8. # my 2 url conf
  9. # url_sharepoint,url_NTLM_authproxy
  10. import myconfig as my
  11.  
  12. # build url
  13. wsdl = '_vti_bin/SiteData.asmx?WSDL'
  14. url = '/'.join([my.url_sharepoint,wsdl])
  15.  
  16.  
  17. # we need a NTLM_auth_Proxy -> http://ntlmaps.sourceforge.net/
  18. # follow instruction and get proxy running
  19. proxy_handler = urllib2.ProxyHandler({'http': my.url_NTLM_authproxy })
  20. opener = urllib2.build_opener(proxy_handler)
  21.  
  22. client = SoapClient(url, {'opener' : opener})
  23.  
  24. print client.wsdl
  25.  
  26. from suds import WebFault
  27. from suds.client import *
  28. from suds.transport.https import WindowsHttpAuthenticated
  29.  
  30.  
  31. user = 'SERVERuser'
  32. password = "yourpassword"
  33. url = "http://sharepointserver/_vti_bin/SiteData.asmx?WSDL"
  34.  
  35.  
  36. ntlm = WindowsHttpAuthenticated(username = user, password = password)
  37. client = Client(url, transport=ntlm)
Add Comment
Please, Sign In to add comment