xref: /PHP-8.3/ext/soap/tests/bugs/bug31695.phpt (revision 8b561d33)
1--TEST--
2Bug #31695 (Cannot redefine endpoint when using WSDL)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled", 0);
8
9function Test($x) {
10    return $x;
11}
12
13class LocalSoapClient extends SoapClient {
14  private $server;
15
16  function __construct($wsdl, $options=array()) {
17    parent::__construct($wsdl, $options);
18    $this->server = new SoapServer($wsdl, $options);
19    $this->server->addFunction("Test");
20  }
21
22  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
23    echo "$location\n";
24    ob_start();
25    $this->server->handle($request);
26    $response = ob_get_contents();
27    ob_end_clean();
28    return $response;
29  }
30}
31
32$client = new LocalSoapClient(__DIR__."/bug31695.wsdl");
33$client->Test("str");
34$client = new LocalSoapClient(__DIR__."/bug31695.wsdl", array("location"=>"test://1"));
35$client->Test("str");
36$client->__soapCall("Test",
37                    array("arg1"),
38                     array("location"=>"test://2"));
39$old = $client->__setLocation("test://3");
40echo "$old\n";
41$client->Test("str");
42$client->Test("str");
43$client->__setLocation($old);
44$client->Test("str");
45$old = $client->__setLocation();
46$client->Test("str");
47$client->__setLocation($old);
48$client->Test("str");
49$client->__setLocation(null);
50$client->Test("str");
51var_dump($client->__setLocation());
52?>
53--EXPECT--
54test://0
55test://1
56test://2
57test://1
58test://3
59test://3
60test://1
61test://0
62test://1
63test://0
64NULL
65