xref: /PHP-7.1/ext/soap/tests/bug68361.phpt (revision 327d4f9a)
1--TEST--
2Bug #68361 Segmentation fault on SoapClient::__getTypes
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7
8$xml = <<<XML
9<?xml version="1.0" encoding="UTF-8"?>
10<definitions name="TestServer" targetNamespace="http://foo.bar/testserver" xmlns:tns="http://foo.bar/testserver" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://foo.bar/testserver/types">
11  <types>
12    <xsd:schema targetNamespace="http://foo.bar/testserver/types" xmlns="http://foo.bar/testserver/types">
13      <xsd:complexType name="ArrayOfEmployeeReturn">
14        <xsd:complexContent>
15          <xsd:restriction base="soapenc:Array">
16            <xsd:attribute ref="soapenc:arrayType" arrayType="ns:Employee[]"/>
17          </xsd:restriction>
18        </xsd:complexContent>
19      </xsd:complexType>
20      <xsd:complexType name="Employee">
21        <xsd:sequence>
22          <xsd:element name="id" type="xsd:int"/>
23          <xsd:element name="department" type="xsd:string"/>
24          <xsd:element name="name" type="xsd:string"/>
25          <xsd:element name="age" type="xsd:int"/>
26        </xsd:sequence>
27      </xsd:complexType>
28      <xsd:element name="Employee" nillable="true" type="ns:Employee"/>
29      <xsd:complexType name="User">
30        <xsd:sequence>
31          <xsd:element name="name" type="xsd:string"/>
32          <xsd:element name="age" type="xsd:int"/>
33        </xsd:sequence>
34      </xsd:complexType>
35      <xsd:element name="User" nillable="true" type="ns:User"/>
36    </xsd:schema>
37  </types>
38  <message name="getEmployeeRequest">
39    <part name="name" type="xsd:name"/>
40  </message>
41  <message name="getEmployeeResponse">
42    <part name="employeeReturn" type="ns:ArrayOfEmployeeReturn"/>
43  </message>
44  <message name="getUserRequest">
45    <part name="id" type="xsd:id"/>
46  </message>
47  <message name="getUserResponse">
48    <part name="userReturn" element="ns:User"/>
49  </message>
50  <portType name="TestServerPortType">
51    <operation name="getEmployee">
52      <input message="tns:getEmployeeRequest"/>
53      <output message="tns:getEmployeeResponse"/>
54    </operation>
55    <operation name="getUser">
56      <input message="tns:getUserRequest"/>
57      <output message="tns:getUserResponse"/>
58    </operation>
59  </portType>
60  <binding name="TestServerBinding" type="tns:TestServerPortType">
61    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
62    <operation name="getEmployee">
63      <soap:operation soapAction="http://foo.bar/testserver/#getEmployee"/>
64      <input>
65        <soap:body use="literal" namespace="http://foo.bar/testserver"/>
66      </input>
67      <output>
68        <soap:body use="literal" namespace="http://foo.bar/testserver"/>
69      </output>
70    </operation>
71    <operation name="getUser">
72      <soap:operation soapAction="http://foo.bar/testserver/#getUser"/>
73      <input>
74        <soap:body use="literal" namespace="http://foo.bar/testserver"/>
75      </input>
76      <output>
77        <soap:body use="literal" namespace="http://foo.bar/testserver"/>
78      </output>
79    </operation>
80  </binding>
81  <service name="TestServerService">
82    <port name="TestServerPort" binding="tns:TestServerBinding">
83      <soap:address location="http://localhost/wsdl-creator/TestClass.php"/>
84    </port>
85  </service>
86</definitions>
87XML;
88
89file_put_contents(__DIR__ . "/bug68361.xml", $xml);
90$client = new SoapClient(__DIR__ . "/bug68361.xml");
91
92$res = $client->__getTypes(); // Segmentation fault here
93
94print_r($res);
95?>
96--CLEAN--
97<?php
98unlink(__DIR__ . "/bug68361.xml");
99?>
100--EXPECT--
101Array
102(
103    [0] => anyType ArrayOfEmployeeReturn[]
104    [1] => struct Employee {
105 int id;
106 string department;
107 string name;
108 int age;
109}
110    [2] => struct User {
111 string name;
112 int age;
113}
114)
115