bug35142.phpt 3.7 KB

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