TravelPort官方API解读

本文详细介绍了如何使用TravelPort Universal API,从Ping通开始,逐步讲解了搜索航班可用性和价格,以及如何进行低票价搜索。内容涵盖下载安装cxf,生成Java代码,使用System Service进行Ping操作,进行航班可用性搜索和定价,以及低票价搜索的异步处理。文章适用于Java开发者,旨在帮助他们理解TravelPort API的使用流程。
摘要由CSDN通过智能技术生成

TravelPort Ping通使用教程

Unit1 Lesson 1:

标签(空格分隔): 完成第1单元的三个课程后,您可以使用Travelport Universal API来提出服务请求并了解响应。


  • 1、 下载和安装cxf

  • 2、 需要从Travelport的UniversalAPI提供的wsdl和xsd文件生成Java代码

  • 3、 首先要生成的是系统服务的Java代码(System.wsdl)

命令行:

wsdl2Java -client -d /Users/johndoe/tport-workspace/uapiJava/.cxftmp/src -classdir /Users/johndoe/tport-workspace/uapiJava/build/classes -p http://www.travelport.com/service/system_v8_0=com.travelport.service.system_v8_0 -impl -validate -exsh true -dns true -dex true -autoNameResolution -xjc-Xts,-Xts:style:multiline,-Xlocator,-mark-generated -wsdlLocation http://localhost:8080/kestrel/ExternalCacheAccessService?wsdl -verbose -fe jaxws -db jaxb -wv 1.1 file:/Users/johndoe/tport-workspace/uapiJava/wsdl/system_v8_0/System.wsdl 

  • 4、 系统客户端:使用WDT查看器查看文件(应该是WSDL生成Java代码的结构)


    SystemService.png
    SystemService.png

(1) 看的出来,此WSDL有两个Service暴露,分别是ExternalCacheAccessService and SystemService
在你的src文件下你可以看到生成的service,com.travelport.service.system_v8_0.SystemService(关于此服务的所有实现细节可以safely ignore)
(2) 在SystemService上有三个端口被暴露,SystemInfoPortType,SystemPingPortType, SystemTimePortType.


  • 5、 这个lesson中使用了许多服务,需要准备所必须的代码

a) Air service in src/wsdl/air_v26_0/Air.wsdl,
b) Hotel service in src/wsdl/hotel_v26_0/Hotel.wsdl
c) Vehicle service in src/wsdl/vehicle_v26_0/Vehicle.wsdl
d) Universal service in src/wsdl/universal_v26_0/UniversalRecord.wsdl


  • 6、 模型:Travelport Universal API公开一个端口,该端口有一个Service方法,无论使用何种语言,都可以使用方法或函数调用来通过给定端口在网络上发出请求,这个ping的端口仅仅只有一个service方法,image中还有请求和相应参数PingReq和PingRes,这些生成类的源代码可以在src中com.travelport.schema.system_v8_0.PingReq找到。
    在PingRsq/PingRsps的对象结构在XSD中指定rc/wsdl/system_v8_0/System.xsd。XSD文件定义在WSDL文件中使用的各种类型,WSDL引用这些XSD来导入这些定义。

  • 7、 使用System Service(Ping Port Example)
  1. Create an object of type PingReq
  1. PingReq使用其setter方法填写必要字段
    3) Create an instance of SystemService
  2. 访问该SystemService对象以获取类型的对象SystemPingPortType.(Access the SystemService object to get an object of type SystemPingPortType)
  3. Call the method service on the SystemPingPortType instance, passing the PingReq object created in step 1.(在SystemPingPortType实例上调用service方法,然后传递在步骤1中创建的对象)
  4. 通过PingRsp使用其getter方法查看对象来检查请求结果
    With very few exceptions,All the features and functions of Travelport Universal API follow this pattern of first build the request parameters and then use the port object to get the results
    for example:
public static void main(String[] argv) {        
    //
    // PING REQUEST // String payload= "this my payload; there are many like it but this one is mine"; String someTraceId = "doesntmatter-8176"; //set up the request parameters into a PingReq object PingReq req = new PingReq(); req.setPayload(payload); req.setTraceId(someTraceId); 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值