xref: /php-src/ext/soap/tests/classmap006.phpt (revision e1b59e9e)
1--TEST--
2SOAP Classmap 6: encoding of inherited objects with namespace
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
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__."/classmap006.wsdl",
52    array('classmap'=>array('A'=>'A','{urn:abt}At'=>'Attest','B'=>'B')));
53print_r($client->f(new Attest('test')));
54?>
55--EXPECT--
56B Object
57(
58    [x] => 5
59    [y] => 6
60)
61