Constructing and sending a Soap XML Request in PHP -
i use elois web service
webservice interface:
to request pricing (see xml request):
for authentication:
- the broker reference
- the broker code
- the broker password encrypted
- the product code wish pricing
- action (new, update, quote, ...)
for pricing:
- the information of insured
- the product-specific information
- the reference quote if needed
syntax call :
to use web service via soap, parameters use :
url: http://wsdev.elois.fr/elois_call.php soapaction: gettarifs
- example of xml request
:
<auth> <reference_courtier>elois</reference_courtier> <code_courtier>001234567</code_courtier> <mot_de_passe_courtier>5d7a98bddsfg465qdfs0cb1ab4887eae8 </mot_de_passe_courtier> <action>devispdf</action> <code_produit>acceoplus</code_produit> </auth> <datas> <reference_devis>123321</reference_devis> <civilite1>madame</civilite1> <nom1>dupont</nom1> <prenom1>rosie</prenom1> <date_naissance1>1970-02-01</date_naissance1> <adresse1>25, rue buffon</adresse1> <code_postal1>75017</code_postal1> <ville1>paris</ville1> <telephone1>06 06 06 06 06</telephone1> <email1>mail@mail.fr</email1> <perte_emploi1>non</perte_emploi1> <dos_psy1>non</dos_psy1> <chargement1>t30</chargement1> <profession1>assureur</profession1> <caution1>emprunteur</caution1> <franchise1>90</franchise1> <projet>travaux</projet> <pret1montant>100000</pret1montant> <pret1quotite1>100</pret1quotite1> <pret1garantie1>dcptia66</pret1garantie1> <pret1duree>240</pret1duree> <pret1diffamor>0</pret1diffamor> <pret1taux>4</pret1taux> <pret1typetaux>fixe</pret1typetaux> <date_effet>2014-09-25</date_effet> <typepret1>amort</typepret1> </datas>
response returned web service
<devis> <identif> <code_courtier>00123456</code_courtier> <code_produit>acceoplus</code_produit> <reference_devis>1234567</reference_devis> </identif> <error> </error> <tarifs> <pret1> <montant>500000</montant> <quotite>100</quotite> <duree>160</duree> <dcptia>4422.79</dcptia> <ittiptipp>3184.44</ittiptipp> <pe>0</pe> <fraisadhesion>176</fraisadhesion> <mensualite>47.5451875</mensualite> <couttotal>7607.23</couttotal> <tauxannuelmoyen>0.1141</tauxannuelmoyen> </pret1> <pret2> <montant>120000</montant> <quotite>100</quotite> <duree>240</duree> <dcptia>1920</dcptia> <ittiptipp>1280</ittiptipp> <pe>0</pe> <fraisadhesion>176</fraisadhesion> <mensualite>14.295833333333</mensualite> <couttotal>3431</couttotal> <tauxannuelmoyen>0.143</tauxannuelmoyen> </pret2> </tarifs> <pdf> <libelle>devisacceoplus</libelle> <url>http://www.elois.fr/modules/acceoplus/tmpdevis/ws145464549475.pdf </url> </pdf>
i create php script sends soap xml request web service , receive response
i tried script :
<?php error_reporting(e_all); ini_set('display_errors', true); ini_set('display_startup_errors', true); $test = 'xmlns:xsi="http://www.w3.org/2001/xmlschema-instance” xmlns:xsd="http://www.w3.org/2001/xmlschema” xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <auth> <reference_courtier>elois</reference_courtier> <code_courtier>001234567</code_courtier> ... <date_effet>2014-09-25</date_effet> <typepret1>amort</typepret1> </datas> </soap:body> </soap:envelope>'; //change variables. //$location_url = 'http://write_your_location_url.asmx'; //$action_url = 'http://write_your_action_to_perform_url.asmx”'; $location_url = 'http://wsdev.elois.fr/elois_call.php'; $action_url = 'gettarifs'; $client = new soapclient(null, array( 'location' => $location_url, 'uri' => '', 'trace' => 1, )); try{ $order_return = $client->__dorequest($test,$location_url,$action_url,1); //get response here print_r($order_return); }catch (soapfault $exception){ var_dump(get_class($exception)); var_dump($exception); } ?>
the web service returns me error :
soap-env:clientbad request
Comments
Post a Comment