Sample code for 30+ languages & platforms
Xbase++

POST GovTalk XML to https://vrep1-t.cssz.cz/VREP/submission

See more HTTP Misc Examples

Demonstrates how to POST a GovTalk XML message to https://vrep1-t.cssz.cz/VREP/submission

PDF Documentation is at http://www.cssz.cz/NR/rdonlyres/0ACDBB35-F78A-4B1A-8258-7249B55C788E/0/csszpodavacidotazovaciprotokol20110608.pdf

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oXml
LOCAL oBd
LOCAL oGzip
LOCAL oCert
LOCAL oCrypt
LOCAL oHttp
LOCAL oResp
LOCAL nStatusCode

nSuccess := 0

//  This requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

//  First prepare the XML body that is to be GZip compressed and then encrypted.
//  Build the following XML..

//  Use the online tool at http://tools.chilkat.io/xmlCreate.cshtml
//  to generate the XML creation code that follows this XML.

//  <?xml version="1.0" encoding="utf-8" ?>
//  <pvpoj xmlns="http://schemas.cssz.cz/POJ/PVPOJ2016">
//      <prehled verze="2016.0" typPrehledu="N">
//          <okres>
//              <kodOSSZ>119</kodOSSZ>
//              <nazevOSSZ>Praha 9</nazevOSSZ>
//          </okres>
//          <obdobi>
//              <mesic>1</mesic>
//              <rok>2018</rok>
//          </obdobi>
//          <zamestnavatel>
//              <vs>9992002999</vs>
//              <IC>49710999</IC>
//              <nazev>SIT &amp; KHASO v.o.s.</nazev>
//              <adresa>
//                  <ulice>Na sp�leni�ti</ulice>
//                  <cisloDomu>517</cisloDomu>
//                  <obec>Praha 9</obec>
//                  <PSC>19032</PSC>
//                  <stat>CZ</stat>
//              </adresa>
//          </zamestnavatel>
//          <pojistne>
//              <uhrnVymerovacichZakladu>1104</uhrnVymerovacichZakladu>
//              <pojistneZamestnance>175</pojistneZamestnance>
//              <pojistneZamestnavatele>2826</pojistneZamestnavatele>
//              <pojistneCelkem>4301</pojistneCelkem>
//          </pojistne>
//          <platebniUdaje>
//              <bankaCisloUctu>012345789/0800</bankaCisloUctu>
//          </platebniUdaje>
//          <pracovnik>
//              <jmeno>Matt</jmeno>
//              <prijmeni>Smith</prijmeni>
//              <telefon>606796999</telefon>
//              <email>admin@chilkatsoft.com</email>
//          </pracovnik>
//          <datumVyplneni>2018-03-02</datumVyplneni>
//          <poznamka />
//      </prehled>
//  </pvpoj>

oXml := CreateObject("Chilkat.Xml")
oXml:Tag := "pvpoj"
oXml:AddAttribute("xmlns", "http://schemas.cssz.cz/POJ/PVPOJ2016")
oXml:UpdateAttrAt("prehled", 1, "verze", "2016.0")
oXml:UpdateAttrAt("prehled", 1, "typPrehledu", "N")
oXml:UpdateChildContent("prehled|okres|kodOSSZ", "119")
oXml:UpdateChildContent("prehled|okres|nazevOSSZ", "Praha 9")
oXml:UpdateChildContent("prehled|obdobi|mesic", "1")
oXml:UpdateChildContent("prehled|obdobi|rok", "2018")
oXml:UpdateChildContent("prehled|zamestnavatel|vs", "9992002999")
oXml:UpdateChildContent("prehled|zamestnavatel|IC", "49710999")
oXml:UpdateChildContent("prehled|zamestnavatel|nazev", "SIT & KHASO v.o.s.")
oXml:UpdateChildContent("prehled|zamestnavatel|adresa|ulice", "Na sp�leni�ti")
oXml:UpdateChildContent("prehled|zamestnavatel|adresa|cisloDomu", "517")
oXml:UpdateChildContent("prehled|zamestnavatel|adresa|obec", "Praha 9")
oXml:UpdateChildContent("prehled|zamestnavatel|adresa|PSC", "19032")
oXml:UpdateChildContent("prehled|zamestnavatel|adresa|stat", "CZ")
oXml:UpdateChildContent("prehled|pojistne|uhrnVymerovacichZakladu", "1104")
oXml:UpdateChildContent("prehled|pojistne|pojistneZamestnance", "175")
oXml:UpdateChildContent("prehled|pojistne|pojistneZamestnavatele", "2826")
oXml:UpdateChildContent("prehled|pojistne|pojistneCelkem", "4301")
oXml:UpdateChildContent("prehled|platebniUdaje|bankaCisloUctu", "012345789/0800")
oXml:UpdateChildContent("prehled|pracovnik|jmeno", "Matt")
oXml:UpdateChildContent("prehled|pracovnik|prijmeni", "Smith")
oXml:UpdateChildContent("prehled|pracovnik|telefon", "606796999")
oXml:UpdateChildContent("prehled|pracovnik|email", "admin@chilkatsoft.com")
oXml:UpdateChildContent("prehled|datumVyplneni", "2018-03-02")
oXml:UpdateChildContent("prehled|poznamka", "")

oXml:EmitCompact := 1
oXml:EmitXmlDecl := 0

//  Emit the XML into bd.
oBd := CreateObject("Chilkat.BinData")
oBd:AppendString(oXml:GetXml(), "utf-8")

//  GZip compress the bd contents.
oGzip := CreateObject("Chilkat.Gzip")
//  The Filename is not an actual file on disk, but is just the filename string stored in the gzip compressed format.
oGzip:Filename := "pvpoj.xml"
oGzip:CompressBd(oBd)

//  Encrypt the contents using the government provided cert.
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCert:LoadFromFile("qa_data/govs/czech/pvpoj/DISCSSZ2019.cer")
IF (nSuccess == 0)
    ? oCert:LastErrorText
    oXml:destroy()
    oBd:destroy()
    oGzip:destroy()
    oCert:destroy()
    RETURN
ENDIF

oCrypt := CreateObject("Chilkat.Crypt2")
oCrypt:CryptAlgorithm := "pki"

oCrypt:Pkcs7CryptAlg := "aes"
oCrypt:KeyLength := 256

nSuccess := oCrypt:SetEncryptCert(oCert)
IF (nSuccess == 0)
    ? oCrypt:LastErrorText
    oXml:destroy()
    oBd:destroy()
    oGzip:destroy()
    oCert:destroy()
    oCrypt:destroy()
    RETURN
ENDIF

nSuccess := oCrypt:EncryptBd(oBd)
IF (nSuccess == 0)
    ? oCrypt:LastErrorText
    oXml:destroy()
    oBd:destroy()
    oGzip:destroy()
    oCert:destroy()
    oCrypt:destroy()
    RETURN
ENDIF

//  At this point, bd contains the gzip compressed / encrypted XML.

//  Build the following GovTalkMessage XML:

//  <?xml version="1.0" encoding="utf-8"?>
//  <GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
//    <EnvelopeVersion>2.0</EnvelopeVersion>
//    <Header>
//      <MessageDetails>
//        <Class>CSSZ_PVPOJ</Class>
//        <Qualifier>request</Qualifier>
//        <Function>submit</Function>
//        <TransactionID />
//        <AuditID />
//        <CorrelationID />
//        <ResponseEndPoint PollInterval="0" />
//        <Transformation>XML</Transformation>
//        <GatewayTest />
//        <GatewayTimestamp />
//      </MessageDetails>
//      <SenderDetails>
//        <IDAuthentication>
//          <SenderID />
//          <Authentication>
//            <Method>clear</Method>
//            <Role />
//            <Value />
//          </Authentication>
//        </IDAuthentication>
//        <X509Certificate />
//        <EmailAddress>admin@chilkatsoft.com</EmailAddress>
//      </SenderDetails>
//    </Header>
//    <GovTalkDetails>
//      <Keys>
//        <Key Type="vars">9992888999</Key>
//      </Keys>
//      <GatewayAdditions />
//    </GovTalkDetails>
//    <Body>
//      <Message xmlns="http://www.cssz.cz/XMLSchema/envelope" version="1.2" eType="PVPOJ16">
//        <Header>
//          <Signature xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64">Signature goes here</Signature>
//          <Vendor productName="Abc xyz. s r.o. JKL .NET Client" version="6.0.2.0" />
//        </Header>
//        <Body xmlns:dt="urn:schemas-microsoft-com:datatypes" encrypted="yes" contentEncoding="gzip" dt:dt="bin.base64">Base64 goes here
//  </Body>
//      </Message>
//    </Body>
//  </GovTalkMessage>
//  

//  Use the online tool at http://tools.chilkat.io/xmlCreate.cshtml
//  to generate this code.

oXml:Clear()
oXml:Tag := "GovTalkMessage"
oXml:AddAttribute("xmlns", "http://www.govtalk.gov.uk/CM/envelope")
oXml:UpdateChildContent("EnvelopeVersion", "2.0")
oXml:UpdateChildContent("Header|MessageDetails|Class", "CSSZ_PVPOJ")
oXml:UpdateChildContent("Header|MessageDetails|Qualifier", "request")
oXml:UpdateChildContent("Header|MessageDetails|Function", "submit")
oXml:UpdateChildContent("Header|MessageDetails|TransactionID", "")
oXml:UpdateChildContent("Header|MessageDetails|AuditID", "")
oXml:UpdateChildContent("Header|MessageDetails|CorrelationID", "")
oXml:UpdateAttrAt("Header|MessageDetails|ResponseEndPoint", 1, "PollInterval", "0")
oXml:UpdateChildContent("Header|MessageDetails|Transformation", "XML")
oXml:UpdateChildContent("Header|MessageDetails|GatewayTest", "")
oXml:UpdateChildContent("Header|MessageDetails|GatewayTimestamp", "")
oXml:UpdateChildContent("Header|SenderDetails|IDAuthentication|SenderID", "")
oXml:UpdateChildContent("Header|SenderDetails|IDAuthentication|Authentication|Method", "clear")
oXml:UpdateChildContent("Header|SenderDetails|IDAuthentication|Authentication|Role", "")
oXml:UpdateChildContent("Header|SenderDetails|IDAuthentication|Authentication|Value", "")
oXml:UpdateChildContent("Header|SenderDetails|X509Certificate", "")
oXml:UpdateChildContent("Header|SenderDetails|EmailAddress", "admin@chilkatsoft.com")
oXml:UpdateAttrAt("GovTalkDetails|Keys|Key", 1, "Type", "vars")
oXml:UpdateChildContent("GovTalkDetails|Keys|Key", "9992888999")
oXml:UpdateChildContent("GovTalkDetails|GatewayAdditions", "")
oXml:UpdateAttrAt("Body|Message", 1, "xmlns", "http://www.cssz.cz/XMLSchema/envelope")
oXml:UpdateAttrAt("Body|Message", 1, "version", "1.2")
oXml:UpdateAttrAt("Body|Message", 1, "eType", "PVPOJ16")
oXml:UpdateAttrAt("Body|Message|Header|Signature", 1, "xmlns:dt", "urn:schemas-microsoft-com:datatypes")
oXml:UpdateAttrAt("Body|Message|Header|Signature", 1, "dt:dt", "bin.base64")
oXml:UpdateChildContent("Body|Message|Header|Signature", "Signature goes here")
oXml:UpdateAttrAt("Body|Message|Header|Vendor", 1, "productName", "Abc xyz. s r.o. JKL .NET Client")
oXml:UpdateAttrAt("Body|Message|Header|Vendor", 1, "version", "6.0.2.0")
oXml:UpdateAttrAt("Body|Message|Body", 1, "xmlns:dt", "urn:schemas-microsoft-com:datatypes")
oXml:UpdateAttrAt("Body|Message|Body", 1, "encrypted", "yes")
oXml:UpdateAttrAt("Body|Message|Body", 1, "contentEncoding", "gzip")
oXml:UpdateAttrAt("Body|Message|Body", 1, "dt:dt", "bin.base64")

//  Insert the contents of bd here:
oXml:UpdateChildContent("Body|Message|Body", oBd:GetEncoded("base64"))

//  Show the XML to be sent to https://vrep1-t.cssz.cz/VREP/submission
oXml:EmitCompact := 0
? oXml:GetXml()
oXml:EmitCompact := 1

//  ----------------------------------------------------------
//  POST the XML to https://vrep1-t.cssz.cz/VREP/submission

oHttp := CreateObject("Chilkat.Http")
oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpStr("POST", "https://vrep1-t.cssz.cz/VREP/submission", oXml:GetXml(), "utf-8", "application/xml", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oXml:destroy()
    oBd:destroy()
    oGzip:destroy()
    oCert:destroy()
    oCrypt:destroy()
    oHttp:destroy()
    oResp:destroy()
    RETURN
ENDIF

//  Examine the response status code (200 = success)
nStatusCode := oResp:StatusCode
? "Response status code = " + Str(nStatusCode)

//  The response body should be XML.
//  Load it into a Chilkat XML object to get it in indented format for viewing..
oXml:Clear()
oXml:LoadXml(oResp:BodyStr)
oXml:EmitCompact := 0
? oXml:GetXml()

//  Output is:
//  <GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
//      <EnvelopeVersion>2.0</EnvelopeVersion>
//      <Header>
//          <MessageDetails>
//              <Class>CSSZ_PVPOJ</Class>
//              <Qualifier>acknowledgement</Qualifier>
//              <Function>submit</Function>
//              <TransactionID />
//              <CorrelationID>1B6336D5ACE949CDB944424CB2D54401</CorrelationID>
//              <ResponseEndPoint PollInterval="60">https://vrep1-t.cssz.cz/VREP/poll</ResponseEndPoint>
//              <GatewayTimestamp>2018-07-02T22:23:41.310</GatewayTimestamp>
//          </MessageDetails>
//          <SenderDetails />
//      </Header>
//      <GovTalkDetails>
//          <Keys />
//      </GovTalkDetails>
//      <Body>
//          <Signature xmlns="http://www.podani.gov.cz/TxE/timestamp" Version="1.0">
//              <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
//              <TimeStamp>
//                  <date>20180702</date>
//                  <time>22:23:41</time>
//              </TimeStamp>
//              <SignatureValue>MIIORwYJKoZIhvcNAQcCo ... bBNE6MeXmk2siMuvY=</SignatureValue>
//          </Signature>
//      </Body>
//  </GovTalkMessage>
//  

//  Hint: Use the online tool at http://tools.chilkat.io/xmlParse.cshtml
//  to generate XML parsing code based on a sample response..

oXml:destroy()
oBd:destroy()
oGzip:destroy()
oCert:destroy()
oCrypt:destroy()
oHttp:destroy()
oResp:destroy()