PHP
<?php $fname = "/home/Downloads/20110128_171752.xml"; $handle = fopen($fname, "r"); $sData = ''; $usuario = "testing@solucionfactible.com"; $password = "timbrado.SF.16672"; while(!feof($handle)) $sData .= fread($handle, filesize($fname)); fclose($handle); $b64 = base64_encode($sData); $response = ''; /* Porfavor note: Este ejemplo está basado en el WSDL De timbrado cada WSDL tiene su propia estructura y deberá modificarse la petición acorde al webservice que se esté conectando.*/ try { $client = new SoapClient("http://testing.solucionfactible.com/ws/services/Timbrado?wsdl"); $params = array('usuario' => $usuario, 'password' => $password, 'cfdiBase64'=>$b64, 'zip'=>False); $response = $client->__soapCall('timbrarBase64', array('parameters' => $params)); } catch (SoapFault $fault) { echo "SOAPFault: ".$fault->faultcode."-".$fault->faultstring."\n"; } $ret = $response->return; if($ret->status == 200) { print_r($ret->resultados); } ?>
Python
import sys from suds.client import Client url = 'http://testing.solucionfactible.com/ws/services/Timbrado?wsdl' client = Client(url) result = client.service.timbrar("user","pass","cfdi","false") print (result)
Perl
use SOAP::Lite; use MIME::Base64; use POSIX qw(tzset); my $TZ = 'America/Mexico_city'; $user = 'testing@solucionfactible.com'; $password = 'timbrado.SF.16672'; $file = 'ruta_al_cfdi.xml'; $base64 = ""; open(FILE, $file) or die "$!"; while (read(FILE, $buf, 60*57)) { $base64 = $base64.encode_base64($buf); } $proxy = "http://testing.solucionfactible.com/ws/services/Timbrado"; $response = SOAP::Lite->uri('http://timbrado.ws.cfdi.solucionfactible.com')->proxy($proxy)->timbrar($user, $password, $base64, false); $status = $response->result->{'status'}; $mensaje = $response->result->{'mensaje'}; print "Status: $status\n"; print "Mensaje: $mensaje\n\n"; print "Detalle por comprobante\n"; for my $t ($response->valueof('//resultados')) { print "Status $t->{'status'}\nMensaje $t->{'mensaje'}\n"; if(defined($t->{'uuid'})) { $ENV{TZ} = 'GMT'; tzset; $fTimbrado = $t->{'fechaTimbrado'}; print("UUID: $t->{'uuid'}\n"); print("CFDI: ".decode_base64($t->{'cfdiTimbrado'})."\n"); print("Fecha Timbrado: $fTimbrado\n"); print("Cadena original: $t->{'cadenaOriginal'}\n"); print("Certificado: $t->{'certificadoSAT'}\n"); print("Sello: $t->{'selloSAT'}\n"); print("QRCode: $t->{'qrCode'}\n"); } print "\n\n"; } print("\n\n");