我是python的新手,因为我以前没有用过Amadeus API,我试着从Amadeus(http://webservices.amadeus.com/) soap API建立连接,我有.wsdl文件,我想用Python发送请求和获取响应。我看过SOAPpy、suds,并尝试使用它,就像下面这个例子:
sending a soap request from python
但是我不能确定请求是否会发送到服务器,如果请求要发送,如何获取响应数据。
请帮我提前谢谢。
发布于 2014-03-17 22:32:20
如果为传输库启用调试日志记录,则。
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.transport.http').setLevel(logging.DEBUG)您将能够在日志输出中看到类似以下内容:
DEBUG:suds.transport.http:sending:
URL: http://someurl
HEADERS: {'SOAPAction': '"http://blablabla/identityCheck"', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': '"http://blablabla/blablabla"'}
MESSAGE: <xml......>
DEBUG:suds.transport.http:received:
CODE: 200
HEADERS: {'header1': 'blablabla'}
MESSAGE: <xml......>此外,您还可以打印出服务结果对象。这里假设我在端点中有一个名为identityCheck的方法,并将其customer作为输入。
client = Client(wsdl_url, location=endpoint_url)
customer = client.factory.create('customer')
customer.userId = 'A'
customer.password = 'B'
result = client.service.identityCheck(customer)
print resulthttps://stackoverflow.com/questions/22425759
复制相似问题