【问题标题】:Travelport Galileo python SoapClientTravelport Galileo python SoapClient
【发布时间】:2014-03-26 07:01:40
【问题描述】:

我需要为 Travelport Galileo uAPI 开发 python soapclient。

这是 Travelport Universal API 的 30 天试用凭证

通用 API 用户 ID:通用 API/uAPI2514620686-0edbb8e4

通用 API 密码:D54HWfck9nRZNPbXmpzCGwc95

伽利略 (1G) 分公司代码:P7004130

网址:https://emea.universal-api.pp.travelport.com/B2BGateway/connect/uAPI/

这是来自伽利略文档的引用

HTTP 标头

HTTP 标头包括:

SOAP 端点,因以下情况而异: 地理区域。 请求的服务。在前面的示例中,HotelService 用于端点;但是,服务名称会根据请求事务进行修改。 gzip 压缩,这是可选的,但强烈推荐。要在响应中接受 gzip 压缩,请在标头中指定“Accept-Encoding: gzip,deflate”。

授权,遵循标准的基本授权模式。 “授权:基本”之后的文本可以使用 Base 64 进行编码。大多数编程语言都支持此功能。 授权凭证的语法必须在 Travelport 分配的用户名和密码之前包含前缀“Universal API/”。 发布https://americas.universal-api.pp.travelport.com/ B2BGateway/connect/uAPI/HotelService HTTP/2.0

接受编码:gzip,deflate

内容类型:text/xml;charset=UTF-8

SOAPAction: ""

授权:基本 UniversalAPI/用户名:密码

内容长度:长度

这是我的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

过去两周我一直在努力解决这个问题,所以如果可以的话,请告诉我解决方案。

【问题讨论】:

  • 我不熟悉这个特定的主题,但您确定要在此处发布登录凭据吗?
  • 感谢您的回复。没问题,它是 30 天试用凭据
  • 您好,我对这个网络服务平台不熟悉,但我似乎是您遗漏了一个参数。看看 [link]ibm.com/developerworks/community/forums/html/… 似乎你必须设置你试图与之交谈的后端服务器。
  • @TimaOspanov 您找到解决问题的方法了吗?我也遇到了相同的 HTTP 错误 500:未指定动态后端主机 - 路。 (这也是一个试验)

标签: python api soap suds travelport-api


【解决方案1】:

我认为你可以尝试从这个 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)

【讨论】:

  • 您似乎对 Travelport API 有所了解,我输入了我的凭据并将 Apache CXF 与 Tomcat 相关联,我还使用此链接从 GitHub 导入了项目:github.com/Travelport /travelport-uapi-tutorial/tree/master,我使用 WSDL 生成了客户端类,但现在我如何测试 Travelport API 以从真实数据中检索数据?因为当我调用该服务时,它向我显示一个错误:原因:java.net.ConnectException:连接被拒绝:连接,请帮助,我花了很多时间但几天没有任何结果,谢谢
  • 另外,如果你愿意,你可以在这里帮助我:stackoverflow.com/questions/35961224/… 谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多