$oXml = ObjCreate("Chilkat_9_5_0.Xml")
$oXml.Tag = "soapenv:Envelope"
$oXml.AddAttribute("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/")
$oXml.AddAttribute("xmlns","http://ws.pc.gif.com.br/")
$oXml.AddAttribute("xmlns:nfs","http://nfse.abrasf.org.br")
$oXml.AddAttribute("xmlns:ds","http://www.w3.org/2000/09/xmldsig#")
$oXml.UpdateChildContent"soapenv:Header",""
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote",True,"versao","?")
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|CNPJ","token string"
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|cLote","string"
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature",True,"Id","?")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo",True,"Id","?")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:CanonicalizationMethod",True,"Algorithm","http://www.w3.org/TR/2001/REC-xml-c14n-20010315")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:SignatureMethod",True,"Algorithm","http://www.w3.org/2000/09/xmldsig#rsa-sha1")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",True,"Id","?")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",True,"URI","?")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",True,"Type","?")
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform",True,"Algorithm","?")
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform|ds:XPath","string"
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestMethod",True,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1")
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestValue","BASE64_DATA"
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignatureValue","..."
$oXml.UpdateAttrAt("soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo",True,"Id","?")
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509SubjectName","string"
$oXml.UpdateChildContent"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509Certificate","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.
$oXml.EmitXmlDecl = FalseLocal $soapRequestBody = $oXml.GetXml()
Local $sEndpoint = "https://canoas-homol.infisc.com.br/services/nfse/ws/Servicos"Local $soapAction = ""; For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"Local $sContentType = "text/xml"
$oHttp = ObjCreate("Chilkat_9_5_0.Http")
$oHttp.ClearHeaders
$oHttp.SetRequestHeader"Content-Type",$sContentType
$oHttp.SetRequestHeader"SOAPAction",$soapAction
Local $oResp = $oHttp.PostXml($sEndpoint,$soapRequestBody,"utf-8")
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
ConsoleWrite("Failed to send SOAP request." & @CRLF)
Exit
EndIf; Get the XML response body.
$oResponseXml = ObjCreate("Chilkat_9_5_0.Xml")
$oResp.GetBodyXml($oResponseXml)
Local $iStatusCode = $oResp.StatusCode
ConsoleWrite("response status code: " & $iStatusCode & @CRLF)
; If the status code does not indicate succcess, then show the response XML,
; which probably contains error information.If ($iStatusCode <> 200) Then
ConsoleWrite($oResponseXml.GetXml() & @CRLF)
Exit
EndIf
ConsoleWrite($oResponseXml.GetXml() & @CRLF)
; 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).Local $sEnvelope_xmlns = $oResponseXml.GetAttrValue("xmlns")
Local $sConfirmaCancelamentoLote_versao = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|(versao)")
Local $sCNPJ = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|CNPJ")
Local $sCLote = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|cLote")
Local $sDhRecbto = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|dhRecbto")
Local $sit = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|sit")
Local $sMot = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|mot")
Local $sSignature_Id = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|(Id)")
Local $sSignedInfo_Id = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|(Id)")
Local $sCanonicalizationMethod_Algorithm = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:CanonicalizationMethod|(Algorithm)")
Local $sSignatureMethod_Algorithm = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:SignatureMethod|(Algorithm)")
Local $sReference_Id = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Id)")
Local $sReference_URI = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(URI)")
Local $sReference_Type = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Type)")
Local $sTransform_Algorithm = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|(Algorithm)")
Local $sXPath = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|*:XPath")
Local $sDigestMethod_Algorithm = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestMethod|(Algorithm)")
Local $sDigestValue = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestValue")
Local $sSignatureValue = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignatureValue")
Local $sKeyInfo_Id = $oResponseXml.ChilkatPath("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|(Id)")
Local $sX509SubjectName = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509SubjectName")
Local $sX509Certificate = $oResponseXml.GetChildContent("*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509Certificate")