xref: /PHP-8.3/ext/soap/tests/bugs/bug35142.phpt (revision 8b561d33)
1--TEST--
2Bug #35142 (SOAP Client/Server Complex Object Support)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9ini_set("soap.wsdl_cache_enabled",0);
10$timestamp = "2005-11-08T11:22:07+03:00";
11$wsdl = __DIR__."/bug35142.wsdl";
12
13function PostEvents($x) {
14    var_dump($x);
15    exit();
16  return $x;
17}
18
19class TestSoapClient extends SoapClient {
20  private $server;
21
22  function __construct($wsdl, $options) {
23    parent::__construct($wsdl, $options);
24    $this->server = new SoapServer($wsdl, $options);
25    $this->server->addFunction('PostEvents');
26  }
27
28  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
29        echo "$request\n";
30    $this->server->handle($request);
31    return $response;
32  }
33
34}
35
36$soapClient = new TestSoapClient($wsdl,
37    array('trace' => 1, 'exceptions' => 0,
38        'classmap' => array('logOnEvent' => 'LogOnEvent',
39            'logOffEvent' => 'LogOffEvent',
40            'events' => 'IVREvents')));
41
42$logOnEvent = new LogOnEvent(34567, $timestamp);
43$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked");
44$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree");
45$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents);
46
47$result = $soapClient->PostEvents($ivrEvents);
48
49class LogOffEvent {
50  public $audienceMemberId;
51  public $timestamp;
52  public $smokeStatus;
53  public $callInitiator;
54
55  function __construct($audienceMemberId, $timestamp, $smokeStatus) {
56    $this->audienceMemberId = $audienceMemberId;
57    $this->timestamp = $timestamp;
58    $this->smokeStatus = $smokeStatus;
59    $this->callInitiator = "IVR";
60  }
61}
62
63class LogOnEvent {
64  public $audienceMemberId;
65  public $timestamp;
66
67  function __construct($audienceMemberId, $timestamp) {
68    $this->audienceMemberId = $audienceMemberId;
69    $this->timestamp = $timestamp;
70  }
71}
72
73class IVREvents {
74  public $version;
75  public $activityId;
76  public $messageId;
77  public $source;
78  public $logOnEvent;
79  public $logOffEvent;
80
81  function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) {
82    $this->version = $version;
83    $this->activityId = $activityId;
84    $this->messageId = $messageId;
85    $this->source = $source;
86    $this->logOnEvent = $logOnEvent;
87    $this->logOffEvent = $logOffEvent;
88  }
89}
90?>
91--EXPECTF--
92<?xml version="1.0" encoding="UTF-8"?>
93<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testurl/Message"><SOAP-ENV:Body><ns1:ivrEvents version="1.0" activityId="101" messageId="12345" source="IVR"><ns1:logOffEvent audienceMemberId="34567" timestamp="2005-11-08T11:22:07+03:00" smokeStatus="Smoked" callInitiator="IVR"/><ns1:logOffEvent audienceMemberId="34568" timestamp="2005-11-08T11:22:07+03:00" smokeStatus="SmokeFree" callInitiator="IVR"/><ns1:logOnEvent audienceMemberId="34567" timestamp="2005-11-08T11:22:07+03:00"/></ns1:ivrEvents></SOAP-ENV:Body></SOAP-ENV:Envelope>
94
95object(IVREvents)#%d (6) {
96  ["version"]=>
97  string(3) "1.0"
98  ["activityId"]=>
99  int(101)
100  ["messageId"]=>
101  int(12345)
102  ["source"]=>
103  string(3) "IVR"
104  ["logOnEvent"]=>
105  object(LogOnEvent)#%d (2) {
106    ["audienceMemberId"]=>
107    int(34567)
108    ["timestamp"]=>
109    string(25) "2005-11-08T11:22:07+03:00"
110  }
111  ["logOffEvent"]=>
112  array(2) {
113    [0]=>
114    object(LogOffEvent)#%d (4) {
115      ["audienceMemberId"]=>
116      int(34567)
117      ["timestamp"]=>
118      string(25) "2005-11-08T11:22:07+03:00"
119      ["smokeStatus"]=>
120      string(6) "Smoked"
121      ["callInitiator"]=>
122      string(3) "IVR"
123    }
124    [1]=>
125    object(LogOffEvent)#%d (4) {
126      ["audienceMemberId"]=>
127      int(34568)
128      ["timestamp"]=>
129      string(25) "2005-11-08T11:22:07+03:00"
130      ["smokeStatus"]=>
131      string(9) "SmokeFree"
132      ["callInitiator"]=>
133      string(3) "IVR"
134    }
135  }
136}
137