SOAP WSDL Generate Code

TimbradoSoap12Binding / timbrarBase64

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 <CkXmlW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    CkXmlW xml;
    xml.put_Tag(L"soap:Envelope");
    xml.AddAttribute(L"xmlns:soap",L"http://www.w3.org/2003/05/soap-envelope");
    xml.AddAttribute(L"xmlns:ns",L"http://timbrado.ws.cfdi.solucionfactible.com");
    xml.UpdateChildContent(L"soap:Header",L"");
    xml.UpdateChildContent(L"soap:Body|ns:timbrarBase64|ns:usuario",L"string");
    xml.UpdateChildContent(L"soap:Body|ns:timbrarBase64|ns:password",L"string");
    xml.UpdateChildContent(L"soap:Body|ns:timbrarBase64|ns:cfdiBase64",L"string");
    xml.UpdateChildContent(L"soap:Body|ns:timbrarBase64|ns:zip",L"true");

    // 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.put_EmitXmlDecl(false);
    const wchar_t *soapRequestBody = xml.getXml();

    const wchar_t *endpoint = L"";
    const wchar_t *soapAction = L"urn:timbrarBase64";
    //  For SOAP requests, the standard Content-Type is usually set to "text/xml" or "application/soap+xml"
    const wchar_t *contentType = L"text/xml";

    CkHttpW http;

    http.ClearHeaders();
    http.SetRequestHeader(L"Content-Type",contentType);
    http.SetRequestHeader(L"SOAPAction",soapAction);

    CkHttpResponseW *resp = http.PostXml(endpoint,soapRequestBody,L"utf-8");
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        wprintf(L"Failed to send SOAP request.\n");
        return;
    }

    // Get the XML response body.
    CkXmlW responseXml;
    resp->GetBodyXml(responseXml);

    int statusCode = resp->get_StatusCode();
    wprintf(L"response status code: %d\n",statusCode);

    delete 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",responseXml.getXml());
        return;
    }

    wprintf(L"%s\n",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).

    const wchar_t *mensaje = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:mensaje");
    const wchar_t *cadenaOriginal = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:cadenaOriginal");
    const wchar_t *certificadoSAT = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:certificadoSAT");
    const wchar_t *cfdiTimbrado = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:cfdiTimbrado");
    const wchar_t *fechaTimbrado = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:fechaTimbrado");
    mensaje = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:mensaje");
    const wchar_t *qrCode = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:qrCode");
    const wchar_t *selloSAT = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:selloSAT");
    int status = responseXml.GetChildIntValue(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:status");
    const wchar_t *uuid = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:uuid");
    const wchar_t *versionTFD = responseXml.getChildContent(L"*:Body|*:timbrarBase64Response|*:return|*:resultados|*:versionTFD");
    status = responseXml.GetChildIntValue(L"*:Body|*:timbrarBase64Response|*:return|*:status");
    }
Request XML
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://timbrado.ws.cfdi.solucionfactible.com">
    <soap:Header/>
    <soap:Body>
        <ns:timbrarBase64>
            <ns:usuario>string</ns:usuario>
            <ns:password>string</ns:password>
            <ns:cfdiBase64>string</ns:cfdiBase64>
            <ns:zip>true</ns:zip>
        </ns:timbrarBase64>
    </soap:Body>
</soap:Envelope>
Response XML
<soap:Envelope xmlns:ns="http://timbrado.ws.cfdi.solucionfactible.com" xmlns:ax27="http://timbrado.ws.cfdi.solucionfactible.com/xsd" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header/>
    <soap:Body>
        <ns:timbrarBase64Response>
            <ns:return>
                <ax27:mensaje>string</ax27:mensaje>
                <ax27:resultados>
                    <ax27:cadenaOriginal>string</ax27:cadenaOriginal>
                    <ax27:certificadoSAT>string</ax27:certificadoSAT>
                    <ax27:cfdiTimbrado>BqozVXeZZg==</ax27:cfdiTimbrado>
                    <ax27:fechaTimbrado>dateTime</ax27:fechaTimbrado>
                    <ax27:mensaje>string</ax27:mensaje>
                    <ax27:qrCode>BqozVXeZZg==</ax27:qrCode>
                    <ax27:selloSAT>string</ax27:selloSAT>
                    <ax27:status>1042</ax27:status>
                    <ax27:uuid>string</ax27:uuid>
                    <ax27:versionTFD>string</ax27:versionTFD>
                </ax27:resultados>
                <ax27:status>1042</ax27:status>
            </ns:return>
        </ns:timbrarBase64Response>
    </soap:Body>
</soap:Envelope>