Q:

I want to send a soap request using php with multiple items

i want to send a soap request using php but i found a problem here is what i have to send as XML format.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
  <soap:Header/>
  <soap:Body>
    <tem:getImpayee>
      <tem:tocken>reererer</tem:tocken>
      <tem:CodeCreancier>1013</tem:CodeCreancier>
      <tem:CodeCreance>01</tem:CodeCreance>
      <tem:crVals>
        <tem:CreancierVals>
          <tem:nomChamp>montant</tem:nomChamp>
          <tem:ValeurChamp>45</tem:ValeurChamp>
        </tem:CreancierVals>
        <tem:CreancierVals>
          <tem:nomChamp>ND</tem:nomChamp>
          <tem:ValeurChamp>0663143327</tem:ValeurChamp>
        </tem:CreancierVals>
      </tem:crVals>
    </tem:getImpayee>
  </soap:Body>
</soap:Envelope>

but the problem is that there is multiple "tem:CreancierVals" when i use this
$client->__setLocation(url_PaiementWS);
$result = $client->getImpayee(
    array(
        'tocken' => $_SESSION['tocken'],
        'CodeCreancier' => $CodeCreancier,
        'CodeCreance' => $CodeCreance,
        'crVals' => array (
            'CreancierVals' => array(
                'nomChamp' => 'montant',
                'ValeurChamp' => $montant
            ),
            'CreancierVals' => array(
                'nomChamp' => 'ND',
                'ValeurChamp' => $ND
            )
        )
    )
);

it doesnt work
its like reseting the "CreancierVals" val
is there a solution in which i can send pure xml using php ? or just a dynamic method that doesn't reseting the "CreancierVals" val but add one to the other as an array for example. thanks

A:

Try this:
$result = $client->getImpayee(
    [
        'tocken'        => $_SESSION['tocken'],
        'CodeCreancier' => $CodeCreancier,
        'CodeCreance'   => $CodeCreance,
        'crVals'        => [
            'CreancierVals' => [
                [
                    'nomChamp'    => 'montant',
                    'ValeurChamp' => $montant,
                ],
                [
                    'nomChamp'    => 'ND',
                    'ValeurChamp' => $ND,
                ],
            ],
        ],
    ]
);

