Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) Panama Electronic Invoice Send (SOAP Request)Demonstrate sending an electronic invoice (XML) to http://demoemision.thefactoryhka.com.pa/ws/obj/v1.0/Service.svc
#include <C_CkHttpW.h> #include <C_CkXmlW.h> #include <C_CkHttpResponseW.h> void ChilkatSample(void) { HCkHttpW http; BOOL success; HCkXmlW xml; const wchar_t *strXml; int responseStatusCode; const wchar_t *endPoint; HCkHttpResponseW resp; HCkXmlW xmlResp; http = CkHttpW_Create(); // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // -------------------------------------------------------------------------------- // Also see Chilkat's Online WSDL Code Generator // to generate code and SOAP Request and Response XML for each operation in a WSDL. // -------------------------------------------------------------------------------- // The SOAP XML will look like this: // <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:ser="http://schemas.datacontract.org/2004/07/Services.ObjComprobante.v1_0"> // <soapenv:Header/> // <soapenv:Body> // <tem:Enviar> // <tem:tokenEmpresa>SOLICITAR</tem:tokenEmpresa> // <tem:tokenPassword>SOLICITAR</tem:tokenPassword> // <tem:documento> // <ser:codigoSucursalEmisor>0000</ser:codigoSucursalEmisor> // <ser:tipoSucursal>1</ser:tipoSucursal> // <ser:datosTransaccion> // <ser:tipoEmision>01</ser:tipoEmision> // <ser:tipoDocumento>01</ser:tipoDocumento> // <ser:numeroDocumentoFiscal>176</ser:numeroDocumentoFiscal> // <ser:puntoFacturacionFiscal>505</ser:puntoFacturacionFiscal> // <ser:fechaEmision>2019-05-15T07:49:27-05:00</ser:fechaEmision> // <ser:fechaSalida>2019-05-15T07:49:27-05:00</ser:fechaSalida> // <ser:naturalezaOperacion>01</ser:naturalezaOperacion> // <ser:tipoOperacion>1</ser:tipoOperacion> // <ser:destinoOperacion>1</ser:destinoOperacion> <!--1: Panama 2: Extranjero--> // <ser:formatoCAFE>1</ser:formatoCAFE> // <ser:entregaCAFE>1</ser:entregaCAFE> // <ser:envioContenedor>1</ser:envioContenedor> // <ser:procesoGeneracion>1</ser:procesoGeneracion> // <ser:tipoVenta>1</ser:tipoVenta> // <ser:informacionInteres>Informacion Interes</ser:informacionInteres> // <ser:cliente> // <ser:tipoClienteFE>02</ser:tipoClienteFE> <!--iTipoREC--> // <ser:tipoContribuyente>2</ser:tipoContribuyente> // <ser:numeroRUC>155596713-2-2015</ser:numeroRUC> // <ser:digitoVerificadorRUC>59</ser:digitoVerificadorRUC> // <ser:razonSocial>Ambiente de pruebas</ser:razonSocial> // <ser:direccion>Ave. La Paz</ser:direccion> // <ser:codigoUbicacion>1-1-1</ser:codigoUbicacion> // <ser:provincia>Bocas del Toro</ser:provincia> // <ser:distrito>Bocas del Toro</ser:distrito> // <ser:corregimiento>Bocas del Toro</ser:corregimiento> // <ser:tipoIdentificacion></ser:tipoIdentificacion> // <ser:nroIdentificacionExtranjero></ser:nroIdentificacionExtranjero> // <ser:paisExtranjero></ser:paisExtranjero> // <ser:telefono1>9999-9999</ser:telefono1> // <ser:correoElectronico1>usuario@pruebas.com</ser:correoElectronico1> // <ser:pais>PA</ser:pais> // <ser:paisOtro/> // </ser:cliente> // </ser:datosTransaccion> // <ser:listaItems> // <ser:item> // <ser:descripcion>Lapiz</ser:descripcion> // <ser:codigo>CA-001</ser:codigo> // <ser:unidadMedida>m</ser:unidadMedida> // <ser:cantidad>1.00</ser:cantidad> // <ser:fechaFabricacion>1999-05-10</ser:fechaFabricacion> // <ser:fechaCaducidad>2019-05-10</ser:fechaCaducidad> // <ser:unidadMedidaCPBS></ser:unidadMedidaCPBS> // <ser:infoItem>Lapiz con Goma</ser:infoItem> // <ser:precioUnitario>1234.12</ser:precioUnitario> // <ser:precioUnitarioDescuento></ser:precioUnitarioDescuento> // <ser:precioItem>1234.12</ser:precioItem> // <ser:valorTotal>1335.3384</ser:valorTotal> <!--dvalTotItem--> // <ser:codigoGTIN>0</ser:codigoGTIN> // <ser:cantGTINCom>0.99</ser:cantGTINCom> // <ser:codigoGTINInv>0</ser:codigoGTINInv> // <ser:cantGTINComInv>1.00</ser:cantGTINComInv> // <ser:tasaITBMS>01</ser:tasaITBMS> // <ser:valorITBMS>86.3884</ser:valorITBMS> // <ser:listaItemOTI> // <ser:oti> // <ser:tasaOTI>01</ser:tasaOTI> // <ser:valorTasa>14.81</ser:valorTasa> // </ser:oti> // <ser:oti> // <ser:tasaOTI>02</ser:tasaOTI> // <ser:valorTasa>0.02</ser:valorTasa> // </ser:oti> // </ser:listaItemOTI> // </ser:item> // </ser:listaItems> // <ser:totalesSubTotales> // <ser:totalPrecioNeto>1234.12</ser:totalPrecioNeto> // <ser:totalITBMS>86.39</ser:totalITBMS> // <ser:totalISC>0.00</ser:totalISC> // <ser:totalMontoGravado>101.22</ser:totalMontoGravado> // <ser:totalDescuento>0.00</ser:totalDescuento> // <ser:totalAcarreoCobrado/> // <ser:valorSeguroCobrado/> // <ser:totalFactura>1335.34</ser:totalFactura> // <ser:totalValorRecibido>1335.34</ser:totalValorRecibido> // <ser:tiempoPago>1</ser:tiempoPago> // <ser:nroItems>1</ser:nroItems> // <ser:totalTodosItems>1335.34</ser:totalTodosItems> // <ser:listaFormaPago> // <ser:formaPago> // <ser:formaPagoFact>02</ser:formaPagoFact> // <ser:descFormaPago/> // <ser:valorCuotaPagada>1335.34</ser:valorCuotaPagada> // </ser:formaPago> // </ser:listaFormaPago> // <ser:listaTotalOTI> // <ser:totalOti> // <ser:codigoTotalOTI>01</ser:codigoTotalOTI> // <ser:valorTotalOTI>14.81</ser:valorTotalOTI> // </ser:totalOti> // <ser:totalOti> // <ser:codigoTotalOTI>02</ser:codigoTotalOTI> // <ser:valorTotalOTI>0.02</ser:valorTotalOTI> // </ser:totalOti> // </ser:listaTotalOTI> // </ser:totalesSubTotales> // <ser:usoPosterior> // <ser:cufe></ser:cufe> // </ser:usoPosterior> // </tem:documento> // </tem:Enviar> // </soapenv:Body> // </soapenv:Envelope> // Use this online tool to generate code from sample XML: // Generate Code to Create XML xml = CkXmlW_Create(); CkXmlW_putTag(xml,L"soapenv:Envelope"); CkXmlW_AddAttribute(xml,L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/"); CkXmlW_AddAttribute(xml,L"xmlns:tem",L"http://tempuri.org/"); CkXmlW_AddAttribute(xml,L"xmlns:ser",L"http://schemas.datacontract.org/2004/07/Services.ObjComprobante.v1_0"); CkXmlW_UpdateChildContent(xml,L"soapenv:Header",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:tokenEmpresa",L"SOLICITAR"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:tokenPassword",L"SOLICITAR"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:codigoSucursalEmisor",L"0000"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:tipoSucursal",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoEmision",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoDocumento",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:numeroDocumentoFiscal",L"176"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:puntoFacturacionFiscal",L"505"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:fechaEmision",L"2019-05-15T07:49:27-05:00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:fechaSalida",L"2019-05-15T07:49:27-05:00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:naturalezaOperacion",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoOperacion",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:destinoOperacion",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:formatoCAFE",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:entregaCAFE",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:envioContenedor",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:procesoGeneracion",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoVenta",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:informacionInteres",L"Informacion Interes"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoClienteFE",L"02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoContribuyente",L"2"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:numeroRUC",L"155596713-2-2015"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:digitoVerificadorRUC",L"59"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:razonSocial",L"Ambiente de pruebas"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:direccion",L"Ave. La Paz"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:codigoUbicacion",L"1-1-1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:provincia",L"Bocas del Toro"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:distrito",L"Bocas del Toro"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:corregimiento",L"Bocas del Toro"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoIdentificacion",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:nroIdentificacionExtranjero",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:paisExtranjero",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:telefono1",L"9999-9999"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:correoElectronico1",L"usuario@pruebas.com"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:pais",L"PA"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:paisOtro",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:descripcion",L"Lapiz"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigo",L"CA-001"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:unidadMedida",L"m"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantidad",L"1.00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:fechaFabricacion",L"1999-05-10"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:fechaCaducidad",L"2019-05-10"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:unidadMedidaCPBS",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:infoItem",L"Lapiz con Goma"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioUnitario",L"1234.12"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioUnitarioDescuento",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioItem",L"1234.12"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:valorTotal",L"1335.3384"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigoGTIN",L"0"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantGTINCom",L"0.99"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigoGTINInv",L"0"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantGTINComInv",L"1.00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:tasaITBMS",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:valorITBMS",L"86.3884"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti|ser:tasaOTI",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti|ser:valorTasa",L"14.81"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti[1]|ser:tasaOTI",L"02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti[1]|ser:valorTasa",L"0.02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalPrecioNeto",L"1234.12"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalITBMS",L"86.39"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalISC",L"0.00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalMontoGravado",L"101.22"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalDescuento",L"0.00"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalAcarreoCobrado",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:valorSeguroCobrado",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalFactura",L"1335.34"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalValorRecibido",L"1335.34"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:tiempoPago",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:nroItems",L"1"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalTodosItems",L"1335.34"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:formaPagoFact",L"02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:descFormaPago",L""); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:valorCuotaPagada",L"1335.34"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti|ser:codigoTotalOTI",L"01"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti|ser:valorTotalOTI",L"14.81"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti[1]|ser:codigoTotalOTI",L"02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti[1]|ser:valorTotalOTI",L"0.02"); CkXmlW_UpdateChildContent(xml,L"soapenv:Body|tem:Enviar|tem:documento|ser:usoPosterior|ser:cufe",L""); strXml = CkXmlW_getXml(xml); // We'll need to add this in the HTTP header: // SOAPAction: http://tempuri.org/IService/Enviar CkHttpW_SetRequestHeader(http,L"SOAPAction",L"http://tempuri.org/IService/Enviar"); CkHttpW_SetRequestHeader(http,L"Content-Type",L"text/xml; charset=utf-8"); // The endpoint for this soap service is: endPoint = L"http://demoemision.thefactoryhka.com.pa/ws/obj/v1.0/Service.svc"; resp = CkHttpW_PostXml(http,endPoint,strXml,L"utf-8"); if (CkHttpW_getLastMethodSuccess(http) != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); wprintf(L"LastHeader:\n"); wprintf(L"%s\n",CkHttpW_lastHeader(http)); CkHttpW_Dispose(http); CkXmlW_Dispose(xml); return; } responseStatusCode = CkHttpResponseW_getStatusCode(resp); // You may wish to verify that the responseStatusCode equals 200... wprintf(L"Response Status Code: %d\n",responseStatusCode); // You may examine the exact HTTP header sent with the POST like this: wprintf(L"LastHeader:\n"); wprintf(L"%s\n",CkHttpW_lastHeader(http)); // Examine the XML returned by the web service: wprintf(L"XML Response:\n"); xmlResp = CkXmlW_Create(); CkXmlW_LoadXml(xmlResp,CkHttpResponseW_bodyStr(resp)); wprintf(L"%s\n",CkXmlW_getXml(xmlResp)); // Use this online tool to generate parsing code from response XML: // Generate Parsing Code from XML CkHttpResponseW_Dispose(resp); CkHttpW_Dispose(http); CkXmlW_Dispose(xml); CkXmlW_Dispose(xmlResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.