It happens that I always make AJAX requests and by php I return a JSON. I am working with the taxpayer registry of AFIP and since it is a SOAP service I should return an XML. Here is the documentation: link The getPersona method is the method in question.
Then I have this code:
<?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,
)
);
var_dump($resultado);
// $xml=new SimpleXMLElement($resultado);
// var_dump($xml);
}
?>
And the result var dump returns an array of std class objects, and I do not know what to do: object (stdClass) # 7 (1) { ["personReturn"] = > object (stdClass) # 8 (2) { ["metadata"] = > object (stdClass) # 9 (2) { ["dateTime"] = > string (29) "2018-09-20T15: 48: 20.183-03: 00" ["server"] = > string (19) "awshomo.afip.gov.ar" }
It starts like this and remains the same. I mean the data I bring from the webservice that works. But I want to read that arrangement, how do I do it?
$("#buscar").click(function(){
var CUIT=$("#cuit1").val();
$.ajax({
type: "POST",
url: "//localhost/gestionweb/includes/afip/consultaPadron.php",
data: {"CUIT":CUIT},
dataType: "xml",
error: function(){
alert("error petición ajax");
},
success: function(cli){
}
Try it like this but it gives an error, it does not enter a success error in the request.