データを取得するためにAPIを使用していますが、jsonを使用すると、次のコードでデータを取得します
string apiKey = Connection.AppSettings("APIKey");
string fullURL = "http://api.hotelspro.com/4.1_test/hotel/b2bHotelJSON.php?method=getAvailableHotel&apiKey=" + apiKey + "&destinationId=LD6J&checkIn=2012-07-20&checkOut=2012-07-24¤cy=EUR&clientNationality=UK&onRequest=false&rooms[0][0][paxType]=Adult&rooms[0][1][paxType]=Adult&rooms[0][2][paxType]=Child&rooms[0][2][age]=6&rooms[1][0][paxType]=Adult&rooms[1][1][paxType]=Adult&rooms[1][2][paxType]=Child&rooms[1][2][age]=8&filters[0][filterType]=hotelStar&filters[0][filterValue]=3&filters[1][filterType]=resultLimit&filters[1][filterValue]=10";
string text;
try
{
HttpWebRequest request = WebRequest.Create(fullURL) as HttpWebRequest;
request.Method = "Get";
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode != HttpStatusCode.OK)
throw new Exception(String.Format(
"Server error (HTTP {0}: {1}).",
response.StatusCode,
response.StatusDescription));
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
Response.Write(text);
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
しかし、このコードの下で同じことを石鹸で使用していると、ゼロレコードが表示されます。
これは、soap wsdl のコードです。
b2bHotelSOAPService objsoap = new b2bHotelSOAPService();
objsoap.Timeout = 20000;
objsoap.Url = "http://api.hotelspro.com/4.1_test/hotel/b2bHotelSOAP.php";
string destinationId = "CIEC";
DateTime checkIn = new DateTime(2012, 7, 20);
DateTime checkOut = new DateTime(2012, 7, 24);
string strCurrencyCode = "EUR";
pax[][] rooms = new pax[3][];
rooms[0] = new pax[3];
rooms[0][0] = new pax();
rooms[0][1] = new pax();
rooms[0][2] = new pax();
rooms[1] = new pax[3];
rooms[1][0] = new pax();
rooms[1][1] = new pax();
rooms[1][2] = new pax();
rooms[0][0].paxType = "Adult";
rooms[0][1].paxType = "Adult";
rooms[0][2].paxType = "Child";
rooms[0][2].age = "6";
rooms[1][0].paxType = "Adult";
rooms[1][1].paxType = "Adult";
rooms[1][2].paxType = "Child";
rooms[1][2].age = "8";
filter[] f = new filter[2];
f[0] = new filter();
f[0].filterType = "hotelStar";
f[0].filterValue = "3";
f[1] = new filter();
f[1].filterType = "resultLimit";
f[1].filterValue = "20";
getAvailableHotelResponse getres = new getAvailableHotelResponse();
getres = objsoap.getAvailableHotel(apiKey, destinationId, checkIn, checkOut, strCurrencyCode, "UK", false, rooms, f);
ここでゼロレコードを表示します。