Skip to content

Instantly share code, notes, and snippets.

@cmbuckley
Last active January 11, 2023 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmbuckley/1165020 to your computer and use it in GitHub Desktop.
Save cmbuckley/1165020 to your computer and use it in GitHub Desktop.
<?php
$request = <<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.example.com"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<ns1:add>
<param0 xsi:type="xsd:int">3</param0>
<param1 xsi:type="xsd:int">4</param1>
</ns1:add>
</soap:Body>
</soap:Envelope>
EOS;
function fromXml($xml) {
// works fine if only thrown for second param:
// if ('4' === strip_tags($xml))
throw new SoapFault('Server', 'Conversion Fault');
}
function toXml() {}
function add($x, $y) {}
$server = new SoapServer(null, array(
'uri' => 'http://schemas.example.com',
'typemap' => array(array(
'type_name' => 'int',
'type_ns' => 'http://www.w3.org/2001/XMLSchema',
'from_xml' => 'fromXml',
'to_xml' => 'toXml',
))
));
$server->addFunction('add');
$server->handle($request);
@cmbuckley
Copy link
Author

This was fixed in PHP 8.2.0beta1: https://onlinephp.io/c/52b78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment