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