jeudi 17 septembre 2020

Same key, different data SOAP request in Laravel

I'm using ArtisanWeb SOAPClient Wrapper. In my SAOP API body I have the following:

<roles>
   <role>[string?]</role>
</roles>

I should be able to pass multiple roles to the API with this call. My code looks like this:

            $request = $this->soapWrapper->add('CreateSession', function ($service){
            $service
                ->wsdl('mywsdl')
                ->trace(true)
                ->options([
                  'user_agent' => 'PHPSoapClient',
                ]);
        });

        $params = ["parameters" => 

                    ['user' => [
                                  'firstname' => $request['firstname'],
                                  'lastname' => $request['lastname'],
                                  'email' => $request['email'],
                                  'roles' => [
                                                'role' => 'admin_x',
                                                'role' => 'admin_y'
                                             ]
                                 ]
                   ];

        $response = $this->soapWrapper->call('CreateSession'.importUsers', $params);

Obviously the collection is not allowing me to have two keys called 'role' with different values. Is there a way around this?

The code works for everything else and does create the user. It is only the roles that is causing the problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire