xref: /PHP-8.1/ext/soap/tests/bugs/bug36629.phpt (revision 7f2f0c00)
1--TEST--
2Bug #36629 (SoapServer::handle() exits on SOAP faults)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7function test1() {
8  throw new SoapFault("Server", "test1");
9}
10function test2() {
11  return new SoapFault("Server", "test2");
12}
13
14$server = new soapserver(null,array('uri'=>"http://testuri.org"));
15$server->addfunction(array("test1","test2"));
16
17$HTTP_RAW_POST_DATA = <<<EOF
18<?xml version="1.0" encoding="ISO-8859-1"?>
19<SOAP-ENV:Envelope
20  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
21  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
22  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
23  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24  xmlns:si="http://soapinterop.org/xsd">
25  <SOAP-ENV:Body>
26    <ns1:test1 xmlns:ns1="http://testuri.org" />
27  </SOAP-ENV:Body>
28</SOAP-ENV:Envelope>
29EOF;
30$server->handle($HTTP_RAW_POST_DATA);
31
32$HTTP_RAW_POST_DATA = <<<EOF
33<?xml version="1.0" encoding="ISO-8859-1"?>
34<SOAP-ENV:Envelope
35  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
36  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
37  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
38  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39  xmlns:si="http://soapinterop.org/xsd">
40  <SOAP-ENV:Body>
41    <ns1:test2 xmlns:ns1="http://testuri.org" />
42  </SOAP-ENV:Body>
43</SOAP-ENV:Envelope>
44EOF;
45$server->handle($HTTP_RAW_POST_DATA);
46echo "ok\n";
47?>
48--EXPECT--
49<?xml version="1.0" encoding="UTF-8"?>
50<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>test1</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
51<?xml version="1.0" encoding="UTF-8"?>
52<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>test2</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
53ok
54