How to pass an array into a PHP SoapClient call

后端 未结 6 1955
[愿得一人]
[愿得一人] 2020-12-05 19:33

Using PHP and SoapClient.

I need to pass the following XML into a soap request - i.e. multiple \'s within .

<
6条回答
  •  猫巷女王i
    2020-12-05 19:49

    I also had this problem and found the solution. Stays needs to be an array with ascending keys starting with 0.

    $client = new SoapClient('http://myservice.com?wsdl');
    $stays[] = array('startDate'=>'01-01-2013', 'endDate'=>'02-02-2013');
    $stays[] = array('startDate'=>'02-02-2013', 'endDate'=>'03-03-2013');
    $params = array(
      'reservation' => array('stays'=>$stays)
    );
    $client->saveReservation($params);
    

    I found my answer on this page: https://bugs.php.net/bug.php?id=45284

提交回复
热议问题