首页 新闻 会员 周边 捐助

添加Web引用 调用接口后 无法获取到响应的值

0
悬赏园豆:15 [已解决问题] 解决于 2013-02-18 10:25

1.soapUI 中测试接口 http://ws.51book.com:8000/ltips/services/getAvailableFlightWithPriceAndCommisionService1.0?wsdl 可以正常访问 并返回结果集。

在VS2008 中 添加 Web应用 实例接口 调用方法 却得不到返回结果。

代码如下:

 com.w_51book.ws.GetAvailableFlightWithPriceAndCommisionServiceImpl_1_0Service ws = new com.w_51book.ws.GetAvailableFlightWithPriceAndCommisionServiceImpl_1_0Service();

        MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
        availableFlightWithPriceAndCommisionRequest model = new availableFlightWithPriceAndCommisionRequest();
        model.agencyCode = "KISS";             //公司代码
        model.orgAirportCode = "PEK";            //起飞城市
        model.dstAirportCode = "CGO";              //抵达城市
        model.date = "2012-05-19";
        model.onlyAvailableSeat = 0;
        model.onlyNormalCommision = 0;
        model.onlyOnWorkingCommision = 1;
        model.onlySelfPNR = 0;
        string sign = model.agencyCode + model.dstAirportCode + model.onlyAvailableSeat + model.onlyNormalCommision + model.onlyOnWorkingCommision + model.onlySelfPNR + model.orgAirportCode + "sdidkd";
        model.sign = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(sign))).Replace("-", "").ToLower();
        availableFlightWithPriceAndCommisionReply result = ws.getAvailableFlightWithPriceAndCommision(model);

        if (result != null && result.flightItems != null)
        {
            this.TextBox1.Text = result.flightItems.Count().ToString();
        }
        else
        {
            this.TextBox1.Text = "纠结的一天";
        }

现在 求解 大牛 到底咋回事啊!

问题补充:

调用的接口是用java写的。

紫炁星的主页 紫炁星 | 初学一级 | 园豆:57
提问于:2012-05-08 10:00
< >
分享
最佳答案
0

不知道你的错误在哪里,我写了个简单的控制台应用,生成的服务名称空间是ServiceReference1,代码如下:

        static void Main(string[] args)
        {
            ServiceReference1.GetAvailableFlightWithPriceAndCommisionService_1_0Client client = new ServiceReference1.GetAvailableFlightWithPriceAndCommisionService_1_0Client();

            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            availableFlightWithPriceAndCommisionRequest model = new availableFlightWithPriceAndCommisionRequest();
            model.agencyCode = "KISS";             //公司代码
            model.orgAirportCode = "PEK";            //起飞城市
            model.dstAirportCode = "CGO";              //抵达城市
            model.date = "2012-05-19";
            model.onlyAvailableSeat = 0;
            model.onlyNormalCommision = 0;
            model.onlyOnWorkingCommision = 1;
            model.onlySelfPNR = 0;
            string sign = model.agencyCode + model.dstAirportCode + model.onlyAvailableSeat + model.onlyNormalCommision + model.onlyOnWorkingCommision + model.onlySelfPNR + model.orgAirportCode + "sdidkd";
            model.sign = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(sign))).Replace("-", "").ToLower();
            availableFlightWithPriceAndCommisionReply result = client.getAvailableFlightWithPriceAndCommision(model);

            string msg;
            if (result != null && result.flightItems != null)
            {
                Debug.WriteLine("OK");
                Debug.WriteLine(msg = result.flightItems.Count().ToString());
            }
            else
            {
                Debug.WriteLine("ERROR");
                Debug.WriteLine(msg = "纠结的一天");
            }
            MessageBox.Show(msg);
        }

运行结果是:
result:不为空

result.flightItems:为空

消息显示:纠结的一天

收获园豆:15
无之无 | 大侠五级 |园豆:5095 | 2012-05-11 15:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册