xref: /PHP-8.4/ext/soap/tests/classmap007.phpt (revision e1b59e9e)
1--TEST--
2SOAP Classmap 7: encoding of inherited objects with namespace and cache wsdl
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=1
7--FILE--
8<?php
9class A {
10  public $x;
11  function __construct($a){
12    $this->x = $a;
13  }
14}
15class Attest {
16  public $x;
17  function __construct($a){
18    $this->x = $a;
19  }
20}
21class B extends A {
22  public $y;
23  function __construct($a){
24    parent::__construct($a);
25    $this->y = $a + 1;
26  }
27}
28
29function f($input){
30  return new B(5);
31}
32
33class LocalSoapClient extends SoapClient {
34  private $server;
35
36  function __construct($wsdl, $options) {
37    parent::__construct($wsdl, $options);
38    $this->server = new SoapServer($wsdl, $options);
39    $this->server->addFunction("f");
40  }
41
42  function __doRequest($request, $location, $action, $version, $one_way = 0): string {
43    ob_start();
44    $this->server->handle($request);
45    $response = ob_get_contents();
46    ob_end_clean();
47    return $response;
48  }
49}
50
51$client = new LocalSoapClient(__DIR__."/classmap007.wsdl",
52    array('classmap'=>array('A'=>'A','{urn:abt}At'=>'Attest','B'=>'B')));
53print_r($client->f(new Attest('test')));
54print_r($client->f(new Attest('test')));
55?>
56--EXPECT--
57B Object
58(
59    [x] => 5
60    [y] => 6
61)
62B Object
63(
64    [x] => 5
65    [y] => 6
66)
67