Problem with SOAP, php facto.cl

0

I am trying to make electronic tickets via the api de facto.cl that is made in SOAP XML ... I think I have reached the closest point to a solution, but I still can not make it work and I do not know what I'm wrong, if anyone could give me some light on it I appreciate it.

enters the try and does not throw me out in catch so I guess the code is fairly good but does not give me an answer.

public function generaBoleta($id = null){
    $user = '1.111.111-4/pruebasapi';
    $pass = '90809d7721fe3cdcf1668ccf33fea982';        

    //$soapURL = "https://conexion.facto.cl/documento.php?wsdl";

    $wsdl = 'https://conexion.facto.cl/documento.php?wsdl'; // @see http://developer.yousign.fr/

    $client = new SoapClient(null, array('location'=>$wsdl, 'uri' =>$wsdl));

    $ns = 'http://schemas.xmlsoap.org/wsdl/'; //Namespace of the WS. 

    //Body of the Soap Header. 
    $headerbody = array('user' => $user, 
                        'pass' => $pass, 
                        ); 

    //Create Soap Header.        
    $header = new SOAPHeader($ns, 'Auth', $headerbody);        

    //set the Headers of Soap Client. 
    $client->__setSoapHeaders($header); 

    var_dump($client);
    var_dump($client->__getLastResponseHeaders());


        $xml_dte = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:server">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:emitirDocumento soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <documento xsi:type="urn:emitir_dte">
            <encabezado xsi:type="urn:encabezado">
               <tipo_dte xsi:type="xsd:string">33</tipo_dte>
               <fecha_emision xsi:type="xsd:date">2016-10-25</fecha_emision>
               <receptor_rut xsi:type="xsd:string">12345678-5</receptor_rut>
               <receptor_razon xsi:type="xsd:string">Prueba</receptor_razon>
               <receptor_direccion xsi:type="xsd:string">Alameda 123</receptor_direccion>
               <receptor_comuna xsi:type="xsd:string">Santiago</receptor_comuna>
               <receptor_ciudad xsi:type="xsd:string">Santiago</receptor_ciudad>
               <receptor_telefono xsi:type="xsd:string">1234</receptor_telefono>
               <receptor_giro xsi:type="xsd:string">Servicios</receptor_giro>
               <condiciones_pago xsi:type="xsd:string">0</condiciones_pago>
               <receptor_email xsi:type="xsd:string">[email protected]</receptor_email>
               <identificador_externo_doc>1234</identificador_externo_doc>
            </encabezado>
            <detalles xsi:type="urn:detalles">
               <detalle xsi:type="urn:detalle">
                  <cantidad xsi:type="xsd:int">1</cantidad>
                  <unidad xsi:type="xsd:decimal">UN</unidad>
                  <glosa xsi:type="xsd:string">Prueba</glosa>
                  <monto_unitario xsi:type="xsd:decimal">1000</monto_unitario>
                  <exento_afecto xsi:type="xsd:boolean">1</exento_afecto>
    <impuesto_codigo xsi:type="xsd:int">8</impuesto_codigo>
    <impuesto_valorunitario xsi:type="xsd:decimal">300</impuesto_valorunitario>
               </detalle>
            </detalles>
            <totales xsi:type="urn:totales">
               <total_exento xsi:type="xsd:int">0</total_exento>
               <total_afecto xsi:type="xsd:int">1000</total_afecto>
               <total_iva xsi:type="xsd:int">190</total_iva>
    <total_otrosimpuestos xsi:type=”xsd:int”>300</total_otrosimpuestos>
               <total_final xsi:type="xsd:int">1490</total_final>
            </totales>
         </documento>
      </urn:emitirDocumento>
   </soapenv:Body>
</soapenv:Envelope>
';
        $parametros = array("STRINGXML" => $xml_dte, 'user'=>'1.111.111-4/pruebasapi', 'pass'=>'90809d7721fe3cdcf1668ccf33fea982');

    try{ 
  //iniciar cliente soap     
  $resultado = $client->__doRequest($xml_dte, $wsdl, 'emitir_dte', '1.1', $one_way = 0);
   var_dump($resultado);

  //Si hay algún problema intermedio será atrapado aquí. 
  }catch (SoapFault $e){ 
      echo "Ups!! hubo un problema y no pudimos recuperar los datos.<br/>$e<hr/>"; 
      echo "<pre>";
      print_r($client);
  }    

}
    
asked by Octavio Santelices 14.03.2018 в 17:16
source

0 answers