func chilkatTest() {
let xml = CkoXml()
xml.Tag = "soapenv:Envelope"
xml.AddAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns:ar", value: "http://ar.gov.afip.dif.FEV1/")
xml.UpdateChildContent("soapenv:Header", value: "")
xml.UpdateChildContent("soapenv:Body|ar:FECompConsultar|ar:Auth|ar:Token", value: "string")
xml.UpdateChildContent("soapenv:Body|ar:FECompConsultar|ar:Auth|ar:Sign", value: "string")
xml.UpdateChildContentInt("soapenv:Body|ar:FECompConsultar|ar:Auth|ar:Cuit", value: 123456)
xml.UpdateChildContentInt("soapenv:Body|ar:FECompConsultar|ar:FeCompConsReq|ar:CbteTipo", value: 1042)
xml.UpdateChildContentInt("soapenv:Body|ar:FECompConsultar|ar:FeCompConsReq|ar:CbteNro", value: 123456)
xml.UpdateChildContentInt("soapenv:Body|ar:FECompConsultar|ar:FeCompConsReq|ar:PtoVta", value: 1042)
// 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://wswhomo.afip.gov.ar/wsfev1/service.asmx"var soapAction: String? = "http://ar.gov.afip.dif.FEV1/FECompConsultar"// 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)
var resp: CkoHttpResponse? = http.PostXml(endpoint, xmlDoc: soapRequestBody, charset: "utf-8")
if http.LastMethodSuccess == false {
print("\(http.LastErrorText)")
print("Failed to send SOAP request.")
return
}
// Get the XML response body.let responseXml = CkoXml()
resp!.GetBodyXml(responseXml)
var statusCode: Int = resp!.StatusCode.intValue
print("response status code: \(statusCode)")
resp = nil// 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 Concepto: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Concepto").intValue
var DocTipo: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:DocTipo").intValue
var DocNro: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:DocNro").intValue
var CbteDesde: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbteDesde").intValue
var CbteHasta: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbteHasta").intValue
var CbteFch: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbteFch")
var ImpTotal: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpTotal")
var ImpTotConc: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpTotConc")
var ImpNeto: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpNeto")
var ImpOpEx: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpOpEx")
var ImpTrib: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpTrib")
var ImpIVA: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:ImpIVA")
var FchServDesde: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:FchServDesde")
var FchServHasta: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:FchServHasta")
var FchVtoPago: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:FchVtoPago")
var MonId: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:MonId")
var MonCotiz: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:MonCotiz")
var Tipo: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbtesAsoc|*:CbteAsoc|*:Tipo").intValue
var PtoVta: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbtesAsoc|*:CbteAsoc|*:PtoVta").intValue
var Nro: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbtesAsoc|*:CbteAsoc|*:Nro").intValue
var Cuit: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbtesAsoc|*:CbteAsoc|*:Cuit")
CbteFch = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbtesAsoc|*:CbteAsoc|*:CbteFch")
var Id: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Tributos|*:Tributo|*:Id").intValue
var Desc: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Tributos|*:Tributo|*:Desc")
var BaseImp: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Tributos|*:Tributo|*:BaseImp")
var Alic: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Tributos|*:Tributo|*:Alic")
var Importe: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Tributos|*:Tributo|*:Importe")
Id = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Iva|*:AlicIva|*:Id").intValue
BaseImp = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Iva|*:AlicIva|*:BaseImp")
Importe = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Iva|*:AlicIva|*:Importe")
var strId: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Opcionales|*:Opcional|*:Id")
var Valor: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Opcionales|*:Opcional|*:Valor")
DocTipo = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Compradores|*:Comprador|*:DocTipo").intValue
DocNro = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Compradores|*:Comprador|*:DocNro").intValue
var Porcentaje: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Compradores|*:Comprador|*:Porcentaje")
var FchDesde: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:PeriodoAsoc|*:FchDesde")
var FchHasta: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:PeriodoAsoc|*:FchHasta")
Id = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Actividades|*:Actividad|*:Id").intValue
var Resultado: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Resultado")
var CodAutorizacion: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CodAutorizacion")
var EmisionTipo: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:EmisionTipo")
var FchVto: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:FchVto")
var FchProceso: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:FchProceso")
var Code: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Observaciones|*:Obs|*:Code").intValue
var Msg: String? = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:Observaciones|*:Obs|*:Msg")
PtoVta = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:PtoVta").intValue
var CbteTipo: Int = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:ResultGet|*:CbteTipo").intValue
Code = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:Errors|*:Err|*:Code").intValue
Msg = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:Errors|*:Err|*:Msg")
Code = responseXml.GetChildIntValue("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:Events|*:Evt|*:Code").intValue
Msg = responseXml.GetChildContent("*:Body|*:FECompConsultarResponse|*:FECompConsultarResult|*:Events|*:Evt|*:Msg")
}