Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Excel Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Excel) SOAP e-factura.sunat.gob.pe getStatusCdr

Make a SOAP call to https://e-factura.sunat.gob.pe/ol-it-wsconscpegem/billConsultService

Download Excel Class Modules

Chilkat Excel Class Modules

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim http As Chilkat.Http
Set http = Chilkat.NewHttp

' <soapenv:Envelope xmlns:ser="http://service.sunat.gob.pe"
'   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
'   xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
'  <soapenv:Header>
'   <wsse:Security>        
'    <wsse:UsernameToken>          
'     <wsse:Username>MY_USERNAME</wsse:Username>
'     <wsse:Password>MY_PASSWORD</wsse:Password>
'    </wsse:UsernameToken>      
'   </wsse:Security>
'  </soapenv:Header>
'  <soapenv:Body>
'   <ser:getStatus>
'    <rucComprobante>99999999999</rucComprobante>
'    <tipoComprobante>01</tipoComprobante>
'    <serieComprobante>F001</serieComprobante>
'    <numeroComprobante>55555</numeroComprobante>
'   </ser:getStatus>
'  </soapenv:Body>
'  </soapenv:Envelope> 
' 

Dim xml As Chilkat.Xml
Set xml = Chilkat.NewXml
xml.Tag = "soapenv:Envelope"
success = xml.AddAttribute("xmlns:ser","http://service.sunat.gob.pe")
success = xml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
success = xml.AddAttribute("xmlns:wsse","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
xml.UpdateChildContent "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Username","MY_USERNAME"
xml.UpdateChildContent "soapenv:Header|wsse:Security|wsse:UsernameToken|wsse:Password","MY_PASSWORD"
xml.UpdateChildContent "soapenv:Body|ser:getStatus|rucComprobante","99999999999"
xml.UpdateChildContent "soapenv:Body|ser:getStatus|tipoComprobante","01"
xml.UpdateChildContent "soapenv:Body|ser:getStatus|serieComprobante","F001"
xml.UpdateChildContent "soapenv:Body|ser:getStatus|numeroComprobante","55555"


strXml = xml.GetXml()

http.SetRequestHeader "SOAPAction","urn:getStatusCdr"
http.SetRequestHeader "Content-Type","text/xml; charset=utf-8"


endPoint = "https://e-factura.sunat.gob.pe/ol-it-wsconscpegem/billConsultService"


Set resp = http.PostXml(endPoint,strXml,"utf-8")
If (http.LastMethodSuccess <> True) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If


statusCode = resp.StatusCode
If (statusCode <> 200) Then
    Debug.Print "Non-success status code: "; statusCode
    Debug.Print "Response header: "; resp.Header
    Debug.Print "Response body: "; resp.BodyStr
    Debug.Print "Unsuccessful."

    Exit Sub
End If

Dim xmlResp As Chilkat.Xml
Set xmlResp = Chilkat.NewXml
success = xmlResp.LoadXml(resp.BodyStr)

Debug.Print xmlResp.GetXml()

' A sample response:

' <?xml version="1.0" encoding="UTF-8"?>
' <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
'     <S:Body>
'         <ns0:getStatusResponse xmlns:ns0="http://service.sunat.gob.pe">
'             <status>
'                 <statusCode>0001</statusCode>
'                 <statusMessage>El comprobante existe y est aceptado.</statusMessage>
'             </status>
'         </ns0:getStatusResponse>
'     </S:Body>
' </S:Envelope>
' 

' Parse the response...

S_Envelope_xmlns_S = xml.GetAttrValue("xmlns:S")

ns0_getStatusResponse_xmlns_ns0 = xml.ChilkatPath("S:Body|ns0:getStatusResponse|(xmlns:ns0)")
statusCode = xml.GetChildIntValue("S:Body|ns0:getStatusResponse|status|statusCode")

statusMessage = xml.GetChildContent("S:Body|ns0:getStatusResponse|status|statusMessage")

 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.