Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting parameter names from SOAP request with PHP SOAP extension?
    primarykey
    data
    text
    <p>Given that the following client.php creates this request XML:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soap.dev/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt; &lt;SOAP-ENV:Body&gt; &lt;ns1:Test&gt; &lt;RequestId xsi:type="xsd:int"&gt;1&lt;/RequestId&gt; &lt;PartnerId xsi:type="xsd:int"&gt;99&lt;/PartnerId&gt; &lt;/ns1:Test&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>How do I access the names of the parameters? (RequestId and PartnerId) inside a server.php? The names are clearly there in the payload, but on server side only the values are received (1 and 99)</p> <p>Sample code follows:</p> <p>client.php</p> <pre><code>&lt;?php $client_params = array( 'location' =&gt; 'http://soap.dev/server.php', 'uri' =&gt; 'http://soap.dev/', 'trace' =&gt; 1 ); $client = new SoapClient(null, $client_params); try { $res = $client-&gt;Test( new SoapParam(1, 'RequestId'), new SoapParam(99, 'PartnerId') ); } catch (Exception $Ex) { print $Ex-&gt;getMessage(); } var_dump($client-&gt;__getLastRequest()); var_dump($client-&gt;__getLastResponse()); </code></pre> <p>server.php</p> <pre><code>class receiver { public function __call ($name, $params) { $args = func_get_args(); // here $params equals to array(1, 99) // I want the names as well. return var_export($args, 1); } } $server_options = array('uri' =&gt; 'http://soap.dev/'); $server = new SoapServer(null, $server_options); $server-&gt;setClass('receiver'); $server-&gt;handle(); </code></pre> <p>Please note that I can not really change the incoming request format. </p> <p>Also, I am aware that I could give the names back to parameters by creating a Test function with <code>$RequestId</code> and <code>$PartnerId</code> parameters.</p> <p>But what I really want to is to get name/value pairs out of incoming request. </p> <p>So far the only idea I have is to simply parse the XML and this cannot be right.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload