PowerBuilder
PowerBuilder
Panama Electronic Invoice Send (SOAP Request)
See more HTTP Misc Examples
Demonstrate sending an electronic invoice (XML) to http://demoemision.thefactoryhka.com.pa/ws/obj/v1.0/Service.svcChilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_Xml
string ls_StrXml
integer li_ResponseStatusCode
string ls_EndPoint
oleobject loo_Resp
oleobject loo_XmlResp
li_Success = 0
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// 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
loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")
loo_Xml.Tag = "soapenv:Envelope"
loo_Xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
loo_Xml.AddAttribute("xmlns:tem","http://tempuri.org/")
loo_Xml.AddAttribute("xmlns:ser","http://schemas.datacontract.org/2004/07/Services.ObjComprobante.v1_0")
loo_Xml.UpdateChildContent("soapenv:Header","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:tokenEmpresa","SOLICITAR")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:tokenPassword","SOLICITAR")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:codigoSucursalEmisor","0000")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:tipoSucursal","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoEmision","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoDocumento","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:numeroDocumentoFiscal","176")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:puntoFacturacionFiscal","505")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:fechaEmision","2019-05-15T07:49:27-05:00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:fechaSalida","2019-05-15T07:49:27-05:00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:naturalezaOperacion","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoOperacion","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:destinoOperacion","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:formatoCAFE","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:entregaCAFE","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:envioContenedor","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:procesoGeneracion","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:tipoVenta","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:informacionInteres","Informacion Interes")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoClienteFE","02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoContribuyente","2")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:numeroRUC","155596713-2-2015")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:digitoVerificadorRUC","59")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:razonSocial","Ambiente de pruebas")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:direccion","Ave. La Paz")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:codigoUbicacion","1-1-1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:provincia","Bocas del Toro")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:distrito","Bocas del Toro")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:corregimiento","Bocas del Toro")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:tipoIdentificacion","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:nroIdentificacionExtranjero","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:paisExtranjero","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:telefono1","9999-9999")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:correoElectronico1","usuario@pruebas.com")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:pais","PA")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:datosTransaccion|ser:cliente|ser:paisOtro","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:descripcion","Lapiz")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigo","CA-001")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:unidadMedida","m")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantidad","1.00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:fechaFabricacion","1999-05-10")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:fechaCaducidad","2019-05-10")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:unidadMedidaCPBS","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:infoItem","Lapiz con Goma")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioUnitario","1234.12")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioUnitarioDescuento","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:precioItem","1234.12")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:valorTotal","1335.3384")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigoGTIN","0")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantGTINCom","0.99")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:codigoGTINInv","0")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:cantGTINComInv","1.00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:tasaITBMS","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:valorITBMS","86.3884")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti|ser:tasaOTI","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti|ser:valorTasa","14.81")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti[1]|ser:tasaOTI","02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:listaItems|ser:item|ser:listaItemOTI|ser:oti[1]|ser:valorTasa","0.02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalPrecioNeto","1234.12")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalITBMS","86.39")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalISC","0.00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalMontoGravado","101.22")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalDescuento","0.00")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalAcarreoCobrado","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:valorSeguroCobrado","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalFactura","1335.34")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalValorRecibido","1335.34")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:tiempoPago","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:nroItems","1")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:totalTodosItems","1335.34")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:formaPagoFact","02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:descFormaPago","")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaFormaPago|ser:formaPago|ser:valorCuotaPagada","1335.34")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti|ser:codigoTotalOTI","01")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti|ser:valorTotalOTI","14.81")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti[1]|ser:codigoTotalOTI","02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:totalesSubTotales|ser:listaTotalOTI|ser:totalOti[1]|ser:valorTotalOTI","0.02")
loo_Xml.UpdateChildContent("soapenv:Body|tem:Enviar|tem:documento|ser:usoPosterior|ser:cufe","")
ls_StrXml = loo_Xml.GetXml()
// We'll need to add this in the HTTP header:
// SOAPAction: http://tempuri.org/IService/Enviar
loo_Http.SetRequestHeader("SOAPAction","http://tempuri.org/IService/Enviar")
// The endpoint for this soap service is:
ls_EndPoint = "http://demoemision.thefactoryhka.com.pa/ws/obj/v1.0/Service.svc"
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpStr("POST",ls_EndPoint,ls_StrXml,"utf-8","text/xml",loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Xml
destroy loo_Resp
return
end if
li_ResponseStatusCode = loo_Resp.StatusCode
// You may wish to verify that the responseStatusCode equals 200...
Write-Debug "Response Status Code: " + string(li_ResponseStatusCode)
// You may examine the exact HTTP header sent with the POST like this:
Write-Debug "LastHeader:"
Write-Debug loo_Http.LastHeader
// Examine the XML returned by the web service:
Write-Debug "XML Response:"
loo_XmlResp = create oleobject
li_rc = loo_XmlResp.ConnectToNewObject("Chilkat.Xml")
loo_XmlResp.LoadXml(loo_Resp.BodyStr)
Write-Debug loo_XmlResp.GetXml()
// Use this online tool to generate parsing code from response XML:
// Generate Parsing Code from XML
destroy loo_Http
destroy loo_Xml
destroy loo_Resp
destroy loo_XmlResp