ทำการเพิ่ม
soap_service namespace: "wash_out", wsse_username: "username", wsse_password: "password"
จากเดิมเป็น
soap_service namespace: 'urn:WashOut'
ภายใน airwebservice_controller.rb ที่อยู่ ใน controller
จากนั้นเวลาจะใช้ WebService จะต้องส่ง username และ password ที่ตั้งไว้ด้านบน (ตัวหนา) เพื่อใช้งาน
ตัวอย่างการส่ง Request ด้วย SOAP UI
![]() |
กรณีส่งไม่มี Header |
![]() |
ส่ง Username และ Password ใน Header ไปด้วย |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import zeep from zeep import Client import time client = Client(wsdl='http://localhost:3000/airwebservice/wsdl') header = zeep.xsd.Element( 'Security', zeep.xsd.ComplexType([ zeep.xsd.Element( 'UsernameToken', zeep.xsd.ComplexType([ zeep.xsd.Element('Username',zeep.xsd.String()), zeep.xsd.Element('Password',zeep.xsd.String()), ]) ), ]) ) # https://stackoverflow.com/questions/42963114/python-zeep-soap-complex-header header_value = header(UsernameToken={'Username':'username','Password':'password'}) result = client.service.get_all_airinfo(_soapheaders=[header_value]) print(result) |
ไม่มีความคิดเห็น:
แสดงความคิดเห็น