xref: /PHP-8.2/ext/soap/tests/bugs/bug30106.phpt (revision 8b561d33)
1--TEST--
2Bug #30106 (SOAP cannot not parse 'ref' element. Causes Uncaught SoapFault exception)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7ini_set("soap.wsdl_cache_enabled", 0);
8
9function getContinentList() {
10    return array("getContinentListResult"=>array(
11      "schema"=>"<xsd:schema><element name=\"test\" type=\"xsd:string\"/></xsd:schema>",
12      "any"=>"<test>Hello World!</test><test>Bye World!</test>"));
13}
14
15class LocalSoapClient extends SoapClient {
16  private $server;
17
18  function __construct($wsdl, $options=array()) {
19    parent::__construct($wsdl, $options);
20    $this->server = new SoapServer($wsdl, $options);
21        $this->server->addFunction("getContinentList");
22  }
23
24  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
25    echo $request;
26    ob_start();
27    $this->server->handle($request);
28    $response = ob_get_contents();
29    ob_end_clean();
30    echo $response;
31    return $response;
32  }
33}
34
35$client = new LocalSoapClient(__DIR__."/bug30106.wsdl");
36var_dump($client->__getFunctions());
37var_dump($client->__getTypes());
38$x = $client->getContinentList(array("AFFILIATE_ID"=>1,"PASSWORD"=>"x"));
39var_dump($x);
40?>
41--EXPECTF--
42array(1) {
43  [0]=>
44  string(71) "getContinentListResponse getContinentList(getContinentList $parameters)"
45}
46array(3) {
47  [0]=>
48  string(64) "struct getContinentList {
49 int AFFILIATE_ID;
50 string PASSWORD;
51}"
52  [1]=>
53  string(83) "struct getContinentListResponse {
54 getContinentListResult getContinentListResult;
55}"
56  [2]=>
57  string(66) "struct getContinentListResult {
58 <anyXML> schema;
59 <anyXML> any;
60}"
61}
62<?xml version="1.0" encoding="UTF-8"?>
63<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/PRWebServ/getOtherInformation"><SOAP-ENV:Body><ns1:getContinentList><ns1:AFFILIATE_ID>1</ns1:AFFILIATE_ID><ns1:PASSWORD>x</ns1:PASSWORD></ns1:getContinentList></SOAP-ENV:Body></SOAP-ENV:Envelope>
64<?xml version="1.0" encoding="UTF-8"?>
65<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://tempuri.org/PRWebServ/getOtherInformation"><SOAP-ENV:Body><ns1:getContinentListResponse><ns1:getContinentListResult><xsd:schema><element name="test" type="xsd:string"/></xsd:schema><test>Hello World!</test><test>Bye World!</test></ns1:getContinentListResult></ns1:getContinentListResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
66object(stdClass)#%d (1) {
67  ["getContinentListResult"]=>
68  object(stdClass)#%d (2) {
69    ["schema"]=>
70    string(65) "<xsd:schema><element name="test" type="xsd:string"/></xsd:schema>"
71    ["any"]=>
72    string(48) "<test>Hello World!</test><test>Bye World!</test>"
73  }
74}
75