这是我第一次在php应用程序中使用带SOAP的Web服务。 其实我做的是这样的:
$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;
}
我的问题是:我如何制作许多 Devis-&gt; Assure ,如此documentation或以下示例?
<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>
<NumeroAssure>#panier#</NumeroAssure>
<Type>Conjoint</Type>
<DateNaissance>#dn2webservice#</DateNaissance>
<RegimeObligatoire>#reg1#</RegimeObligatoire>
</Assure>
</cfif>'
我需要制作一个数组或类似的东西吗?
答案 0 :(得分:0)
我最终在 Assure 节点中创建了一个数组,如下所示:
$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']);
}
它就像一个魅力:)