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
#include <C_CkXml.h>
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkXml xml;
const char *soapRequestBody;
const char *endpoint;
const char *soapAction;
const char *contentType;
HCkHttp http;
HCkHttpResponse resp;
HCkXml responseXml;
int statusCode;
const char *Envelope_xmlns;
const char *confirmaCancelamentoLote_versao;
const char *CNPJ;
const char *cLote;
const char *dhRecbto;
const char *sit;
const char *mot;
const char *Signature_Id;
const char *SignedInfo_Id;
const char *CanonicalizationMethod_Algorithm;
const char *SignatureMethod_Algorithm;
const char *Reference_Id;
const char *Reference_URI;
const char *Reference_Type;
const char *Transform_Algorithm;
const char *XPath;
const char *DigestMethod_Algorithm;
const char *DigestValue;
const char *SignatureValue;
const char *KeyInfo_Id;
const char *X509SubjectName;
const char *X509Certificate;
xml = CkXml_Create();
CkXml_putTag(xml,"soapenv:Envelope");
CkXml_AddAttribute(xml,"xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/");
CkXml_AddAttribute(xml,"xmlns","http://ws.pc.gif.com.br/");
CkXml_AddAttribute(xml,"xmlns:nfs","http://nfse.abrasf.org.br");
CkXml_AddAttribute(xml,"xmlns:ds","http://www.w3.org/2000/09/xmldsig#");
CkXml_UpdateChildContent(xml,"soapenv:Header","");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote",TRUE,"versao","?");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|CNPJ","token string");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|cLote","string");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature",TRUE,"Id","?");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo",TRUE,"Id","?");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:CanonicalizationMethod",TRUE,"Algorithm","http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:SignatureMethod",TRUE,"Algorithm","http://www.w3.org/2000/09/xmldsig#rsa-sha1");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,"Id","?");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,"URI","?");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,"Type","?");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform",TRUE,"Algorithm","?");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform|ds:XPath","string");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestMethod",TRUE,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestValue","BASE64_DATA");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignatureValue","...");
CkXml_UpdateAttrAt(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo",TRUE,"Id","?");
CkXml_UpdateChildContent(xml,"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509SubjectName","string");
CkXml_UpdateChildContent(xml,"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.
CkXml_putEmitXmlDecl(xml,FALSE);
soapRequestBody = CkXml_getXml(xml);
endpoint = "https://canoas-homol.infisc.com.br/services/nfse/ws/Servicos";
soapAction = "";
// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
contentType = "text/xml";
http = CkHttp_Create();
CkHttp_ClearHeaders(http);
CkHttp_SetRequestHeader(http,"Content-Type",contentType);
CkHttp_SetRequestHeader(http,"SOAPAction",soapAction);
resp = CkHttp_PostXml(http,endpoint,soapRequestBody,"utf-8");
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
printf("Failed to send SOAP request.\n");
CkXml_Dispose(xml);
CkHttp_Dispose(http);
return;
}
// Get the XML response body.
responseXml = CkXml_Create();
CkHttpResponse_GetBodyXml(resp,responseXml);
statusCode = CkHttpResponse_getStatusCode(resp);
printf("response status code: %d\n",statusCode);
CkHttpResponse_Dispose(resp);
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.
if (statusCode != 200) {
printf("%s\n",CkXml_getXml(responseXml));
CkXml_Dispose(xml);
CkHttp_Dispose(http);
CkXml_Dispose(responseXml);
return;
}
printf("%s\n",CkXml_getXml(responseXml));
// 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).
Envelope_xmlns = CkXml_getAttrValue(responseXml,"xmlns");
confirmaCancelamentoLote_versao = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|(versao)");
CNPJ = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|CNPJ");
cLote = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|cLote");
dhRecbto = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|dhRecbto");
sit = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|sit");
mot = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|mot");
Signature_Id = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|(Id)");
SignedInfo_Id = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|(Id)");
CanonicalizationMethod_Algorithm = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:CanonicalizationMethod|(Algorithm)");
SignatureMethod_Algorithm = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:SignatureMethod|(Algorithm)");
Reference_Id = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Id)");
Reference_URI = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(URI)");
Reference_Type = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Type)");
Transform_Algorithm = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|(Algorithm)");
XPath = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|*:XPath");
DigestMethod_Algorithm = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestMethod|(Algorithm)");
DigestValue = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestValue");
SignatureValue = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignatureValue");
KeyInfo_Id = CkXml_chilkatPath(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|(Id)");
X509SubjectName = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509SubjectName");
X509Certificate = CkXml_getChildContent(responseXml,"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509Certificate");
CkXml_Dispose(xml);
CkHttp_Dispose(http);
CkXml_Dispose(responseXml);
}