func chilkatTest() {
let xml = CkoXml()!
xml.tag = "soapenv:Envelope"
xml.addAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.addAttribute("xmlns:sfLR", value: "https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd")
xml.addAttribute("xmlns:sf", value: "https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd")
xml.updateChildContent("soapenv:Header", value: "")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:Cabecera|sf:ObligadoEmision|sf:NombreRazon", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:Cabecera|sf:ObligadoEmision|sf:NIF", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:IDVersion", value: "1.0")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:IDFactura|sf:IDEmisorFactura", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:IDFactura|sf:NumSerieFactura", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:IDFactura|sf:FechaExpedicionFactura", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:NombreRazonEmisor", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:TipoFactura", value: "F1")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:DescripcionOperacion", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:Desglose|sf:DetalleDesglose|sf:CalificacionOperacion", value: "S1")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:Desglose|sf:DetalleDesglose|sf:BaseImponibleOimporteNoSujeto", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:CuotaTotal", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:ImporteTotal", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:Encadenamiento", value: "")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:NombreRazon", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:NIF", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:NombreSistemaInformatico", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:IdSistemaInformatico", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:Version", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:NumeroInstalacion", value: "string")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:TipoUsoPosibleSoloVerifactu", value: "S")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:TipoUsoPosibleMultiOT", value: "S")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:SistemaInformatico|sf:IndicadorMultiplesOT", value: "S")
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:FechaHoraHusoGenRegistro", value: "dateTime")
xml.updateChildContentInt("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:TipoHuella", value: 01)
xml.updateChildContent("soapenv:Body|sfLR:RegFactuSistemaFacturacion|sfLR:RegistroFactura|sf:RegistroAlta|sf:Huella", value: "string")
// In a SOAP HTTP request, including the XML declaration (<?xml version="1.0" encoding="UTF-8"?>) in the XML body is generally not required.
xml.emitXmlDecl = falsevar soapRequestBody: String? = xml.getXml()
var endpoint: String? = "https://www1.agenciatributaria.gob.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/RequerimientoSOAP"var soapAction: String? = ""// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"var contentType: String? = "text/xml"let http = CkoHttp()!
http.clearHeaders()
http.setRequestHeader("Content-Type", value: contentType)
http.setRequestHeader("SOAPAction", value: soapAction)
let resp = CkoHttpResponse()!
ERROR: Undefined variable(success)
ERROR: Undefined variable(success)
if success == false {
print("\(http.lastErrorText!)")
print("Failed to send SOAP request.")
return
}
// Get the XML response body.let responseXml = CkoXml()!
resp.getBody(responseXml)
var statusCode: Int = resp.statusCode.intValue
print("response status code: \(statusCode)")
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.if statusCode != 200 {
print("\(responseXml.getXml()!)")
return
}
print("\(responseXml.getXml()!)")
// 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).var NombreRazon: String? = responseXml.getChildContent("*:Body|*:RespuestaRegFactuSistemaFacturacion|*:Cabecera|*:ObligadoEmision|*:NombreRazon")
var NIF: String? = responseXml.getChildContent("*:Body|*:RespuestaRegFactuSistemaFacturacion|*:Cabecera|*:ObligadoEmision|*:NIF")
var TiempoEsperaEnvio: String? = responseXml.getChildContent("*:Body|*:RespuestaRegFactuSistemaFacturacion|*:TiempoEsperaEnvio")
var EstadoEnvio: String? = responseXml.getChildContent("*:Body|*:RespuestaRegFactuSistemaFacturacion|*:EstadoEnvio")
}