Advertisement
lacrosse199i

working code

Dec 15th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import os
  2. from urllib import parse
  3. from urllib.request import pathname2url
  4. from suds.client import Client
  5. from suds.transport.http import HttpAuthenticated
  6.  
  7.  
  8. sessionID = None
  9. client = None
  10. def initiate_conn(hostUrl, username, password):
  11. global sessionID
  12. global client
  13.  
  14. host = hostUrl+'/soap'
  15. wsdl_file = parse.urljoin('file:', pathname2url(os.path.abspath("soap_bindings/hpna10_11_api.wsdl.soappy")))
  16. t = HttpAuthenticated(username=username, password=password)
  17.  
  18. client = Client(wsdl_file, transport=t)
  19. client.set_options(location=host)
  20.  
  21. request = client.factory.create('loginInputParms')
  22. request.username = username
  23. request.password = password
  24. authObject = client.service.login(request)
  25. sessionID = authObject.Text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement