ServicosPortSoap11 / cancelarLote
ASP AutoIt C C (Unicode) C++ C++ (Unicode) C# DataFlex Delphi Foxpro Go Java Node.js Objective-C Perl PHP Extension PowerBuilder Powershell PureBasic Python CkPython Ruby SQL Server Swift TCL VB.NET VB6 VBScript Xojo
func chilkatTest() {
let xml = CkoXml()
xml.Tag = "soapenv:Envelope"
xml.AddAttribute("xmlns:soapenv", value: "http://schemas.xmlsoap.org/soap/envelope/")
xml.AddAttribute("xmlns", value: "http://ws.pc.gif.com.br/")
xml.AddAttribute("xmlns:nfs", value: "http://nfse.abrasf.org.br")
xml.AddAttribute("xmlns:ds", value: "http://www.w3.org/2000/09/xmldsig#")
xml.UpdateChildContent("soapenv:Header", value: "")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote", autoCreate: true, attrName: "versao", attrValue: "?")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|CNPJ", value: "token string")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|cLote", value: "string")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature", autoCreate: true, attrName: "Id", attrValue: "?")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo", autoCreate: true, attrName: "Id", attrValue: "?")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:CanonicalizationMethod", autoCreate: true, attrName: "Algorithm", attrValue: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:SignatureMethod", autoCreate: true, attrName: "Algorithm", attrValue: "http://www.w3.org/2000/09/xmldsig#rsa-sha1")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference", autoCreate: true, attrName: "Id", attrValue: "?")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference", autoCreate: true, attrName: "URI", attrValue: "?")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference", autoCreate: true, attrName: "Type", attrValue: "?")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform", autoCreate: true, attrName: "Algorithm", attrValue: "?")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform|ds:XPath", value: "string")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestMethod", autoCreate: true, attrName: "Algorithm", attrValue: "http://www.w3.org/2000/09/xmldsig#sha1")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestValue", value: "BASE64_DATA")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignatureValue", value: "...")
xml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo", autoCreate: true, attrName: "Id", attrValue: "?")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509SubjectName", value: "string")
xml.UpdateChildContent("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509Certificate", value: "BqozVXeZZg==")
// 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 = false
var soapRequestBody: String? = xml.GetXml()
var endpoint: String? = "https://canoas-homol.infisc.com.br/services/nfse/ws/Servicos"
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)
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 Envelope_xmlns: String? = responseXml.GetAttrValue("xmlns")
var confirmaCancelamentoLote_versao: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|(versao)")
var CNPJ: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|CNPJ")
var cLote: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|cLote")
var dhRecbto: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|dhRecbto")
var sit: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|sit")
var mot: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|mot")
var Signature_Id: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|(Id)")
var SignedInfo_Id: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|(Id)")
var CanonicalizationMethod_Algorithm: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:CanonicalizationMethod|(Algorithm)")
var SignatureMethod_Algorithm: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:SignatureMethod|(Algorithm)")
var Reference_Id: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Id)")
var Reference_URI: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(URI)")
var Reference_Type: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Type)")
var Transform_Algorithm: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|(Algorithm)")
var XPath: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|*:XPath")
var DigestMethod_Algorithm: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestMethod|(Algorithm)")
var DigestValue: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestValue")
var SignatureValue: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignatureValue")
var KeyInfo_Id: String? = responseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|(Id)")
var X509SubjectName: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509SubjectName")
var X509Certificate: String? = responseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509Certificate")
}
Request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://ws.pc.gif.com.br/" xmlns:nfs="http://nfse.abrasf.org.br" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<soapenv:Header/>
<soapenv:Body>
<cancelarLoteRequest>
<pedidoCancelamentoLote versao="?">
<CNPJ>token string</CNPJ>
<cLote>string</cLote>
<ds:Signature Id="?">
<ds:SignedInfo Id="?">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference Id="?" URI="?" Type="?">
<ds:Transforms>
<ds:Transform Algorithm="?">
<ds:XPath>string</ds:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>BASE64_DATA</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>...</ds:SignatureValue>
<ds:KeyInfo Id="?">
<ds:X509Data>
<ds:X509SubjectName>string</ds:X509SubjectName>
<ds:X509Certificate>BqozVXeZZg==</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
</pedidoCancelamentoLote>
</cancelarLoteRequest>
</soapenv:Body>
</soapenv:Envelope>
Response XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://ws.pc.gif.com.br/" xmlns:nfs="http://nfse.abrasf.org.br" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<soapenv:Header/>
<soapenv:Body>
<cancelarLoteResponse>
<confirmaCancelamentoLote versao="?">
<CNPJ>token string</CNPJ>
<cLote>string</cLote>
<dhRecbto>string</dhRecbto>
<sit>positiveInteger</sit>
<mot>string</mot>
<ds:Signature Id="?">
<ds:SignedInfo Id="?">
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference Id="?" URI="?" Type="?">
<ds:Transforms>
<ds:Transform Algorithm="?">
<ds:XPath>string</ds:XPath>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>BASE64_DATA</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>...</ds:SignatureValue>
<ds:KeyInfo Id="?">
<ds:X509Data>
<ds:X509SubjectName>string</ds:X509SubjectName>
<ds:X509Certificate>BqozVXeZZg==</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
</confirmaCancelamentoLote>
</cancelarLoteResponse>
</soapenv:Body>
</soapenv:Envelope>