Ricorocks-Digital-Agency / Soap

A Laravel SOAP client that provides a clean interface for handling requests and responses.
MIT License
405 stars 34 forks source link

Issue with parameters structure #57

Open scramatte opened 1 year ago

scramatte commented 1 year ago

Hello,

I need to pass following structure to the SOAP Client:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <get_voip_account_subscriber xmlns="/SOAP/Provisioning">
         <authentication>
            <type xsi:type="xsd:string">admin</type>
            <username xsi:type="xsd:string">administrator</username>
            <password xsi:type="xsd:string">administrator</password>
         </authentication>
         <parameters>
            <id xsi:type="xsd:int">6</id>
            <username xsi:type="xsd:string">nobody</username>
            <domain xsi:type="xsd:string">example.com</domain>
         </parameters>
      </get_voip_account_subscriber>
   </soap:Body>
</soap:Envelope>

I've tried with the following array as parameters. But it doesn't works.

$params = [
  'authentication' => [
      'type' => 'admin',
      'username' => 'administrator',
     'password' => 'administrator',
  ],
  'parameters' => [
       'id' => 6,
       'username' => 'nobody',
       'domain' => 'example.com'
  ]
]

Anybody can give me an hand with this?

Regards

krizzdev commented 1 year ago

How do you call the method?

I had a similar problem when I used the magic method __call() via:

$client->myMethodName($params)

because when you check the SoapClientRequest.php and check the defined __call() method you will see that it uses only the first part of the $params. ($parameters[0])

public function __call($name, $parameters)
    {
        return $this->call($name, $parameters[0] ?? []);
    }

So directly use the call() method, maybe it will work, because it doesn't take only the first part of $parameters.

$client->call('myMethodName', $params)

If you are already using the call() method, ignore this comment :D

utsavsomaiya commented 6 months ago

@lukeraymonddowning How can i pass multiple parameter to body?

https://help.usaepay.info/api/soap/#token-methods

utsavsomaiya commented 6 months ago

https://help.usaepay.info/api/soap/#searchtransactionscustom

lukeraymonddowning commented 6 months ago

@nedwors are you able to chime in on this?

krizzdev commented 6 months ago

maybe my suggested changes here are helping: https://github.com/Ricorocks-Digital-Agency/Soap/issues/61