All, I am in need of some assistance in developing my first RPG program to decode Base64 data. The requirement is to request a Qualcomm webservice, Event Subscription Service (ESS), and call the Dequeue2 method which returns message data that I want to store & use on our IBM i. Using soapUI I can clearly see the expected response: <soapenv:Envelope xmlns:soapenv="[1]http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="[2]http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="[3]http://www.w3.org/2001/XMLSchema" xmlns:xsi="[4]http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header/> <soapenv:Body> <p917:dequeue2Response xmlns:p917="[5]http://websvcs.otswebws"> <dequeue2Return> <count>3</count> <transactions>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48dHJhb kJsb2NrPjx0cmFuIElEPSI3OTM5IiBjb21wYW55SUQ9IlRNVFNXIiBhdXhJRD0iMDA5MzM2 ODM0OCI+PFQuNy4wMS4wPgk8a2V5PjI2NzU3MDQ8L2tleT4JPGV2ZW50VFM+MjAxMi0xMC0 wM1QyMToxMDowNlo8L2V2ZW50VFM+CTxzdGF0dXM+TmV3PC9zdGF0dXM+CTxpbnNwZWN0ZW RFcXVpcG1lbnQ+dHJhaWxlcjwvaW5zcGVjdGVkRXF1aXBtZW50Pgk8ZXF1aXBtZW50IAkgI HVuaXRBZGRyZXNzPSIxMDUzNTI3OTMiIAkgIGRldmljZUlEPSIxMDUzNTI3OTMiIAkgIElE PSIxMDEwIiAJICBlcXVpcFR5cGU9InRyYWN0b3IiIAkgIGFsaWFzPSIxMTAwNjg4IgkgIC8 +CTxwb3NpdGlvbiBsYXQ9IjM1LjkxMjA4MyIgbG9uPSItNzguOTc3MTc2IiBwb3NUUz0iMj AxMi0xMC0wMlQyMToyNTo0MFoiLz4JPHBvc1R5cGU+MTwvcG9zVHlwZT4JPGlnbml0aW9uU 3RhdHVzPjE8L2lnbml0aW9uU3RhdHVzPgk8dHJpcFN0YXR1cz4wPC90cmlwU3RhdHVzPgk8 bHRkRGlz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V5Pjc0ODAxM Dwva2V5Pgk8ZXZlbnRUUz4yMDEyLTEwLTAzVDIxOjIwOjA3WjwvZXZlbnRUUz4JPGVxdWlw bWVudCAJICB1bml0QWRkcmVzcz0iMTA1MzUyNzkzIiAJICBkZXZpY2VJRD0iMTA1MzUyNzk zIiAJICBJRD0iMTAxMCIgCSAgZXF1aXBUeXBlPSJ0cmFjdG9yIiAJICBhbGlhcz0iMTAxMC IJICAvPgk8Y29tcGxldGlvbkNvZGU+MzwvY29tcGxldGlvbkNvZGU+CTxjb21wbGV0aW9uU 3RhdHVzPk1lc3NhZ2UgQWNrbm93bGVkZ2VkPC9jb21wbGV0aW9uU3RhdHVzPjwvVC43LjAz LjA+PC90cmFuPjwvdHJhbkJsb2NrPg==</transactions> <transactionIdOut>7941</transactionIdOut> </dequeue2Return> </p917:dequeue2Response> </soapenv:Body> </soapenv:Envelope> The <transactions> element decoded: <?xml version="1.0" encoding="UTF-8"?><tranBlock><tran ID="7939" companyID="XXXXX" auxID="0093368348"><T.7.01.0> <key>2675704</key> <eventTS>2012-10-03T21 :10:06Z</eventTS> <status>New</status> <inspectedEquipment>trailer</ins pectedEquipment> <equipment unitAddress="105352793" deviceID="105352793" ID="1010" equipType="tractor" alias="1100688" /> <position lat="35.912083" lon="-78.977176" posTS="2012-10-02T21:25:40Z"/> <posType>1</posType> <ignitionStatus>1</ ignitionStatus> <tripStatus>0</tripStatus> <ltdDistance>0</ltdDistance> <driverID>DONNIE</driverID> <driverAuthenticated>true</driverAuthentic ated> <hasDefects>true</hasDefects> <defects> <comments>Trailer is falling apart</comments> <defect>Coupling (King) Pin</defect> <defect>Landing Gear</defect> <defect>Brakes</defect> <defect>Other</defect> <defect>Reefer</defect> <defect>Doors</defect> </defects></T.7.01.0></tran><tran ID="7940" companyID="XXXXX" auxID="0093368348"><T.7.02.0> <key>748010</key> <eventTS>2012-10-03T21: 19:31Z</eventTS> <equipment unitAddress="105352793" deviceID="105352793" ID="1010" equipType="tractor" alias="1010" /> <completionCode>0</completionCode> <completionStatus></completionSta tus></T.7.02.0></tran><tran ID="7941" companyID="XXXXX" auxID="0093368348"><T.7.03.0> <key>748010</key> <eventTS>2012-10-03T21: 20:07Z</eventTS> <equipment unitAddress="105352793" deviceID="105352793" ID="1010" equipType="tractor" alias="1010" /> <completionCode>3</completionCode> <completionStatus>Message Acknowledged</completionStatus></T.7.03.0></tran></tranBlock> A snippet of documentation on the <transactions> element: The ESS High-Volume Transaction Block data type is implemented as the TransactionBlock2 class. It is returned by the [6]ESS High-Volume Dequeue method. The attributes of an ESS High Volume Transaction Block are: Attribute Description count This integer value contains the number of transactions that are contained in this block. Choose a host variable large enough for values up to five digits. transactionIdOut This long integer value contains the highest transaction ID returned in the transaction block. Choose a host variable large enough for values up to 17 digits. transactions An array of bytes containing the transactions that were retrieved by this call to dequeue. Choose a host variable large enough to receive up to 1mb or more worth of bytes in a single call. See the note below for the format of this byte array. The transaction block will contain [7]ESS Transactions. Also helpful in making use of the returned transaction block is the [8]ESS Transaction Schema. Note: The <transactions> element is defined in the WSDL as XML data type xsd:base64Binary. You will need to employ a base64Binary decoder to translate the transaction data into ASCII or Unicode. Some platforms have built-in functions to do this. .NET is one such example. Other platforms will require you download and use a library containing the base64Binary decoder. A Google search for your platform with the term "base64 decoder" will likely show several freely available algorithms for decoding base64Binary data. The algorithm is well defined and rather simple to replicate. Once decoded from Base64, the transactions will have a structure defined here: * [9]<tranBlock> Structure Definition I used WSDL2RPG and the attached wsdl to generate service program ESSSRV02 and rpg program ESSPGM02. The only change made to ESSSRV02 was to add the required soap security header since it is not included in the provided wsdl. A couple of minor changes to ESSPGM02 and I'm getting message data. Awesome! Now that I have the data, I am uncertain of how best to decode the Base64 binary and process the xml elements with in it. Here's what element <transactions> looks like in debug: TRANSACTIONS Ì_%ÎÁÊËÑ?>Á>Ä?ÀÑ>ÅíèãÈÊ/>â%?Ä,ÈÊ/>ñàÄ?_ø/>`ñàè(èëï/ÍÌñàè,Á `, ESPGM02 is currently generating error message: Unable to decode character at position 1. (Char=x'3C') Questions I've been trying to answer are: 1) How best to decode the <transactions> element 2) Once decoded, will parsing the result be best accomplished with HTTPAPI procedure: http_parse_xml_string() Any advice is greatly appreciated. Thanks in advance, Donnie References 1. http://schemas.xmlsoap.org/soap/envelope/ 2. http://schemas.xmlsoap.org/soap/encoding/ 3. http://www.w3.org/2001/XMLSchema 4. http://www.w3.org/2001/XMLSchema-instance 5. http://websvcs.otswebws/ 6. https://intinfo.myqualcomm.com/display/iWebInt/ESS+High-Volume+Dequeue 7. https://intinfo.myqualcomm.com/display/iWebInt/ESS+Transactions 8. https://intinfo.myqualcomm.com/display/iWebInt/Notice+of+Scheduled+ESS+Transaction+Type+Schema+Changes 9. https://intinfo.myqualcomm.com/display/iWebInt/Shared+Complex+Types#SharedComplexTypes-transactionblock
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://websvcs.otswebws" xmlns:impl="http://websvcs.otswebws" xmlns:intf="http://websvcs.otswebws" xmlns:tns2="http://datatype.otswebws" xmlns:tns3="http://exception.sharedws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <schema targetNamespace="http://websvcs.otswebws" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://datatype.otswebws"/> <element name="dequeueResponse"> <complexType> <sequence> <element name="dequeueReturn" nillable="true" type="tns2:TransactionBlock"/> </sequence> </complexType> </element> <element name="getSubscriberInfo"> <complexType> <sequence> <element name="subscriberID" type="xsd:int"/> </sequence> </complexType> </element> <element name="getSubscriberInfoResponse"> <complexType> <sequence> <element name="getSubscriberInfoReturn" nillable="true" type="tns2:SubscriberInfo"/> </sequence> </complexType> </element> <element name="dequeue2"> <complexType> <sequence> <element name="subscriberId" type="xsd:int"/> <element name="transactionIdIn" type="xsd:long"/> </sequence> </complexType> </element> <element name="dequeue2Response"> <complexType> <sequence> <element name="dequeue2Return" nillable="true" type="tns2:TransactionBlock2"/> </sequence> </complexType> </element> <element name="dequeue"> <complexType> <sequence> <element name="subscriberId" type="xsd:int"/> <element name="blockCount" type="xsd:int"/> <element name="transactionId" type="xsd:int"/> </sequence> </complexType> </element> </schema> <schema targetNamespace="http://datatype.otswebws" xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="TransactionBlock"> <sequence> <element name="count" type="xsd:int"/> <element name="transactions" type="xsd:base64Binary"/> </sequence> </complexType> <complexType name="SubscriberInfo"> <sequence> <element name="enqueueEnabled" type="xsd:boolean"/> <element name="enqueueCount" type="xsd:int"/> <element name="enqueueCountResetTime" nillable="true" type="xsd:string"/> <element name="enqueueEnabledTime" nillable="true" type="xsd:string"/> <element name="fullThreshold" type="xsd:int"/> <element name="lastDequeueTime" nillable="true" type="xsd:string"/> <element name="lastEnqueueTime" nillable="true" type="xsd:string"/> <element name="dequeueBlockCount" type="xsd:int"/> <element name="queueDepth" type="xsd:int"/> <element name="warnThreshold" type="xsd:int"/> </sequence> </complexType> <complexType name="TransactionBlock2"> <sequence> <element name="count" type="xsd:int"/> <element name="transactions" type="xsd:base64Binary"/> <element name="transactionIdOut" type="xsd:long"/> </sequence> </complexType> </schema> <schema targetNamespace="http://exception.sharedws" xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="WSException"> <sequence> <element name="message" nillable="true" type="xsd:string"/> </sequence> </complexType> <element name="WSException" nillable="true" type="tns3:WSException"/> </schema> </wsdl:types> <wsdl:message name="getSubscriberInfoResponse"> <wsdl:part element="intf:getSubscriberInfoResponse" name="parameters"/> </wsdl:message> <wsdl:message name="dequeueRequest"> <wsdl:part element="intf:dequeue" name="parameters"/> </wsdl:message> <wsdl:message name="dequeueResponse"> <wsdl:part element="intf:dequeueResponse" name="parameters"/> </wsdl:message> <wsdl:message name="getSubscriberInfoRequest"> <wsdl:part element="intf:getSubscriberInfo" name="parameters"/> </wsdl:message> <wsdl:message name="dequeue2Response"> <wsdl:part element="intf:dequeue2Response" name="parameters"/> </wsdl:message> <wsdl:message name="WSException"> <wsdl:part element="tns3:WSException" name="fault"/> </wsdl:message> <wsdl:message name="dequeue2Request"> <wsdl:part element="intf:dequeue2" name="parameters"/> </wsdl:message> <wsdl:portType name="OTSWebSvcs"> <wsdl:operation name="dequeue"> <wsdl:input message="intf:dequeueRequest" name="dequeueRequest"/> <wsdl:output message="intf:dequeueResponse" name="dequeueResponse"/> <wsdl:fault message="intf:WSException" name="WSException"/> </wsdl:operation> <wsdl:operation name="getSubscriberInfo"> <wsdl:input message="intf:getSubscriberInfoRequest" name="getSubscriberInfoRequest"/> <wsdl:output message="intf:getSubscriberInfoResponse" name="getSubscriberInfoResponse"/> <wsdl:fault message="intf:WSException" name="WSException"/> </wsdl:operation> <wsdl:operation name="dequeue2"> <wsdl:input message="intf:dequeue2Request" name="dequeue2Request"/> <wsdl:output message="intf:dequeue2Response" name="dequeue2Response"/> <wsdl:fault message="intf:WSException" name="WSException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="OTSWebSvcsSoapBinding" type="intf:OTSWebSvcs"> <wsaw:UsingAddressing wsdl:required="false" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"/> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="dequeue"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="dequeueRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="dequeueResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="WSException"> <wsdlsoap:fault name="WSException" use="literal"/> </wsdl:fault> </wsdl:operation> <wsdl:operation name="getSubscriberInfo"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getSubscriberInfoRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="getSubscriberInfoResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="WSException"> <wsdlsoap:fault name="WSException" use="literal"/> </wsdl:fault> </wsdl:operation> <wsdl:operation name="dequeue2"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="dequeue2Request"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="dequeue2Response"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="WSException"> <wsdlsoap:fault name="WSException" use="literal"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:service name="OTSWebSvcsService"> <wsdl:port binding="intf:OTSWebSvcsSoapBinding" name="OTSWebSvcs"> <wsdlsoap:address location="https://www.myqualcomm.com:443/otsWebWS/services/OTSWebSvcs"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Attachment:
ESSSRV02.rpgle
Description: Binary data
Attachment:
ESSPGM02.rpgle
Description: Binary data
----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------