Python suds Exchange Web服务获取空服务属性

Python suds Exchange Web服务获取空服务属性,python,soap,exchange-server,exchangewebservices,suds,Python,Soap,Exchange Server,Exchangewebservices,Suds,我终于让我的EWS客户端不给我401错误,但我不知道这是否真的意味着什么。现在,当我实例化suds客户机对象时,它有一个空的服务属性 from suds.transport.https import * from suds.client import Client from os import environ import sys def first(car=None, *cdr): return car def cleaned(lines): return map(str

我终于让我的EWS客户端不给我401错误,但我不知道这是否真的意味着什么。现在,当我实例化suds客户机对象时,它有一个空的服务属性

from suds.transport.https import *
from suds.client import Client 
from os import environ
import sys

def first(car=None, *cdr):
    return car

def cleaned(lines):
    return map(str.strip, lines)

def getauth(f=open("%s/.ews/auth"%(environ.get("HOME")), "rt")):
    return first(cleaned(f.readlines()), f.close())

def serviceURI():
    return "https://%s/ews/Services.wsdl"%(environ.get("WEBMAIL"))

def auth():
    def nclnt(tx):
        return Client(serviceURI(), transport=tx)
    def ntauth(username, password):
        '''Authenticate with NTLM and return the Client object.'''
        return nclnt(WindowsHttpAuthenticated(username=username,
                                              password=password))
    def webauth(username, password):
        '''Use standard web authentication.'''
        return nclnt(HttpAuthenticated(username=username,
                                       password=password))
    def authWith(method):
        return method(*getauth())
    return authWith(ntauth if "ntlm" in sys.argv else webauth)

def main():
    def _go(client):
        print client
        print client.last_received
        print dir(client.service)
        return 0
    return _go(auth())

if __name__=="__main__":
    main()
当我运行这个时:

[ishpeck@slcyoshimitsu random_scripts]$ python ews.py ntlm

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913
<bound method Client.last_received of <suds.client.Client object at 0x17ea6d0>>
Traceback (most recent call last):
  File "ews.py", line 42, in <module>
    main()
  File "ews.py", line 39, in main
    return _go(auth())
  File "ews.py", line 37, in _go
    print dir(client.service)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 296, in __getattr__
    port = self.__find(0)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 331, in __find
    raise Exception, 'No services defined'
Exception: No services defined
[ishpeck@slcyoshimitsu random_scripts]$ python ews.py

Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build: R699-20100913
<bound method Client.last_received of <suds.client.Client object at 0x136c6d0>>
Traceback (most recent call last):
  File "ews.py", line 42, in <module>
    main()
  File "ews.py", line 39, in main
    return _go(auth())
  File "ews.py", line 37, in _go
    print dir(client.service)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 296, in __getattr__
    port = self.__find(0)
  File "/usr/lib/python2.7/site-packages/suds/client.py", line 331, in __find
    raise Exception, 'No services defined'
Exception: No services defined

我注意到很多人都在抱怨这件事有问题,但还没有发现有人声称这件事已经成功了

您的打印客户端行没有返回任何内容,因此我怀疑它与wsdl有问题。 打开一些调试以查看发生了什么

import logging
logging.basicConfig(level=logging.DEBUG, filename="suds.log")
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)

找到解决办法了吗?