2012-03-02 14 views
1

私は最終的に401エラーを出さないようにEWSクライアントを取得しましたが、実際に何かを意味するかどうかはわかりません。これで、suds Clientオブジェクトをインスタンス化すると、空のサービス属性が得られます。Python suds Exchange Webサービスが空のサービス属性を取得する

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() 

そして、私は実行すると、この:私はこの非常に事で問題を抱えて文句多くの人々に気付いていたが、それは働いて得ていると主張して誰にも発見していない

[[email protected] 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 
[[email protected] 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 

答えて

0

「印刷クライアント」の行に何も返されなかったので、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) 
関連する問題