PHP 中作为 SOAP 客户端参数的对象

Object as parameter for SOAP client in PHP

我在 php 中传递对象参数时遇到问题。也许你能帮我。

我想使用方法 getBookingPairsByPersonID

在 Wsdl 中它看起来像这样:

   <xsd:element name="getBookingPairsByPersonID" type="tns:getBookingPairsByPersonID"/>
   <xsd:complexType name="getBookingPairsByPersonID">
   <xsd:sequence>
   <xsd:element minOccurs="0" name="arg0" nillable="true" type="xsd:string"/>
   <xsd:element name="arg1" nillable="true" type="tns:ArrayOfString"/>
   <xsd:element minOccurs="0" name="arg2" type="ns0:WSTimestamp"/>
   <xsd:element minOccurs="0" name="arg3" type="ns0:WSTimestamp"/>
   <xsd:element name="arg4" type="xsd:boolean"/>
   <xsd:element name="arg5" type="xsd:int"/>
   </xsd:sequence>
   </xsd:complexType>

这就是文档所说的

java.util.List<WSBookingPair> getBookingPairsByPersonID(java.lang.String session,
                                                       java.lang.String[] personIDs,
                                                       WSTimestamp from,
                                                       WSTimestamp to,
                                                       boolean checked,
                                                       int type)

我的 PHP 代码:


$wsID  = array ('1063');
$wsInt = 1;
$wschecked = false;
$wsFrom ='28.07.2021 00:00:00';
$wsTo ='28.07.2021 23:59:59';

$wsBooking = $client->getBookingPairsByPersonID(array('arg0' => $session->return, 'arg1' => array('ArrayOfString' => $wsID) , 'arg2' =>  $wsFrom , 'arg3' => $wsTo, 'arg4' => $wschecked, 'arg5'=> $wsInt));

var_dump($wsBooking->return);
echo var_dump($client->__getLastRequest());

输出:

object(stdClass)[21] null

WSTimestamp 的结构如下:

输入:

$wsTsNow = $client->getTime(array('arg0' => $session->return));

输出:

object(stdClass)[5]
 public 'return' => 
   object(stdClass)[6]
     public 'TS' => int 1627977040077
     public 'day' => int 3
     public 'hour' => int 9
     public 'min' => int 50
     public 'month' => int 8
     public 'sec' => int 40
     public 'timeInSeconds' => int 1627977040
     public 'timestamp' => string '03.08.2021 09:50:40' (length=19)
     public 'year' => int 2021

之后我尝试创建一个对象,但也没有用

class WSTimestamp{
    public $timestamp;
}

$wsFrom = new WSTimestamp();
$wsFrom->timestamp = "28.07.2021 00:00:00";

$wsTo = new WSTimestamp();
$wsto->timestamp = "28.07.2021 23:59:59";

我不明白的是下面的方法行得通

描述:


getLevelsEByIdentification
java.util.List<WSExtensibleLevel> getLevelsEByIdentification(java.lang.String session,
                                                             WSLevelIdentification[] ids,
                                                             WSTimestamp timestamp)

代码:


$wsTsNow = $client->getTime(array('arg0' => $session->return));
$wsLevelIdentArray = array('levelID' => 1, 'code' => '17022');
$wsLevelEArray = $client->getLevelsEByIdentification(array('arg0' => $session->return, 'arg1' => array('WSLevelIdentification' => $wsLevelIdentArray), 'arg2' => $wsTsNow));

如何正确传递对象参数?

现在可以使用了:

输入:

$wsInt = 2;
$wschecked = false;
$wsID  = array ("9999");


     class WSTimestamp{
            public $timestamp;
        }

$wsFrom = new WSTimestamp();
$wsFrom->timestamp = "09.07.2021 00:00:00";

$wsTo = new WSTimestamp();
$wsTo->timestamp = "09.07.2021 23:59:59";

$wsBooking = $client->getBookingPairsByPersonID(array('arg0' => $session->return, 'arg1' => $wsID , 'arg2' =>  $wsFrom , 'arg3' => $wsTo, 'arg4' => $wschecked, 'arg5'=> $wsInt));

var_dump($wsBooking->return->WSBookingPair);

输出:

object(stdClass)[20]
  public 'absence' => boolean false
  public 'checked' => boolean false
  public 'complete' => boolean true
  public 'duration' => int 0
  public 'from' => 
    object(stdClass)[21]
      public 'TS' => int 1625828040000
      public 'day' => int 9
      public 'hour' => int 12
      public 'min' => int 54
      public 'month' => int 7
      public 'sec' => int 0
      public 'timeInSeconds' => int 1625828040
      public 'timestamp' => string '09.07.2021 12:54:00' (length=19)
      public 'year' => int 2021
  public 'fromBookingID' => int 1905
  public 'fullDay' => boolean false
  public 'levels' => 
    object(stdClass)[22]
  public 'notice' => string '' (length=0)
  public 'person' => string '9999' (length=4)
  public 'properties' => null
  public 'to' => 
    object(stdClass)[23]
      public 'TS' => int 1625828040000
      public 'day' => int 9
      public 'hour' => int 12
      public 'min' => int 54
      public 'month' => int 7
      public 'sec' => int 0
      public 'timeInSeconds' => int 1625828040
      public 'timestamp' => string '09.07.2021 12:54:00' (length=19)
      public 'year' => int 2021
  public 'toBookingID' => int 1906