我正在尝试在 python 中使用 SUDS 访问 SOAP api
from suds.client import Client
def initialize():
url = 'http://uuuuuuuuuuuuuuu.com/wewewe/WsNBI?wsdl'
username = 'xxxxx'
password = 'ppppppp'
client = Client(url)
print client
result = client.service.Login(nbiLogin NBILogin(username,password),)
print result
我无法调用登录方法,知道我该怎么做吗?
这些是查询返回的方法...
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
Service ( WsNBIService ) tns="www.test.com"
Prefixes (1)
ns0 = "www.test.com"
Ports (1):
(WsNBIPort)
Methods (5):
GetClientAssociationInfo(nbiSession NBISession, clientAssociationReqData ClientAssociationReqData, )
GetEvent(nbiSession NBISession, eventReqData EventReqData, )
GetZDClientAssociationInfo(nbiSession NBISession, clientAssociationReqData ClientAssociationReqData, )
Login(nbiLogin NBILogin, )
Logout(nbiSession NBISession, )
Types (22):
GetClientAssociationInfo
GetClientAssociationInfoResponse
GetEvent
GetEventResponse
GetZDClientAssociationInfo
GetZDClientAssociationInfoResponse
Login
LoginResponse
Logout
LogoutResponse
authenticateResult
clientAssociationDetail
clientAssociationReqData
clientAssociationResult
eventDetail
eventReqData
eventResult
eventType
nbiLogin
nbiResult
nbiSession
requestType
更新:
#!/usr/bin/env python
from suds.client import Client
def initialize():
url = 'http://xxxxxxx/xxxx/WsNBI?wsdl'
username = 'xxxxx'
password = 'pppppp'
client = Client(url)
login = client.factory.create("ns0:NBILogin")
print login
ws = login.nbiLogin(userName=username, password = password)
result = client.service.Login(ws)
print result
def main():
initialize()
if __name__ == "__main__":
main()
[root@server scripts]# ./flex_soap.py
(nbiLogin){
UserName = None
Password = None
}
Traceback (most recent call last):
File "./flex_soap.py", line 19, in ?
main()
File "./flex_soap.py", line 16, in main
flexMaster()
File "./flex_soap.py", line 12, in flexMaster
ws = login.nbiLogin(userName=username, password = password)
AttributeError: nbiLogin instance has no attribute 'nbiLogin'
更新:
#!/usr/bin/env python
from suds.client import Client
def initialize():
url = 'http://xxxxx/intune/WsNBI?wsdl'
username = 'uuuuu'
password = 'pppp'
client = Client(url)
print client
login = client.factory.create("ns0:NBILogin")
print login
login.UserName = username
login.Password = password
result = client.service.Login(login)
print result
event = client.factory.create("ns0:EventReqData")
print event
def main():
initialize()
if __name__ == "__main__":
main()
[root@server scripts]# ./flex_soap.py
(nbiLogin){
UserName = None
Password = None
}
(authenticateResult){
Success = True
Session =
(nbiSession){
Id = "0eda1622-473c-4dd6-b68e-4ff3c1ee27f6"
}
}
(eventReqData){
EventType =
(eventType){
value = None
}
SerialNumbers =
(SerialNumbers){
SerialNumber[] = <empty>
}
}
知道我怎么能得到这个方法
GetEvent(nbiSession NBISession, eventReqData EventReqData, )