SOAP WSDL Generate Code

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
-- Important: See this note about {{-https://cknotes.com/sql-sp_oamethod-string-length-return-value-limitations/|||string length limitations for strings returned by sp_OAMethod calls-}}.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the {{-https://www.example-code.com/sql/default.asp|||warning about using nvarchar(max)-}}.
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @xml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @xml OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OASetProperty @xml, 'Tag', 'soapenv:Envelope'
    DECLARE @success int
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:soapenv', 'http://schemas.xmlsoap.org/soap/envelope/'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns', 'http://ws.pc.gif.com.br/'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:nfs', 'http://nfse.abrasf.org.br'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:ds', 'http://www.w3.org/2000/09/xmldsig#'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Header', ''
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote', 1, 'versao', '?'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|CNPJ', 'token string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|cLote', 'string'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature', 1, 'Id', '?'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo', 1, 'Id', '?'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:CanonicalizationMethod', 1, 'Algorithm', 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:SignatureMethod', 1, 'Algorithm', 'http://www.w3.org/2000/09/xmldsig#rsa-sha1'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference', 1, 'Id', '?'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference', 1, 'URI', '?'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference', 1, 'Type', '?'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform', 1, 'Algorithm', '?'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:Transforms|ds:Transform|ds:XPath', 'string'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestMethod', 1, 'Algorithm', 'http://www.w3.org/2000/09/xmldsig#sha1'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignedInfo|ds:Reference|ds:DigestValue', 'BASE64_DATA'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:SignatureValue', '...'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo', 1, 'Id', '?'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'soapenv:Body|cancelarLoteRequest|pedidoCancelamentoLote|ds:Signature|ds:KeyInfo|ds:X509Data|ds:X509SubjectName', 'string'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, '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. 
    EXEC sp_OASetProperty @xml, 'EmitXmlDecl', 0
    DECLARE @soapRequestBody nvarchar(4000)
    EXEC sp_OAMethod @xml, 'GetXml', @soapRequestBody OUT

    DECLARE @endpoint nvarchar(4000)
    SELECT @endpoint = 'https://canoas-homol.infisc.com.br/services/nfse/ws/Servicos'
    DECLARE @soapAction nvarchar(4000)
    SELECT @soapAction = ''
    --  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
    DECLARE @contentType nvarchar(4000)
    SELECT @contentType = 'text/xml'

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT

    EXEC sp_OAMethod @http, 'ClearHeaders', NULL
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', @contentType
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'SOAPAction', @soapAction

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostXml', @resp OUT, @endpoint, @soapRequestBody, 'utf-8'
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed to send SOAP request.'
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        RETURN
      END

    -- Get the XML response body.
    DECLARE @responseXml int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Xml', @responseXml OUT

    EXEC sp_OAMethod @resp, 'GetBodyXml', @success OUT, @responseXml

    DECLARE @statusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @statusCode OUT

    PRINT 'response status code: ' + @statusCode

    EXEC @hr = sp_OADestroy @resp

    -- If the status code does not indicate succcess, then show the response XML,
    -- which probably contains error information.
    IF @statusCode <> 200
      BEGIN
        EXEC sp_OAMethod @responseXml, 'GetXml', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @xml
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @responseXml
        RETURN
      END

    EXEC sp_OAMethod @responseXml, 'GetXml', @sTmp0 OUT
    PRINT @sTmp0

    -- 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).

    DECLARE @Envelope_xmlns nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetAttrValue', @Envelope_xmlns OUT, 'xmlns'
    DECLARE @confirmaCancelamentoLote_versao nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @confirmaCancelamentoLote_versao OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|(versao)'
    DECLARE @CNPJ nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @CNPJ OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|CNPJ'
    DECLARE @cLote nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @cLote OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|cLote'
    DECLARE @dhRecbto nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @dhRecbto OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|dhRecbto'
    DECLARE @sit nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @sit OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|sit'
    DECLARE @mot nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @mot OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|mot'
    DECLARE @Signature_Id nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @Signature_Id OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|(Id)'
    DECLARE @SignedInfo_Id nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @SignedInfo_Id OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|(Id)'
    DECLARE @CanonicalizationMethod_Algorithm nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @CanonicalizationMethod_Algorithm OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:CanonicalizationMethod|(Algorithm)'
    DECLARE @SignatureMethod_Algorithm nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @SignatureMethod_Algorithm OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:SignatureMethod|(Algorithm)'
    DECLARE @Reference_Id nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @Reference_Id OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Id)'
    DECLARE @Reference_URI nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @Reference_URI OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(URI)'
    DECLARE @Reference_Type nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @Reference_Type OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|(Type)'
    DECLARE @Transform_Algorithm nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @Transform_Algorithm OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|(Algorithm)'
    DECLARE @XPath nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @XPath OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:Transforms|*:Transform|*:XPath'
    DECLARE @DigestMethod_Algorithm nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @DigestMethod_Algorithm OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestMethod|(Algorithm)'
    DECLARE @DigestValue nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @DigestValue OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignedInfo|*:Reference|*:DigestValue'
    DECLARE @SignatureValue nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @SignatureValue OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:SignatureValue'
    DECLARE @KeyInfo_Id nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'ChilkatPath', @KeyInfo_Id OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|(Id)'
    DECLARE @X509SubjectName nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @X509SubjectName OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509SubjectName'
    DECLARE @X509Certificate nvarchar(4000)
    EXEC sp_OAMethod @responseXml, 'GetChildContent', @X509Certificate OUT, '*:Body|cancelarLoteResponse|confirmaCancelamentoLote|*:Signature|*:KeyInfo|*:X509Data|*:X509Certificate'

    EXEC @hr = sp_OADestroy @xml
    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @responseXml


END
GO
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>