Integrating services using DLL
The DLL libraries developed by Solución Factible® are ActiveXControl COM elements, they can be used by any language that supports DLL import, such as: Vsual Basic 6(VB6), Microsoft Visual C++ (MSVC), Clarion, Visual Fox Pro, lenguajes .NET como C# VB .NET, ASP etc.
Installation
Depending on the programming language being used, this is the way in which a DLL will be imported into the project to be used. Sometimes the DLL has to be registered in the operating system, or you can use the .dll file directly, by calling it in its path.
One of the most common ways to install DLLs is to run the command: regsvr32 to register the DLL in the system:
C:\Users\SF\> regsvr32 SF_ActiveXCtrlCFDI_1.2.2.dll
Solución Factible® also provides an installer, extracts and runs the command to register the dll in the system, in case you need the .dll file just go to "C:\SFDLL\" and you will find it here.
Steps:
- 1.- Install the dll by running "SF DLL Installer.exe"
- 2.- Wait for the registration confirmation message, then click "OK" and then continue.
Implementation in Visual Studio 2010
After running the dll installer or registering it manually with the regsvr32 command, the following steps are:
- 1.- Go to project menu and select "Add reference".
- 2.- Select the COM tab and search for the dll library with the prefix: "SF" and the name, such as: "Timbrar", for example to add the stamping dll we would search for:SFTimbrar.
- 3.- Select and click "OK".
The reference is now part of your project, and can be seen in your solution explorer under "References", with a name like: SF_ConectorWS_TypeLib (the name varies depending on the DLL that has been imported) this name is the one we are going to use to instantiate the object and use the methods.
//Instanciando usando Framework 3.5 SF_ConectorWS_TypeLib.TimbrarClass timbrado35 = new SF_ConectorWS_TypeLib.TimbrarClass(); //Instanciando usando Framework 4.0 SF_ConectorWS_TypeLib.Timbrar timbrado40 = new SF_ConectorWS_TypeLib.Timbrar(); //Timbrado: string responseXML = timbrado.timbrarCFDI("testing@solucionfactible.com", "timbrado.SF.16672", @"C:\F2011-06-09.xml", 0); //Fin del programa
'Ejemplo Visual Basic 2008 Dim timbrado As New SF_ConectorWS_TypeLib.Timbrar Dim xmlResponse As String xmlResponse = timbrado.cancelar( "testing@solucionfactible.com", "timbrado.SF.16672", "C:\iap031014rj2.cer", "C:\iap031014rj2_17s.key", "12345678a", "26D51262-F8A6-40C4-9181-D9965BD37F25", 0) 'Fin del programa
program TimbrarSF; {$APPTYPE CONSOLE} uses SysUtils, SF_ConectorWS_TypeLib_TLB, ActiveX; var timbrar: TTimbrar; //clase que registramos y nombre que le dimos al importar la DLL usuario, password, cfdiPath, wsResponse: WideString; produccion: Integer; begin CoInitialize(nil); timbrar := TTimbrar.Create(nil); usuario := 'testing@solucionfactible.com'; password := 'timbrado.SF.16672'; cfdiPath := 'C:\test.xml'; produccion := 0; Writeln('Enviando a timbrar ' + cfdiPath); wsResponse := timbrar.timbrarCFDI(usuario, password, cfdiPath, produccion); Writeln('Response: '); Writeln(wsResponse); Readln(usuario); {Esperar un enter} end.
'TIMBRAR TEST Dim timbrado 'El string "SF.timbrar" es el ProgID (o nombre de la clase como se registró) 'de la dll de timbrado, cada DLL tiene uno diferente que se puede consultar en su API Set timbrado = CreateObject("SF.timbrar") Text1.Text = timbrado.timbrarCFDI("testing@solucionfactible.com", "timbrado.SF.16672", "C:/F_A00001099.xml", 0) 'Fin del programa
OLEObject axTimbrado; axTimbrado = CREATE OLEObject #El string "SF.timbrar" es el ProgID (o nombre de la clase como se registró) #de la dll de timbrado, cada DLL tiene uno diferente que se puede consultar en su API integer result result = axTimbrado.ConnectToNewObject("SF.timbrar"); IF result = 0 THEN MessageBox("SUCCESS Conexion con DLL", result, & Exclamation!, OK!, 2) string respuesta respuesta = axTimbrado.timbrarCFDI("testing@solucionfactible.com", "timbrado.SF.16672", "C:\SFDLL\xml.xml", 0) MessageBox("RESPUESTA DLL", respuesta, & Exclamation!, OK!, 2) ELSE MessageBox("FALLO Conexion con DLL", result, & Exclamation!, OK!, 2) END IF
