PHP SOAP Server named arguments

24 views Asked by At

I am using a simple PHP Soap Server in non wsdl mode and passing an object that has one method defined. I want to get all the arguments with their names because most of them are optional. How to correctly get an object or array containing the names of the arguments with their values ​​in non wsdl mode? Restrictions:

  1. You cannot change the incoming message.
  2. There is no WSDL schema and there is no way to get it. But we can create custom wsdl with "any type" attributes if needed.

can not change incoming soap message and haven`t wsdl schema.

Server:

$options = [
  'uri' => $serverUri
];
$server = new \SoapServer(null, $options);
$server->setObject($this->soapService);

SOAP-Message (arg2 and arg3 is optional and have minOccurs = 0):

<soap:Body>
    <Action>
        <arg1>Value 1</arg1>
        <arg3>Value 3</arg3>
    </Action>
</soap:Body>

soapService:

class SoapService
{
    public function Action($arg1, $arg2 = null, $arg3 = null): void
    {
        var_dump($arg1, $arg2, $arg3); // Getting "Value 1, Value 3, null"
    }
}

I want get one object argument contains key => value fields.

{
    arg1: "Value 1",
    arg3: "Value 3"
}
0

There are 0 answers