Given that the following client.php creates this XML request:
<?xml version="1.0" encoding="UTF-8"?> <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/"> <SOAP-ENV:Body> <ns1:Test> <RequestId xsi:type="xsd:int">1</RequestId> <PartnerId xsi:type="xsd:int">99</PartnerId> </ns1:Test> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
How do I access parameter names? (RequestId and PartnerId) inside server.php? Names are clearly present in the payload, but only values ββare accepted on the server side (1 and 99)
Code example:
client.php
<?php $client_params = array( 'location' => 'http://soap.dev/server.php', 'uri' => 'http://soap.dev/', 'trace' => 1 ); $client = new SoapClient(null, $client_params); try { $res = $client->Test( new SoapParam(1, 'RequestId'), new SoapParam(99, 'PartnerId') ); } catch (Exception $Ex) { print $Ex->getMessage(); } var_dump($client->__getLastRequest()); var_dump($client->__getLastResponse());
server.php
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' => 'http://soap.dev/'); $server = new SoapServer(null, $server_options); $server->setClass('receiver'); $server->handle();
Please note that I cannot change the format of the incoming request.
In addition, I know that I could return the names to the parameters by creating a test function with the parameters $RequestId and $PartnerId .
But I really want to get name / value pairs from the incoming request.
So far, the only idea I have is to just parse the XML, and that may not be right.
source share