Use ChilkatAx-win32.pkg
Procedure TestHandle hoXml
Boolean iSuccess
String sSoapRequestBody
String sEndpoint
String sSoapAction
String sContentType
Handle hoHttp
Variant vResp
Handle hoResp
Variant vResponseXml
Handle hoResponseXml
Integer iStatusCode
String sCSV
String sNIFPresentador
String sTimestampPresentacion
String sCabecera
String sTiempoEsperaEnvio
String sEstadoEnvio
String sIDEmisorFactura
String sNumSerieFactura
String sFechaExpedicionFactura
String sEstadoRegistro
String sCodigoErrorRegistro
String sDescripcionErrorRegistro
String sCSVRegistroDuplicado
String sEstadoRegistroDuplicado
String sTemp1
Boolean bTemp1
Get Create (RefClass(cComChilkatXml)) To hoXml
If (Not(IsComObjectCreated(hoXml))) BeginSend CreateComObject of hoXml
EndSetComTagOf hoXml To"soapenv:Envelope"GetComAddAttributeOf hoXml "xmlns:soapenv""http://schemas.xmlsoap.org/soap/envelope/"To iSuccess
GetComAddAttributeOf hoXml "xmlns:ds""http://www.w3.org/2000/09/xmldsig#"To iSuccess
GetComAddAttributeOf hoXml "xmlns:sfLR""https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd"To iSuccess
GetComAddAttributeOf hoXml "xmlns:sf""https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd"To iSuccess
SendComUpdateChildContentTo hoXml "soapenv:Header"""SendComUpdateChildContentTo hoXml "soapenv:Body|sfLR:RegFactuSistemaFacturacion""?<sfLR:RegistroFactura><sfLR:RegistroAlta><sf:IDVersion>1.0</sf:IDVersion><sf:IDFactura><sf:IDEmisorFactura>string</sf:IDEmisorFactura><sf:NumSerieFactura>string</sf:NumSerieFactura><sf:FechaExpedicionFactura>string</sf:FechaExpedicionFactura></sf:IDFactura><sf:RefExterna>string</sf:RefExterna><sf:NombreRazonEmisor>string</sf:NombreRazonEmisor><sf:Subsanacion>S</sf:Subsanacion><sf:RechazoPrevio>N</sf:RechazoPrevio><sf:TipoFactura>F1</sf:TipoFactura><sf:TipoRectificativa>S</sf:TipoRectificativa><sf:FacturasRectificadas><sf:IDFacturaRectificada><sf:IDEmisorFactura>string</sf:IDEmisorFactura><sf:NumSerieFactura>string</sf:NumSerieFactura><sf:FechaExpedicionFactura>string</sf:FechaExpedicionFactura></sf:IDFacturaRectificada></sf:FacturasRectificadas><sf:FacturasSustituidas><sf:IDFacturaSustituida><sf:IDEmisorFactura>string</sf:IDEmisorFactura><sf:NumSerieFactura>string</sf:NumSerieFactura><sf:FechaExpedicionFactura>string</sf:FechaExpedicionFactura></sf:IDFacturaSustituida></sf:FacturasSustituidas><sf:ImporteRectificacion><sf:BaseRectificada>string</sf:BaseRectificada><sf:CuotaRectificada>string</sf:CuotaRectificada><sf:CuotaRecargoRectificado>string</sf:CuotaRecargoRectificado></sf:ImporteRectificacion><sf:FechaOperacion>string</sf:FechaOperacion><sf:DescripcionOperacion>string</sf:DescripcionOperacion><sf:FacturaSimplificadaArt7273>S</sf:FacturaSimplificadaArt7273><sf:FacturaSinIdentifDestinatarioArt61d>S</sf:FacturaSinIdentifDestinatarioArt61d><sf:Macrodato>S</sf:Macrodato><sf:EmitidaPorTerceroODestinatario>D</sf:EmitidaPorTerceroODestinatario><sf:Tercero><sf:NombreRazon>string</sf:NombreRazon><sf:NIF>string</sf:NIF></sf:Tercero><sf:Destinatarios><sf:IDDestinatario><sf:NombreRazon>string</sf:NombreRazon><sf:NIF>string</sf:NIF></sf:IDDestinatario></sf:Destinatarios><sf:Cupon>S</sf:Cupon><sf:Desglose><sf:DetalleDesglose><sf:Impuesto>01</sf:Impuesto><sf:ClaveRegimen>01</sf:ClaveRegimen><sf:CalificacionOperacion>S1</sf:CalificacionOperacion><sf:TipoImpositivo>string</sf:TipoImpositivo><sf:BaseImponibleOimporteNoSujeto>string</sf:BaseImponibleOimporteNoSujeto><sf:BaseImponibleACoste>string</sf:BaseImponibleACoste><sf:CuotaRepercutida>string</sf:CuotaRepercutida><sf:TipoRecargoEquivalencia>string</sf:TipoRecargoEquivalencia><sf:CuotaRecargoEquivalencia>string</sf:CuotaRecargoEquivalencia></sf:DetalleDesglose></sf:Desglose><sf:CuotaTotal>string</sf:CuotaTotal><sf:ImporteTotal>string</sf:ImporteTotal><sf:Encadenamiento></sf:Encadenamiento><sf:SistemaInformatico><sf:NombreRazon>string</sf:NombreRazon><sf:NIF>string</sf:NIF><sf:NombreSistemaInformatico>string</sf:NombreSistemaInformatico><sf:IdSistemaInformatico>string</sf:IdSistemaInformatico><sf:Version>string</sf:Version><sf:NumeroInstalacion>string</sf:NumeroInstalacion><sf:TipoUsoPosibleSoloVerifactu>S</sf:TipoUsoPosibleSoloVerifactu><sf:TipoUsoPosibleMultiOT>S</sf:TipoUsoPosibleMultiOT><sf:IndicadorMultiplesOT>S</sf:IndicadorMultiplesOT></sf:SistemaInformatico><sf:FechaHoraHusoGenRegistro>dateTime</sf:FechaHoraHusoGenRegistro><sf:NumRegistroAcuerdoFacturacion>string</sf:NumRegistroAcuerdoFacturacion><sf:IdAcuerdoSistemaInformatico>string</sf:IdAcuerdoSistemaInformatico><sf:TipoHuella>01</sf:TipoHuella><sf:Huella>string</sf:Huella><ds:Signature Id="?"><ds:SignedInfo Id="?"><ds:CanonicalizationMethod Algorithm="?"></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="?"><ds:HMACOutputLength>integer</ds:HMACOutputLength></ds:SignatureMethod><ds:Reference Id="?" URI="?" Type="?"><ds:Transforms><ds:Transform Algorithm="?"></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="?"></ds:DigestMethod><ds:DigestValue>BASE64_DATA</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>...</ds:SignatureValue><ds:KeyInfo Id="?"></ds:KeyInfo><ds:Object Id="?" MimeType="?" Encoding="?"></ds:Object></ds:Signature></sfLR:RegistroAlta></sfLR:RegistroFactura>"// In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required. SetComEmitXmlDeclOf hoXml ToFalseGetComGetXmlOf hoXml To sSoapRequestBody
Move"https:///www1.agenciatributaria.gob.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/RequerimientoSOAP"To sEndpoint
Move""To sSoapAction
// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"Move"text/xml"To sContentType
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) BeginSend CreateComObject of hoHttp
EndSendComClearHeadersTo hoHttp
SendComSetRequestHeaderTo hoHttp "Content-Type" sContentType
SendComSetRequestHeaderTo hoHttp "SOAPAction" sSoapAction
GetComPostXmlOf hoHttp sEndpoint sSoapRequestBody "utf-8"To vResp
If (IsComObject(vResp)) BeginGet Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
EndGetComLastMethodSuccessOf hoHttp To bTemp1
If (bTemp1 = False) BeginGetComLastErrorTextOf hoHttp To sTemp1
Showln sTemp1
Showln"Failed to send SOAP request."Procedure_ReturnEnd// Get the XML response body.Get Create (RefClass(cComChilkatXml)) To hoResponseXml
If (Not(IsComObjectCreated(hoResponseXml))) BeginSend CreateComObject of hoResponseXml
End
Get pvComObject of hoResponseXml to vResponseXml
GetComGetBodyXmlOf hoResp vResponseXml To iSuccess
GetComStatusCodeOf hoResp To iStatusCode
Showln"response status code: " iStatusCode
Send Destroy of hoResp
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.If (iStatusCode <> 200) BeginGetComGetXmlOf hoResponseXml To sTemp1
Showln sTemp1
Procedure_ReturnEndGetComGetXmlOf hoResponseXml To sTemp1
Showln sTemp1
// Parse the successful SOAP response XML.// This is a sample of the response XML, but the namespace prefixes will be different.
// We can parse the result using "*" for the namespace prefixes (see below).GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:CSV"To sCSV
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:DatosPresentacion|*:NIFPresentador"To sNIFPresentador
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:DatosPresentacion|*:TimestampPresentacion"To sTimestampPresentacion
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:Cabecera"To sCabecera
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:TiempoEsperaEnvio"To sTiempoEsperaEnvio
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:EstadoEnvio"To sEstadoEnvio
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:IDFactura|*:IDEmisorFactura"To sIDEmisorFactura
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:IDFactura|*:NumSerieFactura"To sNumSerieFactura
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:IDFactura|*:FechaExpedicionFactura"To sFechaExpedicionFactura
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:EstadoRegistro"To sEstadoRegistro
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:CodigoErrorRegistro"To sCodigoErrorRegistro
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:DescripcionErrorRegistro"To sDescripcionErrorRegistro
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:CSVRegistroDuplicado"To sCSVRegistroDuplicado
GetComGetChildContentOf hoResponseXml "*:Body|*:RespuestaRegFactuSistemaFacturacion|*:RespuestaLinea|*:EstadoRegistroDuplicado"To sEstadoRegistroDuplicado
End_Procedure