bug30045.phpt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. --TEST--
  2. Bug #30045 (Cannot pass big integers (> 2147483647) in SOAP requests)
  3. --EXTENSIONS--
  4. soap
  5. simplexml
  6. --INI--
  7. soap.wsdl_cache_enabled=1
  8. --FILE--
  9. <?php
  10. function foo($type, $num) {
  11. return new SoapVar($num, $type);
  12. }
  13. class LocalSoapClient extends SoapClient {
  14. function __construct($wsdl, $options) {
  15. parent::__construct($wsdl, $options);
  16. $this->server = new SoapServer($wsdl, $options);
  17. $this->server->addFunction('foo');
  18. }
  19. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  20. $xml = simplexml_load_string($request);
  21. echo $xml->children("http://schemas.xmlsoap.org/soap/envelope/")->Body->children("http://test-uri")->children()->param1->asXML(),"\n";
  22. unset($xml);
  23. ob_start();
  24. $this->server->handle($request);
  25. $response = ob_get_contents();
  26. ob_end_clean();
  27. return $response;
  28. }
  29. }
  30. $soap = new LocalSoapClient(NULL, array("uri"=>"http://test-uri", "location"=>"test://"));
  31. function test($type, $num) {
  32. global $soap;
  33. try {
  34. printf(" %0.0f\n ", $num);
  35. $ret = $soap->foo($type, new SoapVar($num, $type));
  36. printf(" %0.0f\n", $ret);
  37. } catch (SoapFault $ex) {
  38. var_dump($ex);
  39. }
  40. }
  41. /*
  42. echo "byte\n";
  43. //test(XSD_BYTE, -129);
  44. test(XSD_BYTE, -128);
  45. test(XSD_BYTE, 127);
  46. //test(XSD_BYTE, 128);
  47. echo "\nshort\n";
  48. //test(XSD_SHORT, -32769);
  49. test(XSD_SHORT, -32768);
  50. test(XSD_SHORT, 32767);
  51. //test(XSD_SHORT, 32768);
  52. echo "\nint\n";
  53. //test(XSD_INT, -2147483649);
  54. test(XSD_INT, -2147483648);
  55. test(XSD_INT, 2147483647);
  56. //test(XSD_INT, 2147483648);
  57. echo "\nlong\n";
  58. //test(XSD_LONG, -9223372036854775809);
  59. test(XSD_LONG, -9223372036854775808);
  60. test(XSD_LONG, 9223372036854775807);
  61. //test(XSD_LONG, 9223372036854775808);
  62. echo "\nunsignedByte\n";
  63. //test(XSD_UNSIGNEDBYTE, -1);
  64. test(XSD_UNSIGNEDBYTE, 0);
  65. test(XSD_UNSIGNEDBYTE, 255);
  66. //test(XSD_UNSIGNEDBYTE, 256);
  67. echo "\nunsignedShort\n";
  68. //test(XSD_UNSIGNEDSHORT, -1);
  69. test(XSD_UNSIGNEDSHORT, 0);
  70. test(XSD_UNSIGNEDSHORT, 65535);
  71. //test(XSD_UNSIGNEDSHORT, 65536);
  72. echo "\nunsignedInt\n";
  73. //test(XSD_UNSIGNEDINT, -1);
  74. test(XSD_UNSIGNEDINT, 0);
  75. test(XSD_UNSIGNEDINT, 4294967295);
  76. //test(XSD_UNSIGNEDINT, 4294967296);
  77. echo "\nunsignedLong\n";
  78. //test(XSD_UNSIGNEDLONG, -1);
  79. test(XSD_UNSIGNEDLONG, 0);
  80. test(XSD_UNSIGNEDLONG, 18446744073709551615);
  81. //test(XSD_UNSIGNEDLONG, 18446744073709551616);
  82. echo "\nnegativeInteger\n";
  83. test(XSD_NEGATIVEINTEGER, -18446744073709551616);
  84. test(XSD_NEGATIVEINTEGER, -1);
  85. //test(XSD_NEGATIVEINTEGER, 0);
  86. echo "\nnonPositiveInteger\n";
  87. test(XSD_NONPOSITIVEINTEGER, -18446744073709551616);
  88. test(XSD_NONPOSITIVEINTEGER, 0);
  89. //test(XSD_NONPOSITIVEINTEGER, 1);
  90. echo "\nnonNegativeInteger\n";
  91. //test(XSD_NONNEGATIVEINTEGER, -1);
  92. test(XSD_NONNEGATIVEINTEGER, 0);
  93. test(XSD_NONNEGATIVEINTEGER, 18446744073709551616);
  94. echo "\nPositiveInteger\n";
  95. //test(XSD_POSITIVEINTEGER, 0);
  96. test(XSD_POSITIVEINTEGER, 1);
  97. test(XSD_POSITIVEINTEGER, 18446744073709551616);
  98. echo "\ninteger\n";
  99. test(XSD_INTEGER, -18446744073709551616);
  100. test(XSD_INTEGER, 18446744073709551616);
  101. */
  102. echo "long\n";
  103. test(XSD_LONG, 2147483647);
  104. test(XSD_LONG, 2147483648);
  105. test(XSD_LONG, 4294967296);
  106. test(XSD_LONG, 8589934592);
  107. test(XSD_LONG, 17179869184);
  108. echo "\nunsignedLong\n";
  109. test(XSD_UNSIGNEDLONG, 2147483647);
  110. test(XSD_UNSIGNEDLONG, 2147483648);
  111. test(XSD_UNSIGNEDLONG, 4294967296);
  112. test(XSD_UNSIGNEDLONG, 8589934592);
  113. test(XSD_UNSIGNEDLONG, 17179869184);
  114. ?>
  115. --EXPECT--
  116. long
  117. 2147483647
  118. <param1 xsi:type="xsd:long">2147483647</param1>
  119. 2147483647
  120. 2147483648
  121. <param1 xsi:type="xsd:long">2147483648</param1>
  122. 2147483648
  123. 4294967296
  124. <param1 xsi:type="xsd:long">4294967296</param1>
  125. 4294967296
  126. 8589934592
  127. <param1 xsi:type="xsd:long">8589934592</param1>
  128. 8589934592
  129. 17179869184
  130. <param1 xsi:type="xsd:long">17179869184</param1>
  131. 17179869184
  132. unsignedLong
  133. 2147483647
  134. <param1 xsi:type="xsd:unsignedLong">2147483647</param1>
  135. 2147483647
  136. 2147483648
  137. <param1 xsi:type="xsd:unsignedLong">2147483648</param1>
  138. 2147483648
  139. 4294967296
  140. <param1 xsi:type="xsd:unsignedLong">4294967296</param1>
  141. 4294967296
  142. 8589934592
  143. <param1 xsi:type="xsd:unsignedLong">8589934592</param1>
  144. 8589934592
  145. 17179869184
  146. <param1 xsi:type="xsd:unsignedLong">17179869184</param1>
  147. 17179869184