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
(DataFlex) SOAP Request to Issue Documents in Facto.clDemonstrates how to make a SOAP HTTP request to issue a document using the facto.cl webservice.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoXml Handle hoHttp Variant vResp Handle hoResp Handle hoXmlResp String sTemp1 Integer iTemp1 Boolean bTemp1 // 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. // -------------------------------------------------------------------------------- // Here is an example of an HTTP POST Request we'll be sending: // POST /documento.php HTTP/1.1 // Content-Type: text/xml;charset=UTF-8 // SOAPAction: https://conexion.facto.cl/documento.php/emitirDocumento // // <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:server"> // <soapenv:Header/> // <soapenv:Body> // <urn:emitirDocumento soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> // <documento xsi:type="urn:emitir_dte"> // <encabezado xsi:type="urn:encabezado"> // <tipo_dte xsi:type="xsd:string">39</tipo_dte> // <fecha_emision xsi:type="xsd:date">2019-08-03</fecha_emision> // <condiciones_pago xsi:type="xsd:string">0</condiciones_pago> // <receptor_email xsi:type="xsd:string">example@gmail.com</receptor_email> // </encabezado> // <detalles xsi:type="urn:detalles"> // <detalle xsi:type="urn:detalle"> // <cantidad xsi:type="xsd:int">3</cantidad> // <glosa xsi:type="xsd:string">Recarga Agua Purificada</glosa> // <monto_unitario xsi:type="xsd:decimal">1932.773109</monto_unitario> // <exento_afecto xsi:type="xsd:boolean">1</exento_afecto> // </detalle> // </detalles> // <totales xsi:type="urn:totales"> // <total_exento xsi:type="xsd:int">0</total_exento> // <total_afecto xsi:type="xsd:int">5798</total_afecto> // <total_iva xsi:type="xsd:int">1102</total_iva> // <total_final xsi:type="xsd:Int">6900</total_final> // </totales> // </documento> // </urn:emitirDocumento> // </soapenv:Body> // </soapenv:Envelope> // Use this online tool to generate code from sample XML: // Generate Code to Create XML Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Set ComTag Of hoXml To "soapenv:Envelope" Get ComAddAttribute Of hoXml "xmlns:xsi" "http://www.w3.org/2001/XMLSchema-instance" To iSuccess Get ComAddAttribute Of hoXml "xmlns:xsd" "http://www.w3.org/2001/XMLSchema" To iSuccess Get ComAddAttribute Of hoXml "xmlns:soapenv" "http://schemas.xmlsoap.org/soap/envelope/" To iSuccess Get ComAddAttribute Of hoXml "xmlns:urn" "urn:server" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Header" "" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento" True "soapenv:encodingStyle" "http://schemas.xmlsoap.org/soap/encoding/" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento" True "xsi:type" "urn:emitir_dte" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado" True "xsi:type" "urn:encabezado" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|tipo_dte" True "xsi:type" "xsd:string" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|tipo_dte" "39" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|fecha_emision" True "xsi:type" "xsd:date" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|fecha_emision" "2019-08-03" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|condiciones_pago" True "xsi:type" "xsd:string" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|condiciones_pago" "0" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|receptor_email" True "xsi:type" "xsd:string" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|encabezado|receptor_email" "example@gmail.com" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles" True "xsi:type" "urn:detalles" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle" True "xsi:type" "urn:detalle" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|cantidad" True "xsi:type" "xsd:int" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|cantidad" "3" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|glosa" True "xsi:type" "xsd:string" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|glosa" "Recarga Agua Purificada" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|monto_unitario" True "xsi:type" "xsd:decimal" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|monto_unitario" "1932.773109" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|exento_afecto" True "xsi:type" "xsd:boolean" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|detalles|detalle|exento_afecto" "1" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|totales" True "xsi:type" "urn:totales" To iSuccess Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_exento" True "xsi:type" "xsd:int" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_exento" "0" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_afecto" True "xsi:type" "xsd:int" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_afecto" "5798" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_iva" True "xsi:type" "xsd:int" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_iva" "1102" Get ComUpdateAttrAt Of hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_final" True "xsi:type" "xsd:Int" To iSuccess Send ComUpdateChildContent To hoXml "soapenv:Body|urn:emitirDocumento|documento|totales|total_final" "6900" Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Set ComBasicAuth Of hoHttp To True Set ComLogin Of hoHttp To "9.999.999-9/mylogin" Set ComPassword Of hoHttp To "mypassword" Send ComSetRequestHeader To hoHttp "Content-Type" "text/xml;charset=UTF-8" Send ComSetRequestHeader To hoHttp "SoapAction" "https://conexion.facto.cl/documento.php/emitirDocumento" Get ComGetXml Of hoXml To sTemp1 Get ComPostXml Of hoHttp "https://conexion.facto.cl/documento.php" sTemp1 "utf-8" To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // A status code = 200 indicates success. Get ComStatusCode Of hoResp To iTemp1 Showln "Response status code = " iTemp1 Get Create (RefClass(cComChilkatXml)) To hoXmlResp If (Not(IsComObjectCreated(hoXmlResp))) Begin Send CreateComObject of hoXmlResp End Get ComBodyStr Of hoResp To sTemp1 Get ComLoadXml Of hoXmlResp sTemp1 To iSuccess Showln "Response body text:" Get ComGetXml Of hoXmlResp To sTemp1 Showln sTemp1 // The response will look like this: // <?xml version="1.0" encoding="UTF-8"?> // <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> // <SOAP-ENV:Body> // <ns1:emitirDocumentoResponse xmlns:ns1="urn:server"> // <return xsi:type="xsd:complexType"> // <resultado> // <status>0</status> // <mensaje_error/> // </resultado> // <encabezado> // <tipo_dte>39</tipo_dte> // <folio>109999</folio> // <fecha_emision>2019-08-03</fecha_emision> // <condiciones_pago>0</condiciones_pago> // <receptor_email>example@gmail.com</receptor_email> // </encabezado> // <detalles> // <cantidad>3</cantidad> // <glosa>Recarga Agua Purificada</glosa> // <monto_unitario>1932.773109</monto_unitario> // <exento_afecto>1</exento_afecto> // </detalles> // <totales> // <total_exento>0</total_exento> // <total_afecto>5798</total_afecto> // <total_iva>1102</total_iva> // <total_final>6900</total_final> // </totales> // <enlaces> // <dte_xml>https://temporal.facto.cl/2019/08/999993022aa9e0733174e87086ade7d4.xml</dte_xml> // <dte_pdf>https://temporal.facto.cl/2019/08/99999f52cf80c8ffc1fc22338dae022.pdf</dte_pdf> // <dte_timbre>https://temporal.facto.cl/2019/08/999999856c08b3d24a83bf29add5364a.png</dte_timbre> // </enlaces> // </return> // </ns1:emitirDocumentoResponse> // </SOAP-ENV:Body> // </SOAP-ENV:Envelope> Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.