Nueva pregunta

Pregunta:

Fecha: 20-09-2018 09:02:12 (En Español)

Problema con XML devuelto por AFIP[No resuelta]

Segun la AFIP la respuesta delmetodo getPersona del padron nivel 5 es un XML por lo que tengo entendido. Pero trabajo con JQUERY y mando una peticion por AJAX a un archivo php que realiza la consulta.

<?php

include_once ($_SERVER['DOCUMENT_ROOT'].'/gestionweb/includes/afip/wsaa-client.php');

define ("URLS", "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA4?WSDL");
$CUIT=$_POST['CUIT'];
$CUITI=(float)$CUIT;

if (isset($_POST['CUIT'])){
    $wsdl_p5="https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA4?WSDL";
    $padron = new SoapClient($wsdl_p5, array(
'soap_version' => SOAP_1_1,
'location' => URLS,
'exceptions' => 0,
'trace' => 1)
);
$TA = simplexml_load_file("C:\\xampp\htdocs\gestionweb\includes\afip\TA.xml");

 
$resultado = $padron->getPersona(
array(
'token' => $TA->credentials->token,
'sign' => $TA->credentials->sign,
'cuitRepresentada' => 20357161178, // es el cuit con el que pedi el certificao
'idPersona' =>$CUITI,
)
);

echo json_encode($resultado);
}

?>

Y esta es la peticion:
$(document).ready(function() {
$("#buscar").click(function(){
   var CUIT=$("#cuit1").val();
alert(CUIT);
   $.ajax({
            type: "POST",
            url: "//localhost/gestionweb/includes/afip/consultaPadron.php",
            data: {"CUIT":CUIT}, 
      
    dataType: "json",
            error: function(){
                alert("error petición ajax");
               
            },
            
            success: function(cli){
            
                               
              }}).fail( function( jqXHR, textStatus, errorThrown ) {

  if (jqXHR.status === 0) {

    alert('Not connect: Verify Network.');

  } else if (jqXHR.status == 404) {

    alert('Requested page not found [404]');
  

  } else if (jqXHR.status == 500) {

    alert('Internal Server Error [500].');

  } else if (textStatus === 'parsererror') {

    alert('Requested JSON parse failed.');

  } else if (textStatus === 'timeout') {

    alert('Time out error.');

  } else if (textStatus === 'abort') {

    alert('Ajax request aborted.');

  } else {

    alert('Uncaught Error: ' + jqXHR.responseText);

  }

});
                                
});
   
}); 


El caso es que quiero recorrer los resultados en JSON para llenar los campos del form. Pero el servicio devuelve un xml. Como resuelvo esto?
O le puedo pasar un xml a JQUERY?

La respuesta obtenida por un var_dump es un arreglo de objetos:
object(stdClass)#7 (1) {
["personaReturn"]=>
object(stdClass)#8 (2) {
["metadata"]=>
object(stdClass)#9 (2) {
["fechaHora"]=>
string(29) "2018-09-20T15:00:55.399-03:00"
["servidor"]=>
string(19) "awshomo.afip.gov.ar"
}
["persona"]=>
object(stdClass)#10 (16) {
["actividad"]=>
object(stdClass)#11 (5) {
["descripcionActividad"]=>
string(27) "CULTIVO DE FRUTAS CÍTRICAS"
["idActividad"]=>
int(12200)
["nomenclador"]=>
int(883)
["orden"]=>
int(1)
["periodo"]=>
int(201311)
}
["apellido"]=>
string(6) "ANSWER"
["categoria"]=>
array(3) {
[0]=>
object(stdClass)#12 (5) {
["descripcionCategoria"]=>
string(16) "AGROP./NO AGROP."
["estado"]=>
string(15) "BAJA DEFINITIVA"
["idCategoria"]=>
int(1)
["idImpuesto"]=>
int(20)
["periodo"]=>
int(200407)
}
[1]=>
object(stdClass)#13 (5) {
["descripcionCategoria"]=>
string(7) "ACTIVO "

y continua..ese es un fragmento..
Gracias de antemano
Etiquetas: Votos: 0 - Respuestas: 1 - Vistas: 5 Compartir en: Google Facebook Twitter LinkedIn Link
 

Respuestas:

  • Fecha: 25-09-2018 04:19:30 ¿Por qué no armás un json a partir del xml? Si igual lo estás haciendo pasar por un php que hace la llamada al WS de AFIP podrías armar un json como necesites y devolvérselo al frontend...   Votos: 0 - Link respuesta
     
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión
 
frjcbbae garagebible.com