xref: /php-src/ext/soap/tests/bugs/bug35142.phpt (revision e1b59e9e)
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    ob_start();
31    $this->server->handle($request);
32    $response = ob_get_contents();
33    ob_end_clean();
34    return $response;
35  }
36
37}
38
39$soapClient = new TestSoapClient($wsdl,
40    array('trace' => 1, 'exceptions' => 0,
41        'classmap' => array('logOnEvent' => 'LogOnEvent',
42            'logOffEvent' => 'LogOffEvent',
43            'events' => 'IVREvents')));
44
45$logOnEvent = new LogOnEvent(34567, $timestamp);
46$logOffEvents[] = new LogOffEvent(34567, $timestamp, "Smoked");
47$logOffEvents[] = new LogOffEvent(34568, $timestamp, "SmokeFree");
48$ivrEvents = new IVREvents("1.0", 101, 12345, 'IVR', $logOnEvent, $logOffEvents);
49
50$result = $soapClient->PostEvents($ivrEvents);
51
52class LogOffEvent {
53  public $audienceMemberId;
54  public $timestamp;
55  public $smokeStatus;
56  public $callInitiator;
57
58  function __construct($audienceMemberId, $timestamp, $smokeStatus) {
59    $this->audienceMemberId = $audienceMemberId;
60    $this->timestamp = $timestamp;
61    $this->smokeStatus = $smokeStatus;
62    $this->callInitiator = "IVR";
63  }
64}
65
66class LogOnEvent {
67  public $audienceMemberId;
68  public $timestamp;
69
70  function __construct($audienceMemberId, $timestamp) {
71    $this->audienceMemberId = $audienceMemberId;
72    $this->timestamp = $timestamp;
73  }
74}
75
76class IVREvents {
77  public $version;
78  public $activityId;
79  public $messageId;
80  public $source;
81  public $logOnEvent;
82  public $logOffEvent;
83
84  function __construct($version, $activityId, $messageId, $source, $logOnEvent=NULL, $logOffEvent=NULL) {
85    $this->version = $version;
86    $this->activityId = $activityId;
87    $this->messageId = $messageId;
88    $this->source = $source;
89    $this->logOnEvent = $logOnEvent;
90    $this->logOffEvent = $logOffEvent;
91  }
92}
93?>
94--EXPECTF--
95<?xml version="1.0" encoding="UTF-8"?>
96<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>
97
98object(IVREvents)#%d (6) {
99  ["version"]=>
100  string(3) "1.0"
101  ["activityId"]=>
102  int(101)
103  ["messageId"]=>
104  int(12345)
105  ["source"]=>
106  string(3) "IVR"
107  ["logOnEvent"]=>
108  object(LogOnEvent)#%d (2) {
109    ["audienceMemberId"]=>
110    int(34567)
111    ["timestamp"]=>
112    string(25) "2005-11-08T11:22:07+03:00"
113  }
114  ["logOffEvent"]=>
115  array(2) {
116    [0]=>
117    object(LogOffEvent)#%d (4) {
118      ["audienceMemberId"]=>
119      int(34567)
120      ["timestamp"]=>
121      string(25) "2005-11-08T11:22:07+03:00"
122      ["smokeStatus"]=>
123      string(6) "Smoked"
124      ["callInitiator"]=>
125      string(3) "IVR"
126    }
127    [1]=>
128    object(LogOffEvent)#%d (4) {
129      ["audienceMemberId"]=>
130      int(34568)
131      ["timestamp"]=>
132      string(25) "2005-11-08T11:22:07+03:00"
133      ["smokeStatus"]=>
134      string(9) "SmokeFree"
135      ["callInitiator"]=>
136      string(3) "IVR"
137    }
138  }
139}
140