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代码的结构)
(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)
- Create an object of type PingReq
- PingReq使用其setter方法填写必要字段
3) Create an instance of SystemService - 访问该SystemService对象以获取类型的对象SystemPingPortType.(Access the SystemService object to get an object of type SystemPingPortType)
- Call the method service on the SystemPingPortType instance, passing the PingReq object created in step 1.(在SystemPingPortType实例上调用service方法,然后传递在步骤1中创建的对象)
- 通过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);