any.phpt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --TEST--
  2. SOAP handling of <any>
  3. --EXTENSIONS--
  4. soap
  5. --INI--
  6. precision=14
  7. soap.wsdl_cache_enabled=0
  8. --FILE--
  9. <?php
  10. class SOAPComplexType {
  11. function __construct($s, $i, $f) {
  12. $this->varString = $s;
  13. $this->varInt = $i;
  14. $this->varFloat = $f;
  15. }
  16. }
  17. $struct = new SOAPComplexType('arg',34,325.325);
  18. function echoAnyElement($x) {
  19. global $g;
  20. $g = $x;
  21. $struct = $x->inputAny->any["SOAPComplexType"];
  22. if ($struct instanceof SOAPComplexType) {
  23. return array("return" => array("any" => array("SOAPComplexType"=>new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPComplexType", "http://soapinterop.org/xsd", "SOAPComplexType", "http://soapinterop.org/"))));
  24. } else {
  25. return "?";
  26. }
  27. }
  28. class TestSoapClient extends SoapClient {
  29. function __construct($wsdl, $options) {
  30. parent::__construct($wsdl, $options);
  31. $this->server = new SoapServer($wsdl, $options);
  32. $this->server->addFunction('echoAnyElement');
  33. }
  34. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  35. ob_start();
  36. $this->server->handle($request);
  37. $response = ob_get_contents();
  38. ob_end_clean();
  39. return $response;
  40. }
  41. }
  42. $client = new TestSoapClient(__DIR__."/interop/Round4/GroupI/round4_groupI_xsd.wsdl",
  43. array("trace"=>1,"exceptions"=>0,
  44. 'classmap' => array('SOAPComplexType'=>'SOAPComplexType')));
  45. $ret = $client->echoAnyElement(
  46. array(
  47. "inputAny"=>array(
  48. "any"=>new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPComplexType", "http://soapinterop.org/xsd", "SOAPComplexType", "http://soapinterop.org/")
  49. )));
  50. var_dump($g);
  51. var_dump($ret);
  52. ?>
  53. --EXPECT--
  54. object(stdClass)#5 (1) {
  55. ["inputAny"]=>
  56. object(stdClass)#6 (1) {
  57. ["any"]=>
  58. array(1) {
  59. ["SOAPComplexType"]=>
  60. object(SOAPComplexType)#7 (3) {
  61. ["varInt"]=>
  62. int(34)
  63. ["varString"]=>
  64. string(3) "arg"
  65. ["varFloat"]=>
  66. float(325.325)
  67. }
  68. }
  69. }
  70. }
  71. object(stdClass)#8 (1) {
  72. ["return"]=>
  73. object(stdClass)#9 (1) {
  74. ["any"]=>
  75. array(1) {
  76. ["SOAPComplexType"]=>
  77. object(SOAPComplexType)#10 (3) {
  78. ["varInt"]=>
  79. int(34)
  80. ["varString"]=>
  81. string(3) "arg"
  82. ["varFloat"]=>
  83. float(325.325)
  84. }
  85. }
  86. }
  87. }