Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) POST GovTalk XML to https://vrep1-t.cssz.cz/VREP/submissionDemonstrates 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
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoXml Variant vBd Handle hoBd Handle hoGzip Variant vCert Handle hoCert Handle hoCrypt Handle hoHttp Variant vResp Handle hoResp Integer iStatusCode String sTemp1 Boolean bTemp1 // 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 & 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> Get Create (RefClass(cComChilkatXml)) To hoXml If (Not(IsComObjectCreated(hoXml))) Begin Send CreateComObject of hoXml End Set ComTag Of hoXml To "pvpoj" Get ComAddAttribute Of hoXml "xmlns" "http://schemas.cssz.cz/POJ/PVPOJ2016" To iSuccess Get ComUpdateAttrAt Of hoXml "prehled" True "verze" "2016.0" To iSuccess Get ComUpdateAttrAt Of hoXml "prehled" True "typPrehledu" "N" To iSuccess Send ComUpdateChildContent To hoXml "prehled|okres|kodOSSZ" "119" Send ComUpdateChildContent To hoXml "prehled|okres|nazevOSSZ" "Praha 9" Send ComUpdateChildContent To hoXml "prehled|obdobi|mesic" "1" Send ComUpdateChildContent To hoXml "prehled|obdobi|rok" "2018" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|vs" "9992002999" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|IC" "49710999" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|nazev" "SIT & KHASO v.o.s." Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|adresa|ulice" "Na sp�leni�ti" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|adresa|cisloDomu" "517" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|adresa|obec" "Praha 9" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|adresa|PSC" "19032" Send ComUpdateChildContent To hoXml "prehled|zamestnavatel|adresa|stat" "CZ" Send ComUpdateChildContent To hoXml "prehled|pojistne|uhrnVymerovacichZakladu" "1104" Send ComUpdateChildContent To hoXml "prehled|pojistne|pojistneZamestnance" "175" Send ComUpdateChildContent To hoXml "prehled|pojistne|pojistneZamestnavatele" "2826" Send ComUpdateChildContent To hoXml "prehled|pojistne|pojistneCelkem" "4301" Send ComUpdateChildContent To hoXml "prehled|platebniUdaje|bankaCisloUctu" "012345789/0800" Send ComUpdateChildContent To hoXml "prehled|pracovnik|jmeno" "Matt" Send ComUpdateChildContent To hoXml "prehled|pracovnik|prijmeni" "Smith" Send ComUpdateChildContent To hoXml "prehled|pracovnik|telefon" "606796999" Send ComUpdateChildContent To hoXml "prehled|pracovnik|email" "admin@chilkatsoft.com" Send ComUpdateChildContent To hoXml "prehled|datumVyplneni" "2018-03-02" Send ComUpdateChildContent To hoXml "prehled|poznamka" "" Set ComEmitCompact Of hoXml To True Set ComEmitXmlDecl Of hoXml To False // Emit the XML into bd. Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End Get ComGetXml Of hoXml To sTemp1 Get ComAppendString Of hoBd sTemp1 "utf-8" To iSuccess // GZip compress the bd contents. Get Create (RefClass(cComChilkatGzip)) To hoGzip If (Not(IsComObjectCreated(hoGzip))) Begin Send CreateComObject of hoGzip End // The Filename is not an actual file on disk, but is just the filename string stored in the gzip compressed format. Set ComFilename Of hoGzip To "pvpoj.xml" Get pvComObject of hoBd to vBd Get ComCompressBd Of hoGzip vBd To iSuccess // Encrypt the contents using the government provided cert. Get Create (RefClass(cComChilkatCert)) To hoCert If (Not(IsComObjectCreated(hoCert))) Begin Send CreateComObject of hoCert End Get ComLoadFromFile Of hoCert "qa_data/govs/czech/pvpoj/DISCSSZ2019.cer" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCert To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt If (Not(IsComObjectCreated(hoCrypt))) Begin Send CreateComObject of hoCrypt End Set ComCryptAlgorithm Of hoCrypt To "pki" Set ComPkcs7CryptAlg Of hoCrypt To "aes" Set ComKeyLength Of hoCrypt To 256 Get pvComObject of hoCert to vCert Get ComSetEncryptCert Of hoCrypt vCert To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCrypt To sTemp1 Showln sTemp1 Procedure_Return End Get pvComObject of hoBd to vBd Get ComEncryptBd Of hoCrypt vBd To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCrypt To sTemp1 Showln sTemp1 Procedure_Return End // 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. Send ComClear To hoXml Set ComTag Of hoXml To "GovTalkMessage" Get ComAddAttribute Of hoXml "xmlns" "http://www.govtalk.gov.uk/CM/envelope" To iSuccess Send ComUpdateChildContent To hoXml "EnvelopeVersion" "2.0" Send ComUpdateChildContent To hoXml "Header|MessageDetails|Class" "CSSZ_PVPOJ" Send ComUpdateChildContent To hoXml "Header|MessageDetails|Qualifier" "request" Send ComUpdateChildContent To hoXml "Header|MessageDetails|Function" "submit" Send ComUpdateChildContent To hoXml "Header|MessageDetails|TransactionID" "" Send ComUpdateChildContent To hoXml "Header|MessageDetails|AuditID" "" Send ComUpdateChildContent To hoXml "Header|MessageDetails|CorrelationID" "" Get ComUpdateAttrAt Of hoXml "Header|MessageDetails|ResponseEndPoint" True "PollInterval" "0" To iSuccess Send ComUpdateChildContent To hoXml "Header|MessageDetails|Transformation" "XML" Send ComUpdateChildContent To hoXml "Header|MessageDetails|GatewayTest" "" Send ComUpdateChildContent To hoXml "Header|MessageDetails|GatewayTimestamp" "" Send ComUpdateChildContent To hoXml "Header|SenderDetails|IDAuthentication|SenderID" "" Send ComUpdateChildContent To hoXml "Header|SenderDetails|IDAuthentication|Authentication|Method" "clear" Send ComUpdateChildContent To hoXml "Header|SenderDetails|IDAuthentication|Authentication|Role" "" Send ComUpdateChildContent To hoXml "Header|SenderDetails|IDAuthentication|Authentication|Value" "" Send ComUpdateChildContent To hoXml "Header|SenderDetails|X509Certificate" "" Send ComUpdateChildContent To hoXml "Header|SenderDetails|EmailAddress" "admin@chilkatsoft.com" Get ComUpdateAttrAt Of hoXml "GovTalkDetails|Keys|Key" True "Type" "vars" To iSuccess Send ComUpdateChildContent To hoXml "GovTalkDetails|Keys|Key" "9992888999" Send ComUpdateChildContent To hoXml "GovTalkDetails|GatewayAdditions" "" Get ComUpdateAttrAt Of hoXml "Body|Message" True "xmlns" "http://www.cssz.cz/XMLSchema/envelope" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message" True "version" "1.2" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message" True "eType" "PVPOJ16" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Header|Signature" True "xmlns:dt" "urn:schemas-microsoft-com:datatypes" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Header|Signature" True "dt:dt" "bin.base64" To iSuccess Send ComUpdateChildContent To hoXml "Body|Message|Header|Signature" "Signature goes here" Get ComUpdateAttrAt Of hoXml "Body|Message|Header|Vendor" True "productName" "Abc xyz. s r.o. JKL .NET Client" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Header|Vendor" True "version" "6.0.2.0" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Body" True "xmlns:dt" "urn:schemas-microsoft-com:datatypes" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Body" True "encrypted" "yes" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Body" True "contentEncoding" "gzip" To iSuccess Get ComUpdateAttrAt Of hoXml "Body|Message|Body" True "dt:dt" "bin.base64" To iSuccess // Insert the contents of bd here: Get ComGetEncoded Of hoBd "base64" To sTemp1 Send ComUpdateChildContent To hoXml "Body|Message|Body" sTemp1 // Show the XML to be sent to https://vrep1-t.cssz.cz/VREP/submission Set ComEmitCompact Of hoXml To False Get ComGetXml Of hoXml To sTemp1 Showln sTemp1 Set ComEmitCompact Of hoXml To True // ---------------------------------------------------------- // POST the XML to https://vrep1-t.cssz.cz/VREP/submission Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Get ComGetXml Of hoXml To sTemp1 Get ComPostXml Of hoHttp "https://vrep1-t.cssz.cz/VREP/submission" sTemp1 "utf-8" To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // Examine the response status code (200 = success) Get ComStatusCode Of hoResp To iStatusCode Showln "Response status code = " iStatusCode // The response body should be XML. // Load it into a Chilkat XML object to get it in indented format for viewing.. Send ComClear To hoXml Get ComBodyStr Of hoResp To sTemp1 Get ComLoadXml Of hoXml sTemp1 To iSuccess Set ComEmitCompact Of hoXml To False Get ComGetXml Of hoXml To sTemp1 Showln sTemp1 // 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.. Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.