从JSON获得回应,但肥皂零记录 [英] from json get response but soap zero records
问题描述
我使用一个API用于获取数据,但是当我使用JSON我得到以下code中的数据
I am using an api for getting the data but when i use the json i get the data with the following code
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);
}
但是,当我使用低于此code同样的事情用肥皂那么它显示为零的记录。
But when i am using the same thing below this code with soap then its showing zero records.
这里是code香皂WSDL。
here is the code for 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);
在这里得到显示为零的记录。
here gets show zero records.
推荐答案
由于hotelsPro.com支持团队。最后我接到了他们的答案我在这个SOAP请求作出三个房间,但只有两个发送数据。
Thanks to hotelsPro.com support team . Finally i got answer from them that i am making three rooms in this soap request but sending data only for two .
所以我需要改变这一行
pax[][] rooms = new pax[3][];
到
pax[][] rooms = new pax[2][];
现在我正从SOAP响应也。再次感谢hotelsPro.com支持团队。
and now i am getting response from soap also. once again to thanks hotelsPro.com support team.
这篇关于从JSON获得回应,但肥皂零记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!