You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.0 KiB
58 lines
2.0 KiB
|
1 week ago
|
from suds.client import Client
|
||
|
|
import xml_to_dict
|
||
|
|
from lib.gzip_base64 import ungzip_base64_dh2cmc
|
||
|
|
|
||
|
|
|
||
|
|
class GetSeatPlans:
|
||
|
|
def __init__(self, url, cid):
|
||
|
|
self.ws_client = Client(url)
|
||
|
|
self.user_name = 'TUOWEI' # 固定写死的参数
|
||
|
|
self.password = '668CBE9A6BCF4ABB' # 固定写死的参数
|
||
|
|
self.cinema_id = cid
|
||
|
|
self.xml_parse = xml_to_dict.XMLtoDict()
|
||
|
|
|
||
|
|
# getShows(xs:string UserName, xs:string Password, xs:string CinemaId, xs:string ShowDate, xs:string BookingFlg, )
|
||
|
|
"""
|
||
|
|
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
|
||
|
|
<SOAP-ENV:Header/>
|
||
|
|
<SOAP-ENV:Body>
|
||
|
|
<ns1:getSeatPlans xmlns:ns1="wsdl">
|
||
|
|
<UserName>TUOWEI</UserName>
|
||
|
|
<Password>668CBE9A6BCF4ABB</Password>
|
||
|
|
<CinemaId>214</CinemaId>
|
||
|
|
<HallId>12</HallId>
|
||
|
|
</ns1:getSeatPlans>
|
||
|
|
</SOAP-ENV:Body>
|
||
|
|
</SOAP-ENV:Envelope>
|
||
|
|
"""
|
||
|
|
|
||
|
|
def get_seat_plans(self, hall_id):
|
||
|
|
print('-' * 100 + '\n' + '请求GetSeatPlans接口')
|
||
|
|
data = {
|
||
|
|
'UserName': self.user_name, # 授权用户名
|
||
|
|
'Password': self.password, # 授权密码
|
||
|
|
'CinemaId': self.cinema_id, # 影院三位编码
|
||
|
|
'HallId': hall_id, # 影厅ID
|
||
|
|
}
|
||
|
|
result_xml = self.ws_client.service.getSeatPlans(**data)
|
||
|
|
if 'xml' in result_xml:
|
||
|
|
result_dict = self.xml_parse.parse(result_xml)
|
||
|
|
else:
|
||
|
|
print(f"-- gzip加密结果 --\n{result_xml}")
|
||
|
|
result_xml = ungzip_base64_dh2cmc(result_xml)
|
||
|
|
result_dict = self.xml_parse.parse(result_xml)
|
||
|
|
print(f"-- xml结果 --\n{result_xml}")
|
||
|
|
print("-- Dict结果 --")
|
||
|
|
|
||
|
|
print(result_dict)
|
||
|
|
return result_dict
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
# soap_url = 'http://192.168.55.99/webservice/?wsdl'
|
||
|
|
# cinema_id = '304'
|
||
|
|
soap_url = 'http://192.168.55.98/webservice/?wsdl'
|
||
|
|
cinema_id = '849'
|
||
|
|
api_get_seat_plans = GetSeatPlans(soap_url, cinema_id)
|
||
|
|
api_get_seat_plans.get_seat_plans(hall_id='1')
|