从 json 得到响应但肥皂零记录 [英] from json get response but soap zero records

查看:15
本文介绍了从 json 得到响应但肥皂零记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 api 来获取数据,但是当我使用 json 时,我使用以下代码获取数据

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&currency=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的相同内容时,它会显示零记录.

But when i am using the same thing below this code with soap then its showing zero records.

这是soap 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);

此处显示零记录.

推荐答案

感谢hotelsPro.com 支持团队.最后我得到了他们的答复,我在这个肥皂请求中创建了三个房间,但只发送了两个房间的数据.

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][];

现在我也收到了肥皂的回应.再次感谢hotelsPro.com 支持团队.

and now i am getting response from soap also. once again to thanks hotelsPro.com support team.

这篇关于从 json 得到响应但肥皂零记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆