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