开发者

Php soap client multiple node

It's the first time I use a web service with SOAP in a php application. Actually I do something like this :

$urlxml = "https://rec.wspar51.april.fr/WSSante/WSSante.asmx?wsdl";
$client = new SoapClient($urlxml);

$parameters = new stdClass();
$parameters->astr_Clef = "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}";

$parameters->TarifParams = new stdClass();
$parameters->TarifParams->IdCo = "00000";

$parameters->TarifParams->Devis = new stdClass();
$parameters->TarifParams->Devis->Assure = new stdClass();
$parameters->TarifParams->Devis->Assure->Nom = "toto";
$parameters->TarifParams->Devis->Assure->Prenom  = "titi";
$parameters->TarifParams->Devis->Assure->NumeroAssure  = 1;
$parameters->TarifParams->Devis->Assure->Type  = "Adherent";
$parameters->TarifParams->Devis->Assure->DateNaissance  = "19800615";
$parameters->TarifParams->Devis->Assure->RegimeObligatoire  = "SS";

$parameters->TarifParams->Devis->Parametres = new stdClass();
$parameters->TarifParams->Devis->Parametres->DateEffet ="20110809";
$parameters->TarifParams->Devis->Parametres->CodePostal ="27140";
$parameters->TarifParams->Devis->Parametres->BesoinHospitalisation ="Minimum";
$parameters->TarifParams->Devis->Parametres->BesoinFraisMedicaux ="Complete";
$parameters->TarifParams->Devis->Parametres->BesoinDentaire ="Complete";
$parameters->TarifParams->Devis->Parametres->BesoinOptique ="Maximum";
$parameters->TarifParams->Devis->Parametres->Produit ="";       
$parameters->TarifParams->Devis->Parametres->DeuxEurosMalins = False;

try{             
  echo "<pre>";
  print_r($parameters);
  echo "</pre>";
  $response = $client->Tarif($parameters);
  echo "<pre>";
  print_r($response);
  echo "</pre>";
}             
catch(Exception $e){             
  echo '<br /><hr />';
  echo "<b>Exception est :</b> " . $e;
}             

My question is : How can i make Many Devis->Assure as in this documentation or as is the example below ?

<Assure>
    <Nom>#nom1#</Nom>
    <Prenom>#prenom1#</Prenom>
    <NumeroAssure>#panier#</NumeroAssure>
    <Type>Adherent</Type>
    <DateNaissance>#dn1webservice#</DateNaissance>
    <RegimeObligatoire>#reg1#</RegimeObligatoire>
</Assure>
<cfif len(trim(civ2)) gt 0>
    <Assure>
        <Nom>#nom2#</Nom>
        <Prenom>#prenom2#</Prenom>
        <Nu开发者_JAVA技巧meroAssure>#panier#</NumeroAssure>
        <Type>Conjoint</Type>
        <DateNaissance>#dn2webservice#</DateNaissance>
        <RegimeObligatoire>#reg1#</RegimeObligatoire>
    </Assure>
</cfif>'  

I need to make an array or something like this ?


I finally make an array in Assure node such like this :

$this->params_service->TarifParams->Devis->Assure[0] = new stdClass();
$this->params_service->TarifParams->Devis->Assure[0]->Nom = $customerObject->lastname;
$this->params_service->TarifParams->Devis->Assure[0]->Prenom  = $customerObject->firstname;
$this->params_service->TarifParams->Devis->Assure[0]->NumeroAssure  = $customerObject->id;
$this->params_service->TarifParams->Devis->Assure[0]->Type  = "Adherent";
$this->params_service->TarifParams->Devis->Assure[0]->DateNaissance  = $this->formatDate($customerObject->birthday);            // Date format : YYYYMMDD
$this->params_service->TarifParams->Devis->Assure[0]->RegimeObligatoire  = $this->formatRegime($customerObject->regime_id);
// Get the customer family
$family = Family::getCompleteFamily($customerObject->id);
$i = 0;
if($family){
    foreach ($family as $member) {
        $i++;
    $this->params_service->TarifParams->Devis->Assure[$i] = new stdClass();
    $this->params_service->TarifParams->Devis->Assure[$i]->NumeroAssure  = $member['id'];
        $this->params_service->TarifParams->Devis->Assure[$i]->Type  = $this->formatType($member['type']);
    $this->params_service->TarifParams->Devis->Assure[$i]->DateNaissance  = $this->formatDate($member['birthday']);
    $this->params_service->TarifParams->Devis->Assure[$i]->RegimeObligatoire  = $this->formatRegime($member['regime_id']);      
    }

And it work like a charm :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜