Is there such a beastie? The simple SOAP client that ships with PHP does not understand multi-part messages. Thanks in advance.
A little bit more simple IMHO
class SoapClientUnwrappedXml extends SoapClient
{
const SOAP_ENVELOPE_REGEXP = '/^]*>(.*)<\/soap:Envelope>/m';
/**
* Sends SOAP request using a predefined XML.
*
* Overwrites the default method SoapClient::__doRequest() to make it work
* with multipart responses or prefixed/suffixed by uuids.
*
* @return string The XML Valid SOAP response.
*/
public function __doRequest($request, $location, $action, $version, $one_way = 0): string
{
$result = parent::__doRequest($request, $location, $action, $version, $one_way);
$headers = $this->__getLastResponseHeaders();
if (preg_match('#^Content-Type:.*multipart\/.*#mi', $headers) !== 0) {
preg_match_all(self::SOAP_ENVELOPE_REGEXP, $result, $resultSanitized, PREG_SET_ORDER, 0);
$result = $resultSanitized[0][0] ?? $result;
}
return $result;
}
}