xref: /PHP-8.4/ext/soap/tests/server024.phpt (revision 7f2f0c00)
1--TEST--
2SOAP Server 24: Send SOAP headers those were not received
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7class TestHeader1 extends SoapHeader {
8    function __construct($data) {
9        parent::__construct("http://testuri.org", "Test1", $data);
10    }
11}
12
13class TestHeader2 extends SoapHeader {
14    function __construct($data) {
15        parent::__construct("http://testuri.org", "Test2", $data);
16    }
17}
18
19function test() {
20    global $server;
21    $server->addSoapHeader(new TestHeader1("Hello Header!"));
22    $server->addSoapHeader(new TestHeader2("Hello Header!"));
23    return "Hello Body!";
24}
25
26$server = new soapserver(null,array('uri'=>"http://testuri.org"));
27$server->addfunction("test");
28
29$HTTP_RAW_POST_DATA = <<<EOF
30<?xml version="1.0" encoding="ISO-8859-1"?>
31<SOAP-ENV:Envelope
32  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
33  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
34  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
35  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
36  xmlns:si="http://soapinterop.org/xsd">
37  <SOAP-ENV:Body>
38    <ns1:test xmlns:ns1="http://testuri.org"/>
39  </SOAP-ENV:Body>
40</SOAP-ENV:Envelope>
41EOF;
42
43$server->handle($HTTP_RAW_POST_DATA);
44echo "ok\n";
45?>
46--EXPECT--
47<?xml version="1.0" encoding="UTF-8"?>
48<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns1:Test1>Hello Header!</ns1:Test1><ns1:Test2>Hello Header!</ns1:Test2></SOAP-ENV:Header><SOAP-ENV:Body><ns1:testResponse><return xsi:type="xsd:string">Hello Body!</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
49ok
50