xref: /php-src/ext/soap/tests/bugs/bug73538.phpt (revision 7f2f0c00)
1--TEST--
2SOAP: SoapClient::__setHeaders array overrides previous headers
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7
8$client = new SoapClient(null, [
9    "location"      =>  "test://",
10    "uri"           =>  "test://",
11    "exceptions"    =>  false,
12    "trace"         =>  true,
13]);
14$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 1]));
15$client->__setSoapHeaders(new \SoapHeader('ns', 'Header', ['something' => 2]));
16$client->test();
17echo $client->__getLastRequest();
18
19$client = new SoapClient(null, [
20    "location"      =>  "test://",
21    "uri"           =>  "test://",
22    "exceptions"    =>  false,
23    "trace"         =>  true,
24]);
25$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 1])]);
26$client->__setSoapHeaders([new \SoapHeader('ns', 'Header', ['something' => 2])]);
27$client->test();
28echo $client->__getLastRequest();
29
30?>
31--EXPECT--
32<?xml version="1.0" encoding="UTF-8"?>
33<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test://" xmlns:ns2="ns" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns2:Header><item><key>something</key><value>2</value></item></ns2:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>
34<?xml version="1.0" encoding="UTF-8"?>
35<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="test://" xmlns:ns2="ns" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns2:Header><item><key>something</key><value>2</value></item></ns2:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>
36