我需要为旅游端口伽利略uAPI开发python soapclient。
这是Travelport Universal API的30天试用凭据
通用接口用户ID:通用接口/uAPI2514620686-0edbb8e4
通用接口密码: D54HWfck9nRZNPbXmpzCGwc95
Galileo (1G)分支代码: P7004130
URL:https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/
这是从文档galileo中引用的
HTTP报头
HTTP报头包括:
SOAP端点,根据地理区域的不同而不同。请求的服务。在前面的示例中,HotelService用于端点;但是,服务名称是根据请求事务修改的。gzip压缩,这是可选的,但强烈建议使用。要在响应中接受gzip压缩,请在报头中指定“accept -Encoding: gzip,deflate”。
授权,它遵循标准的基本授权模式。“Authorization:Basic”后面的文本可以使用Base64进行编码。大多数编程语言都支持此功能。授权凭证的语法必须在Travelport分配的用户名和密码之前包含前缀"Universal API/“。POST https://americas.universal-api.pp.travelport.com/ B2B网关/连接/uAPI/HotelService HTTP/2.0
Accept-Encoding: gzip、deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction:"“
授权:基础通用接口/用户名:密码
Content- length :长度
这是我的python代码
import urllib2
import base64
import suds
class HTTPSudsPreprocessor(urllib2.BaseHandler):
def http_request(self, req):
message = \
"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:air="http://www.travelport.com/schema/air_v16_0" xmlns:com="http://www.travelport.com/schema/common_v13_0" -->
<soapenv:header>
<soapenv:body>
<air:availabilitysearchreq xmlns:air="http://www.travelport.com/schema/air_v16_0" xmlns:com="http://www.travelport.com/schema/common_v13_0" authorizedby="Test" targetbranch="P7004130">
<air:searchairleg>
<air:searchorigin>
<com:airport code="LHR">
</com:airport></air:searchorigin>
<air:searchdestination>
<com:airport code="JFK">
</com:airport></air:searchdestination>
<air:searchdeptime preferredtime="2011-11-08">
</air:searchdeptime></air:searchairleg>
</air:availabilitysearchreq>
</soapenv:body>
"""
auth = base64.b64encode('Universal API/uAPI2514620686-0edbb8e4:D54HWfck9nRZNPbXmpzCGwc95')
req.add_header('Content-Type', 'text/xml; charset=utf-8')
req.add_header('Accept', 'gzip,deflate')
req.add_header('Cache-Control','no-cache')
req.add_header('Pragma', 'no-cache')
req.add_header('SOAPAction', '')
req.add_header('Authorization', 'Basic %s'%(auth))
return req
https_request = http_request
URL = "https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/"
https = suds.transport.https.HttpTransport()
opener = urllib2.build_opener(HTTPSudsPreprocessor)
https.urlopener = opener
suds.client.Client(URL, transport = https)但它不起作用。
Traceback (most recent call last):
File "soap.py", line 42, in <module>
suds.client.Client(URL, transport = https)
File "/usr/local/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "/usr/local/lib/python2.7/site-packages/suds/reader.py", line 152, in open
d = self.fn(url, self.options)
File "/usr/local/lib/python2.7/site-packages/suds/wsdl.py", line 136, in __init__
d = reader.open(url)
File "/usr/local/lib/python2.7/site-packages/suds/reader.py", line 79, in open
d = self.download(url)
File "/usr/local/lib/python2.7/site-packages/suds/reader.py", line 95, in download
fp = self.options.transport.open(Request(url))
File "/usr/local/lib/python2.7/site-packages/suds/transport/http.py", line 64, in open
raise TransportError(str(e), e.code, e.fp)
suds.transport.TransportError: HTTP Error 500: Dynamic backend host not specified在过去的两周里,我一直在尝试解决这个问题,所以如果你可以的话,请给我建议解决方案。
发布于 2014-06-05 19:56:57
我想你可以试着从这个url https://support.travelport.com/webhelp/uAPI/uAPI.htm#Getting_Started/Universal_API_Schemas_and_WSDLs.htm下载ZIP压缩包中的WSDL文件。
因此,您将能够使用这些WSDL文件生成客户机类,因为https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/上没有WSDL端点(如wsdl或/.wsdl)。
https://stackoverflow.com/questions/22653743
复制相似问题