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_CkXmlW.h>
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkXmlW xml;
const wchar_t *soapRequestBody;
const wchar_t *endpoint;
const wchar_t *soapAction;
const wchar_t *contentType;
HCkHttpW http;
HCkHttpResponseW resp;
HCkXmlW responseXml;
int statusCode;
const wchar_t *Envelope_xmlns;
const wchar_t *confirmaCancelamentoLote_versao;
const wchar_t *CNPJ;
const wchar_t *cLote;
const wchar_t *dhRecbto;
const wchar_t *sit;
const wchar_t *mot;
const wchar_t *Signature_Id;
const wchar_t *SignedInfo_Id;
const wchar_t *CanonicalizationMethod_Algorithm;
const wchar_t *SignatureMethod_Algorithm;
const wchar_t *Reference_Id;
const wchar_t *Reference_URI;
const wchar_t *Reference_Type;
const wchar_t *Transform_Algorithm;
const wchar_t *XPath;
const wchar_t *DigestMethod_Algorithm;
const wchar_t *DigestValue;
const wchar_t *SignatureValue;
const wchar_t *KeyInfo_Id;
const wchar_t *X509SubjectName;
const wchar_t *X509Certificate;
xml = CkXmlW_Create();
CkXmlW_putTag(xml,L"soapenv:Envelope");
CkXmlW_AddAttribute(xml,L"xmlns:soapenv",L"http://schemas.xmlsoap.org/soap/envelope/");
CkXmlW_AddAttribute(xml,L"xmlns",L"http://ws.pc.gif.com.br/");
CkXmlW_AddAttribute(xml,L"xmlns:nfs",L"http://nfse.abrasf.org.br");
CkXmlW_AddAttribute(xml,L"xmlns:ds",L"http://www.w3.org/2000/09/xmldsig#");
CkXmlW_UpdateChildContent(xml,L"soapenv:Header",L"");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote",TRUE,L"versao",L"?");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|CNPJ",L"token string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|cLote",L"string");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature",TRUE,L"Id",L"?");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo",TRUE,L"Id",L"?");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:CanonicalizationMethod",TRUE,L"Algorithm",L"http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:SignatureMethod",TRUE,L"Algorithm",L"http://www.w3.org/2000/09/xmldsig#rsa-sha1");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,L"Id",L"?");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,L"URI",L"?");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference",TRUE,L"Type",L"?");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform",TRUE,L"Algorithm",L"?");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform|ds:XPath",L"string");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestMethod",TRUE,L"Algorithm",L"http://www.w3.org/2000/09/xmldsig#sha1");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestValue",L"BASE64_DATA");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignatureValue",L"...");
CkXmlW_UpdateAttrAt(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo",TRUE,L"Id",L"?");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509SubjectName",L"string");
CkXmlW_UpdateChildContent(xml,L"soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509Certificate",L"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.
CkXmlW_putEmitXmlDecl(xml,FALSE);
soapRequestBody = CkXmlW_getXml(xml);
endpoint = L"https://canoas-homol.infisc.com.br/services/nfse/ws/Servicos";
soapAction = L"";
// For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
contentType = L"text/xml";
http = CkHttpW_Create();
CkHttpW_ClearHeaders(http);
CkHttpW_SetRequestHeader(http,L"Content-Type",contentType);
CkHttpW_SetRequestHeader(http,L"SOAPAction",soapAction);
resp = CkHttpW_PostXml(http,endpoint,soapRequestBody,L"utf-8");
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
wprintf(L"Failed to send SOAP request.\n");
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
return;
}
// Get the XML response body.
responseXml = CkXmlW_Create();
CkHttpResponseW_GetBodyXml(resp,responseXml);
statusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"response status code: %d\n",statusCode);
CkHttpResponseW_Dispose(resp);
// If the status code does not indicate succcess, then show the response XML,
// which probably contains error information.
if (statusCode != 200) {
wprintf(L"%s\n",CkXmlW_getXml(responseXml));
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
CkXmlW_Dispose(responseXml);
return;
}
wprintf(L"%s\n",CkXmlW_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 = CkXmlW_getAttrValue(responseXml,L"xmlns");
confirmaCancelamentoLote_versao = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|(versao)");
CNPJ = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|CNPJ");
cLote = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|cLote");
dhRecbto = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|dhRecbto");
sit = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|sit");
mot = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|mot");
Signature_Id = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|(Id)");
SignedInfo_Id = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|(Id)");
CanonicalizationMethod_Algorithm = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:CanonicalizationMethod|(Algorithm)");
SignatureMethod_Algorithm = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:SignatureMethod|(Algorithm)");
Reference_Id = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Id)");
Reference_URI = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(URI)");
Reference_Type = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Type)");
Transform_Algorithm = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|(Algorithm)");
XPath = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|*:XPath");
DigestMethod_Algorithm = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestMethod|(Algorithm)");
DigestValue = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestValue");
SignatureValue = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignatureValue");
KeyInfo_Id = CkXmlW_chilkatPath(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|(Id)");
X509SubjectName = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509SubjectName");
X509Certificate = CkXmlW_getChildContent(responseXml,L"*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509Certificate");
CkXmlW_Dispose(xml);
CkHttpW_Dispose(http);
CkXmlW_Dispose(responseXml);
}