I am making a booking comparison engine, and I have a very sensitive problem.
The deal is that I have 3-4 different sources to compare results. And each data provider has it’s own API, and in each search method you have another pagination, so you can send them request:
- pageSize
- pageNumber
- search params
and you get basically back:
- search Results
- resultQuantity
- the number of objects returned with that given search params
So I populate them via JQuery. Actually an Ajax GET request is sent to my
And the results are populated.
Lets say we have:
- Source1.com/api.php
- Source2.com/api.php
and on our website we need to arrange a good pagination. Saying good I mean made professionally, so that we don’t load too much the browser, and the server also with too much API queries.
I have thought that I could make it in this way:
If in my site I have pagination of 10 results per page, then I would query both sources with requests to send back 5 results per page.
But I would then face 2 types of problems:
-
1st page returns 5 of 23 2nd only 4
5+4,5+0,5+0…… -
Both have more than 5, but one ends before than second one let’s say 12 and 5
5-5,5-0,5/0 -
…
Not a good solution…
What is a workout for such situation????
1st is soap call
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.
POST /partnerV3/Webservice.asmx HTTP/1.1
Host: webservices.interhome.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<ServiceAuthHeader xmlns="http://www.interhome.com/webservice">
<Username>string</Username>
<Password>string</Password>
</ServiceAuthHeader>
</soap12:Header>
<soap12:Body>
<Search xmlns="http://www.interhome.com/webservice">
<inputValue>
<Page>int</Page>
<PageSize>int</PageSize>
<OrderDirection>NotSet or Ascending or Descending</OrderDirection>
<OrderBy>NotSet or Favorite or Price or Place</OrderBy>
<LanguageCode>string</LanguageCode>
<CurrencyCode>string</CurrencyCode>
<SalesOfficeCode>string</SalesOfficeCode>
<Quicksearch>string</Quicksearch>
<CountryCode>string</CountryCode>
<RegionCode>string</RegionCode>
<PlaceCode>string</PlaceCode>
<CheckIn>string</CheckIn>
<Duration>int</Duration>
<ThemeFilter>NotSet or Cheepcheep or Countryside or Familyfriendly or HolidayVillage or LakesAndMountains or Nightlife or Selection or SomewhereQuiet or SummerHoliday or Cities or SuitableForSeniors</ThemeFilter>
<HouseApartmentType>NotSet or Apartment or DetachedHouse or House</HouseApartmentType>
<Facilities>
<Facilities>NotSet or Aircondition or Balcony or BBQ or Cot or Dishwasher or Fireplace or Internet or InternetWiFi or Jacuzzi or LuxuriousFurnishings or ModernFurnishings or NiceKitchen or NiceSourroundings or Parking or LiftsInhouse or NonSmoker or Pets1 or Pets2 or Pets3 or PetsNo or PoolAll or PoolChildren or PoolIndoor or PoolPrivate or Sauna or Swimmingpool or TV or WashingMachine or Wheelchair</Facilities>
<Facilities>NotSet or Aircondition or Balcony or BBQ or Cot or Dishwasher or Fireplace or Internet or InternetWiFi or Jacuzzi or LuxuriousFurnishings or ModernFurnishings or NiceKitchen or NiceSourroundings or Parking or LiftsInhouse or NonSmoker or Pets1 or Pets2 or Pets3 or PetsNo or PoolAll or PoolChildren or PoolIndoor or PoolPrivate or Sauna or Swimmingpool or TV or WashingMachine or Wheelchair</Facilities>
</Facilities>
<Accessibilities>
<Accessibilities>NotSet or FamilyFrienldy or LiftsInhouse or NonSmoking or PetsWelcome or PetsNotAllowed or SuitableForSeniors or WheelchairAccessible</Accessibilities>
<Accessibilities>NotSet or FamilyFrienldy or LiftsInhouse or NonSmoking or PetsWelcome or PetsNotAllowed or SuitableForSeniors or WheelchairAccessible</Accessibilities>
</Accessibilities>
<Activities>
<Activities>NotSet or Biking or CrossCountrySkiing or Golfing or Hiking or MountainBiking or Nightlife or NordicWalking or Riding or Sailing or Skiing or Snowboarding or Surfing or Tennis or ThemeParkNearby or Toboggan or Windsurfing or SkiingSnowboarding</Activities>
<Activities>NotSet or Biking or CrossCountrySkiing or Golfing or Hiking or MountainBiking or Nightlife or NordicWalking or Riding or Sailing or Skiing or Snowboarding or Surfing or Tennis or ThemeParkNearby or Toboggan or Windsurfing or SkiingSnowboarding</Activities>
</Activities>
<Situations>
<Situations>NotSet or ByTheSea or InAHistoricTown or InAMajorCity or InTheCountryside or InALakesideTown or SomewhereQuiet or OnAIsland or Center100 or Center500 or Center1000 or Golf200 or Golf500 or Golf5000 or Lake50 or Lake1000 or Lake10000 or Sea50 or Sea1000 or Sea10000 or Skilift50 or Skilift500 or Skilift10000 or CountryView or LakeView or MountainView or SeaView</Situations>
<Situations>NotSet or ByTheSea or InAHistoricTown or InAMajorCity or InTheCountryside or InALakesideTown or SomewhereQuiet or OnAIsland or Center100 or Center500 or Center1000 or Golf200 or Golf500 or Golf5000 or Lake50 or Lake1000 or Lake10000 or Sea50 or Sea1000 or Sea10000 or Skilift50 or Skilift500 or Skilift10000 or CountryView or LakeView or MountainView or SeaView</Situations>
</Situations>
<PropertyTypes>
<PropertyTypes>NotSet or Apartment or Bungalow or CastleManor or Chalet or DetachedHouse or Farmhouse or HistoricProperty or HolidayVillage or SpecialProperty or Villa</PropertyTypes>
<PropertyTypes>NotSet or Apartment or Bungalow or CastleManor or Chalet or DetachedHouse or Farmhouse or HistoricProperty or HolidayVillage or SpecialProperty or Villa</PropertyTypes>
</PropertyTypes>
<SpecialOffer>NotSet or AnySpecialOffer or EarlyBooker or LastMinute</SpecialOffer>
<PaxMin>int</PaxMin>
<PaxMax>int</PaxMax>
<RoomsMin>int</RoomsMin>
<RoomsMax>int</RoomsMax>
<BedroomsMin>int</BedroomsMin>
<BedroomsMax>int</BedroomsMax>
<BathroomsMin>int</BathroomsMin>
<BathroomsMax>int</BathroomsMax>
<QualityMin>int</QualityMin>
<QualityMax>int</QualityMax>
<DistanceToCenter>int</DistanceToCenter>
<DistanceToGolfCourse>int</DistanceToGolfCourse>
<DistanceToLake>int</DistanceToLake>
<DistanceToSea>int</DistanceToSea>
<DistanceToSeaOrLake>int</DistanceToSeaOrLake>
<DistanceToSkiLifts>int</DistanceToSkiLifts>
</inputValue>
</Search>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<SearchResponse xmlns="http://www.interhome.com/webservice">
<SearchResult>
<ResultCount>int</ResultCount>
<Items>
<SearchResultItem>
<AccommodationCode>string</AccommodationCode>
<Country>string</Country>
<CountryCode>string</CountryCode>
<Region>string</Region>
<RegionCode>string</RegionCode>
<Place>string</Place>
<PlaceCode>string</PlaceCode>
<Zip>string</Zip>
<CurrencyCode>string</CurrencyCode>
<Price>decimal</Price>
<Quality>int</Quality>
<Type>string</Type>
<Pax>int</Pax>
<Rooms>int</Rooms>
<BedRooms>int</BedRooms>
<Pets>int</Pets>
<Cots>int</Cots>
<AdditionBeds>int</AdditionBeds>
<Parking>boolean</Parking>
<TV>boolean</TV>
<Dishwasher>boolean</Dishwasher>
<Washingmachine>boolean</Washingmachine>
<Aircondition>boolean</Aircondition>
<Pool>boolean</Pool>
<Tennis>boolean</Tennis>
<Sauna>boolean</Sauna>
<Wheelchair>boolean</Wheelchair>
<GeoLng>decimal</GeoLng>
<GeoLat>decimal</GeoLat>
<InsideDescription>string</InsideDescription>
<Picture>string</Picture>
</SearchResultItem>
<SearchResultItem>
<AccommodationCode>string</AccommodationCode>
<Country>string</Country>
<CountryCode>string</CountryCode>
<Region>string</Region>
<RegionCode>string</RegionCode>
<Place>string</Place>
<PlaceCode>string</PlaceCode>
<Zip>string</Zip>
<CurrencyCode>string</CurrencyCode>
<Price>decimal</Price>
<Quality>int</Quality>
<Type>string</Type>
<Pax>int</Pax>
<Rooms>int</Rooms>
<BedRooms>int</BedRooms>
<Pets>int</Pets>
<Cots>int</Cots>
<AdditionBeds>int</AdditionBeds>
<Parking>boolean</Parking>
<TV>boolean</TV>
<Dishwasher>boolean</Dishwasher>
<Washingmachine>boolean</Washingmachine>
<Aircondition>boolean</Aircondition>
<Pool>boolean</Pool>
<Tennis>boolean</Tennis>
<Sauna>boolean</Sauna>
<Wheelchair>boolean</Wheelchair>
<GeoLng>decimal</GeoLng>
<GeoLat>decimal</GeoLat>
<InsideDescription>string</InsideDescription>
<Picture>string</Picture>
</SearchResultItem>
</Items>
</SearchResult>
</SearchResponse>
</soap12:Body>
</soap12:Envelope>
and the second is the same ….
You need create objects for each connection.
This objects will load the content loaded to an array. They can be represented by:
When you conclude, it should work in the way similar to that:
After this working, then you can do what you really want:
The most import thing is the
makePages, probably is what you are wonderring to do. But your question is a little long then I put a little more stuff to not be confusing.You can change
makePageto work in your way. The idea is saving all pages contents inpagesvar.