transport001.phpt 786 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. SOAP Transport 1: Local transport using SoapClient::__doRequest
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. function Add($x,$y) {
  8. return $x+$y;
  9. }
  10. class LocalSoapClient extends SoapClient {
  11. function __construct($wsdl, $options) {
  12. parent::__construct($wsdl, $options);
  13. $this->server = new SoapServer($wsdl, $options);
  14. $this->server->addFunction('Add');
  15. }
  16. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  17. ob_start();
  18. $this->server->handle($request);
  19. $response = ob_get_contents();
  20. ob_end_clean();
  21. return $response;
  22. }
  23. }
  24. $x = new LocalSoapClient(NULL,array('location'=>'test://',
  25. 'uri'=>'http://testuri.org'));
  26. var_dump($x->Add(3,4));
  27. echo "ok\n";
  28. ?>
  29. --EXPECT--
  30. int(7)
  31. ok