mercredi 22 avril 2015

php - do something on soap empty response or not found

I need to do some search on a WS, i have it working, but i need to be able to know when the soap can not find anything with the word im looking.

For example, when i search for KE-5977 i get a response and all the data

<GetChoferesResult xmlns:a="http://ift.tt/1HlBC3f" xmlns:i="http://ift.tt/ra1lAU">
        <a:Choferes>
           <a:ChoferesDTO>
              <a:dc_patente>KE-5977</a:dc_patente>
              <a:dc_patente_habitual>KE-5977</a:dc_patente_habitual>
              <a:dc_rut_chofer>10165014-6</a:dc_rut_chofer>
              <a:dc_tipo_equipo>4</a:dc_tipo_equipo>
              <a:dc_tipo_transportista>E</a:dc_tipo_transportista>
              <a:dg_nombre_chofer>JUAN SOTO</a:dg_nombre_chofer>
              <a:dg_tipo_de_equipo>Camión</a:dg_tipo_de_equipo>
              <a:dg_tipo_transportista>Externo (Se llama a transporte ocasionalmente)</a:dg_tipo_transportista>
              <a:dn_ano_fabricacion>1988</a:dn_ano_fabricacion>
              <a:dq_capacidad_equipo>30.0000</a:dq_capacidad_equipo>
           </a:ChoferesDTO>
        </a:Choferes>
     </GetChoferesResult>

but if i put it wrong like this "KE-7759" i get nothing.

     <GetChoferesResult xmlns:a="http://ift.tt/1HlBC3f" xmlns:i="http://ift.tt/ra1lAU">
        <a:Choferes/>
     </GetChoferesResult>
  </GetChoferesResponse>

i need to show a message "code not found" when i get an empty response from soap (soap request did not found anything with that code).

Please help me

Aucun commentaire:

Enregistrer un commentaire