php - SOAP 错误 : Encoding: object has no 'FinalBookingDate' property

标签 php soap wsdl soapui soap-client

在开始之前,我知道,这个错误意味着我应该定义属性 FinalBookingDate,但只要继续阅读,您就会理解我的观点。

网址是:http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?op=getBookingList 我首先使用 SoapUi 进行测试,并成功获得了我需要的列表: soapui

在 php 上,我只能得到这个响应:SOAP-ERROR: Encoding: object has no 'FinalBookingDate' property

来自 php 的 SoapClient 是:

$params = array('soap_version'   => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding'=>'UTF-8', 'trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new \SoapClient('http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?wsdl', $params);

然后是检索数据的代码:

    /*
    $query = array(
        'InitialServiceDate' => '2015-01-20',
        'InitialBookingDate' => '2015-01-20',
        'FinalBookingDate' => '2015-01-20',
        'FinalServiceDate' => '2015-01-20',
        'CreationUserId' => 1338,
        'CityId' => 4166,
        'ServiceTypes' => array('eServiceType' => 'HOTEL')
    );
     */
    $query = array(
        'InitialBookingDate' => '2015-01-20',
        'ServiceTypes' => array('eServiceType' => 'HOTEL')
    );
    $args = new \stdClass;
    $args->credential = new \stdClass;
    $args->credential->UserName = $conn['userPass']['usr'];
    $args->credential->Password = $conn['userPass']['pass'];
    $args->searchBookingCriteria = new \stdClass;
    $args->searchBookingCriteria->InitialBookingDate = '2015-01-20';
    $args->searchBookingCriteria->ServiceTypes = new \stdClass;
    $args->searchBookingCriteria->ServiceTypes->eServiceType = 'HOTEL';

    //$args = array('credential'=>$credentials, 'searchBookingCriteria' => $query);
    $data = $conn['client']->getBookingList($args);
    print_r($data);
    exit;

如您所见,我尝试了两种方法将 $args 发送到 getBookingList,据我所知,这两种方法都是有效的,但两者(使用数组或对象)都返回相同的错误。在最初评论的代码中,您可以看到我尝试定义 Web 服务要求的所有 does 属性,但在定义所有这些属性之后,我得到一个空结果。

我的问题是,我应该在 SoapClient 上定义一些额外的参数吗?为什么 SoapUI 可以成功呢?我在这里缺少什么?

奖励:带有默认请求的 SoapUI 全屏打印,包括可选参数 https://www.evernote.com/shard/s14/sh/fb5ac276-8147-4e09-95bb-afa0be66d7a6/d273441c74186bf1e600b42ab3303899/deep/0/SoapUI-5.0.0.png

最佳答案

你能试试这个更直接的方法吗:

   try { 
    $params = array('soap_version'   => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding'=>'UTF-8', 'trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
        $client = new SoapClient('http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?wsdl',$params); 
    } catch (SoapFault $E) { 
        echo $E->faultstring;
    }
    if ($client) { 
    $req_params = array('credential' => 
                            array('userName' => 'XXXXXXX',
                                  'Password' => 'XXXXXXX'),
                        'searchBookingCriteria' =>
                            array('BookingNumber' => array('int' => 'XXXXXXXXX'),
                                  'ServiceTypes' => array('eServiceType' => 'HOTEL'),
                                  'PassengerName'=> 'XXXXXXXX',
                                  'InitialBookingDate'=> '2015-01-16',
                                  'FinalBookingDate'=> '2015-01-16',
                                  'InitialServiceDate' => '2015-01-18',
                                  'FinalServiceDate' => '2015-01-18',
                                  'BookingStatus'=> array('eStatus' => 'ACTIVATED'),
                                  'PaymentStatus'=> array('ePaymentStatus' => 'Payed'),
                                  'CreationUserId'=> 'XXX',
                                  'CityId'=> 'XXXX',
                                  'ExternalReference'=> '')
        );
    $response = $client->__soapCall('getBookingList',array($req_params));
    var_dump($response);
    }

关于php - SOAP 错误 : Encoding: object has no 'FinalBookingDate' property,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28116412/

相关文章:

java - 使用 SAAJ 对 Java SOAP 调用进行 Blowfish 加密

java - 为我的 WSDL 工作生成 Web 服务

python - 使用 zeep/python 创建 XML 序列

php - 对 name、id、onclick、onsubmit 感到困惑 - 我在数据库中提交数据时做错了什么?

php - 如何在wordpress的搜索页面上设置wp_query

java - 在 Java 中使用 WSS4j 对 SOAP 消息进行签名

php - WSDL 的问题

php - CI中如何将多维数组插入数据库?

php - 如何使用 PHP 和 MySQL 设置购物车总价

node.js - 目标命名空间 "undefined"已被另一个架构使用