xref: /PHP-8.2/ext/soap/tests/server022.phpt (revision 7f2f0c00)
1--TEST--
2SOAP Server 22: user fault (through throw of subclass)
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7class MyFault extends SoapFault {
8    function __construct() {
9        parent::__construct("MyFault","My fault string");
10    }
11}
12
13
14function test() {
15    throw new MyFault;
16}
17
18$server = new soapserver(null,array('uri'=>"http://testuri.org"));
19$server->addfunction("test");
20
21$HTTP_RAW_POST_DATA = <<<EOF
22<?xml version="1.0" encoding="ISO-8859-1"?>
23<SOAP-ENV:Envelope
24  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
25  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
26  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
27  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
28  xmlns:si="http://soapinterop.org/xsd">
29  <SOAP-ENV:Body>
30    <ns1:test xmlns:ns1="http://testuri.org"/>
31  </SOAP-ENV:Body>
32</SOAP-ENV:Envelope>
33EOF;
34
35$server->handle($HTTP_RAW_POST_DATA);
36echo "ok\n";
37?>
38--EXPECT--
39<?xml version="1.0" encoding="UTF-8"?>
40<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>MyFault</faultcode><faultstring>My fault string</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
41ok
42