SOAP XML broken since PHP 8.3.9 when using classmap constructor option #15252
Description
Description
A bit of a weird issue, hope you can follow.
I am on a windows machine, downloading following php packages:
https://windows.php.net/downloads/releases/archives/php-8.3.8-Win32-vs16-x64.zip
https://windows.php.net/downloads/releases/archives/php-8.3.9-Win32-vs16-x64.zip
When running the "test.php" from attached ZIP, i get different outputs, using no php.ini and just with soap extension enabled:
Test-Script: test.zip (You need the files from zip, it contains the WSDL and XSD files required.
PHP 8.3.8
D:\php-8.3.8-Win32-vs16-x64\php.exe -dextension=D:\php-8.3.8-Win32-vs16-x64\ext\php_soap.dll D:\test\test.php
PHPVERSION: 8.3.8
XML: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages"><SOAP-ENV:Body><ns2:DeleteItem><ns2:ItemIds><ns1:ItemId Id="AAMkAGJjMzNlMDA4LTU5NzMtNDZmMS1hN2QwLWE5NDJhOTg4ZTE3ZABGAAAAAADor6LtxqzcTZY8k3FzncNoBwBqStc3k+YrRrwI06yPhA+DAAAAAAEPAABqStc3k+YrRrwI06yPhA+DAASvw7+bAAA=" ChangeKey="CQAAABYAAABqStc3k+YrRrwI06yPhA+DAASv1Zxc"/></ns2:ItemIds></ns2:DeleteItem></SOAP-ENV:Body></SOAP-ENV:Envelope>
PHP 8.3.9 or even PHP 8.3.10
D:\php-8.3.9-Win32-vs16-x64\php.exe -dextension=D:\php-8.3.9-Win32-vs16-x64\ext\php_soap.dll D:\test\test.php
PHPVERSION: 8.3.9
XML: <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages"><SOAP-ENV:Body><ns2:DeleteItem><ns2:ItemIds xsi:type="ns1:ItemIdType"/></ns2:DeleteItem></SOAP-ENV:Body></SOAP-ENV:Envelope>
Testscript (Notice you need the other files from zip attached)
<?php
namespace Testing\Soap;
$classMap = [
'ItemIdType' => '\\Testing\\Soap\\ItemIdType',
'DeleteItemType' => '\\Testing\\Soap\\DeleteItemType',
];
class ItemIdType{
public $ChangeKey;
public $Id;
public $ItemId;
}
class DeleteItemType
{
public $AffectedTaskOccurrences;
public $DeleteType;
public $ItemIds;
public $SendMeetingCancellations;
public $SuppressReadReceipts;
}
class ClientSoap extends \SoapClient
{
public function __doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false): ?string
{
echo "PHPVERSION: " . PHP_VERSION . "\n";
echo "XML: $request";
return $request;
}
}
$client = new ClientSoap(__DIR__ . "/services.wsdl", [
'classmap' => $classMap
]);
$deleteItem = new ItemIdType();
$deleteItem->Id = "AAMkAGJjMzNlMDA4LTU5NzMtNDZmMS1hN2QwLWE5NDJhOTg4ZTE3ZABGAAAAAADor6LtxqzcTZY8k3FzncNoBwBqStc3k+YrRrwI06yPhA+DAAAAAAEPAABqStc3k+YrRrwI06yPhA+DAASvw7+bAAA=";
$deleteItem->ChangeKey = "CQAAABYAAABqStc3k+YrRrwI06yPhA+DAASv1Zxc";
$request = new DeleteItemType();
$request->ItemIds = new ItemIdType();
$request->ItemIds->ItemId[] = $deleteItem;
$client->DeleteItem($request);
You will notice that the output is different, PHP 8.3.9+ missing a significant part of the message and instead inserts a "xmlns:xsi" namespace for whatever reason.
The error comes from the SOAP extension. When you just link PHP 8.3.9 to the .dll file from PHP 8.3.8 it just works also as expected.
This behaviour resulting in SOAP is broken in this specific case starting from PHP 8.3.9 - We saw it on our automated tests after upgrade to PHP 8.3.9 from PHP 8.3.8
PHP Version
PHP 8.3.9 or higher
Operating System
Windows