0
我只是試圖使用Alex Koshelev的EWS特定的泡沫分支(可在BitBucket上找到)使用Python訪問Exchange Web服務(EWS)2010。 我找到了訪問EWS here的基本代碼,到目前爲止工作正常。但是,當我嘗試執行其他需要屬性的操作時(如FindFolder操作),它會失敗。Python suds.TypeNotFound Exchange EWS 2010
這裏是我使用的代碼:
import urllib2
from suds.client import Client
from suds.sax.element import Element
from suds.transport.https import HttpTransport
class Transport(HttpTransport):
def __init__(self, **kwargs):
realm, uri = kwargs.pop('realm'), kwargs.pop('uri')
HttpTransport.__init__(self, **kwargs)
self.handler = urllib2.HTTPBasicAuthHandler()
self.handler.add_password(realm=realm,
user=self.options.username,
passwd=self.options.password,
uri=uri)
self.urlopener = urllib2.build_opener(self.handler)
transport = Transport(realm='owa10.123together.com',
uri='https://owa10.123together.com',
username='[email protected]',
password='demo123!')
client = Client("https://owa10.123together.com/EWS/Services.wsdl",
transport=transport)
ns = ('t', 'http://schemas.microsoft.com/exchange/services/2006/types')
soap_headers = Element('RequestServerVersion', ns=ns)
soap_headers.attributes.append('Version="Exchange2010_SP1"')
client.set_options(soapheaders=soap_headers)
address = client.factory.create('t:EmailAddress')
address.Address = '[email protected]'
traversal = client.factory.create('t:FolderQueryTraversalType')
#traversal.Traversal = 'Deep'
#print client.service.GetUserOofSettings(address)
test = client.service.FindFolder(traversal)
print test
當我運行這段代碼,我得到了以下錯誤:
suds.TypeNotFound: Type not found: 'Shallow'
我還使用了記錄,以找出問題它向我顯示以下內容:
DEBUG:suds.mx.literal:starting content:
(Content){
tag = "Shallow"
value = "Shallow"
type = None
}
有沒有人知道這裏的問題在哪裏?它是我的一段代碼還是.wsdl文件不正確? 請注意,我是一個血腥的Python,特別是肥皂。如果您需要更多信息或代碼,請告訴我。
非常感謝您提前!