我已经完成了这项任务,我应该创建API的请求和响应类。 API适用于XML SOAP。我没有问题通过SOAP发送请求,但我找不到创建响应POJO的方法。谷歌搜索对我想要的东西没什么帮助。
以下是我从API获得的XML响应示例。我想知道的是,首先,如何生成下面的xml的java类,然后如何解组这个XML来创建该类的对象?
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://TekTravel/HotelBookingApi/IHotelService/HotelSearchResponse</a:Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<HotelSearchResponse xmlns="http://TekTravel/HotelBookingApi">
<Status>
<StatusCode>01</StatusCode>
<Description>Successful: HotelSearch Successful</Description>
</Status>
<ResponseTime>31/05/2018 07:15:50</ResponseTime>
<SessionId>String</SessionId>
<NoOfRoomsRequested>1</NoOfRoomsRequested>
<CityId>122727</CityId>
<CheckInDate>31/07/2018 00:00:00</CheckInDate>
<CheckOutDate>31/08/2018 00:00:00</CheckOutDate>
<RoomGuests>
<RoomGuest AdultCount="2" ChildCount="0" />
</RoomGuests>
<HotelResultList>
<HotelResult>
<ResultIndex>1</ResultIndex>
<HotelInfo>
<HotelCode>1223616</HotelCode>
<HotelName>Holiday Inn Istanbul Airport</HotelName>
<HotelPicture>http://api.tbotechnology.in/imageresource.aspx?img=9eMP+0FIICgCIk6ZClzZH9Cs+1gwAq6BFWcc22yNLMF/UJIXMdxPdU6RmZuwTZuiHZTzqW9k4hFjD8j5qsCZ6ux+KKuGpw2ckqGcenpT20gdryjECrrh0A==</HotelPicture>
<HotelDescription>Property Location With a stay at Holiday Inn Istanbul Airport Hotel in Istanbul (Bagcilar), you&apos;ll be close to Mall of Istanbul and Ataturk Olympic Stadium </HotelDescription>
<Latitude>41.05856</Latitude>
<Longitude>28.81395</Longitude>
<HotelAddress>Mahmutbey Mahallesi Tasocagi Yolu Caddesi 35 </HotelAddress>
<Rating>FiveStar</Rating>
<HotelPromotion />
<TripAdvisorRating>3.5</TripAdvisorRating>
<TripAdvisorReviewURL>http://www.tripadvisor.com/Hotel_Review-g293974-d860088-Reviews-m19454-Holiday_Inn_Istanbul_Airport_</TripAdvisorReviewURL>
<TagIds>126</TagIds>
</HotelInfo>
<MinHotelPrice TotalPrice="3515.40" Currency="USD" B2CRates="false" OriginalPrice="3515.40" />
<IsPkgProperty>false</IsPkgProperty>
<IsPackageRate>false</IsPackageRate>
<MappedHotel>true</MappedHotel>
</HotelResult>
</HotelResultList>
</HotelSearchResponse>
</s:Body>