[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] Simple Soap Action . Used Example18 for a template (HTTP/1.1 500 Internal Server Error )



Hello Ron.

I've attached a copy of the program we've been using for a few years that is doing, what I believe, is what you need to do.
This is a Canadian Version - Qualcomm via SHAW Tracking - so it will be a bit different that the US / Qualcomm version, but very similar.
You will have to replace "yourUsername", "yourPassword", and "yourSubcriberId" with yours of course.
Hope this helps.

------------------------------------------------------------------------------------------------------
Paul Reid
Application Developer III
Erb Group of Companies | 290 Hamilton Road | New Hamburg, Ontario | N3A 1A2
Phone: 519.662.6133 ext. 2363
Web: http://www.erbgroup.com/


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ron Koontz
Sent: Monday, June 05, 2017 8:33 AM
To: FTPAPI/HTTPAPI mailing list
Subject: Re: [Ftpapi] Simple Soap Action . Used Example18 for a template (HTTP/1.1 500 Internal Server Error )

This works great.  Thanks a million.. This makes more sense now.  I still have questions but I will figure them out on my own I hope ( I learn better that way ) They have it coded in a Base 64 bit.  So now I need to convert it to XML.. There isn't by chance anything out there like that is there?


Thanks
Ron Koontz

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Friday, June 02, 2017 7:25 PM
To: FTPAPI/HTTPAPI mailing list
Subject: Re: [Ftpapi] Simple Soap Action . Used Example18 for a template (HTTP/1.1 500 Internal Server Error )

Hello again,

As promised, here is the same program converted to free format, using the newer http_req() API (requires a current version of HTTPAPI) and using RPG's XML-INTO.  Notice that doing it this way, I don't need to use any pointers... which cleans things up a bit, imho.

The basic idea is the same, though.

-SK

On 6/2/2017 5:16 PM, Scott Klement wrote:
> Ron,
>
> I tried piecing together the various pieces of information that you
> sent.  In one case, you sent the whole program, but the XML wasn't
> right (it stopped after the Nonce).  In one case you had the security
> info where the soap action should've been (as previously discussed).
> In one place you created the document in what might've been right, but
> didn't have the rest of the program... and when I looked at the
> document, I found missing parts of the XML, missing spaces, etc.
>
> I ended up giving up on piecing together your code, but instead
> guessed at where the WSDL for this service would be...    and I
> guessed right, so I was able to run this example in SoapUI.   Once I
> did that, I copied and pasted it into my own program and tried it out
> (using the userid/password that you sent me off-list) and it worked
> perfectly for me.
>
> Also, none of your examples had the SoapAction right.  The SoapAction
> (according to SoapUI) was just two double quotes -- an empty string in
> double quotes, that is.  I think because this didn't work, you got
> confused and tried all sorts of irrelevant things. And since the
> service doesn't report a meaningful error, it was hard to tell what
> the problem was.
>
> ANYWAY (this turned out more long-winded than I thought)...
>
> I've attached the program that worked for me.  Let me know if this
> works for you.
>
> Later tonight if I have time, I'll re-do it using the newer
> capabilities in the newer HTTPAPI, and using IBM's built-in XML parser
> so you can see the difference.
>
> -SK
>
>
> On 6/2/2017 2:27 PM, Ron Koontz wrote:
>> The CRLF was it but now back to the same
>> "HTTP/1.1 500 Internal Server Error"
>>
>>
>> Thanks
>> Ron Koontz
>>
>>
>> -----Original Message-----
>> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott
>> Klement
>> Sent: Friday, June 02, 2017 2:58 PM
>> To: FTPAPI/HTTPAPI mailing list
>> Subject: Re: [Ftpapi] Simple Soap Action . Used Example18 for a
>> template (HTTP/1.1 500 Internal Server Error )
>>
>> Ron,
>>
>> HTTPAPI supports up to 16 kb for the soap action parameter.  Are you
>> saying that your soap action is larger than 16 kb?!
>>
>> Or are you using an extremely old version of HTTPAPI?  (The size was
>> increased from 64 bytes to 16 kb in 2012.)
>>
>> The callback method (your "add_soapaction" thing) will still work, too.
>> But, it's easier to make a mistake with that...  I suspect that's
>> what happened in your case.  Maybe you didn't send the CRLF at the
>> end of the header or something like that?
>>
>> Its very hard for us to tell you what is wrong when you don't show us
>> what you did.
>>
>> -SK
>>
>>
>>
>>
>> On 6/2/2017 9:48 AM, Ron Koontz wrote:
>>> So after looking into this in debug I noticed my SOAP field is not
>>> big enough.. So I looked at Example 20 to send a “bigger” set of
>>> soap action.
>>>
>>> It uses the “Add_SoapAction” to add the header stuff then the rest.
>>>
>>> Its getting close, however I’m getting a “SetError() #43:
>>> CommSSL_Read:  time-out!    “
>>>
>>> So I’m not sure where to go from here.  Any ideas?
>>>
>>> Thanks
>>>
>>> Ron Koontz
>>>
>>> *From:*ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] *On Behalf Of *Pargat
>>> Singh
>>> *Sent:* Thursday, June 01, 2017 3:28 PM
>>> *To:* FTPAPI/HTTPAPI mailing list
>>> *Subject:* Re: [Ftpapi] Simple Soap Action . Used Example18 for a
>>> template (HTTP/1.1 500 Internal Server Error )
>>>
>>> Just checking, are you able to connect to this URL from your IBMi or
>>> you need to use proxy?
>>>
>>> Thanks,
>>>
>>> Pargat
>>>
>>> On Thu, Jun 1, 2017 at 2:21 PM, Ron Koontz <rkoontz@xxxxxxxxx
>>> <mailto:rkoontz@xxxxxxxxx>> wrote:
>>>
>>> You are right.  My bad.  I actually sent the wrong stuff.  The xxxx
>>> is my username and password.
>>> I just got the SOAPUI today so I'm playing with that as well.
>>>
>>> Here is the code and attached is the debug
>>>
>>> SOAP =
>>>   '<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>'
>>> +'<SOAP:Envelope'
>>> +'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";'
>>> +'xmlns:web="http://websvcs.otswebws";>'
>>> +'<SOAP:Header>'
>>> +'<wsse:Security soapenv:mustUnderstand="1"'
>>> +'<xmlns:wsse="http://docs.oasis-open.org/wss/'
>>> +'2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"'
>>> +'xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/'
>>> +'oasis-200401-wss-wssecurity-utility-1.0.xsd">'
>>> +'<wsse:UsernameToken wsu:Id="UsernameToken'
>>> +'-01B51377495EE27AFE14613627051441">'
>>> +'<wsse:Username>xxxxxx</wsse:Username>'
>>> +'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/'
>>> +'/oasis-200401-wss-username-token-profile-1.0#Password'
>>> +'Text">xxxxxxx</wsse:Password>'
>>> +'wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01'
>>> +'/oasis-200401-wss-soap-message-security'
>>> +'-1.0#Base64Binary">nvLVj+qPJSJ2+eWuSvjtlg==</wsse:Nonce>'
>>>
>>> http_debug(*ON);
>>>
>>> rc = http_url_post_xml(
>>> 'https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs'
>>>                    : %addr(SOAP) + 2
>>>                    : %len(SOAP)
>>>                    : *NULL
>>>                    : %paddr(Incoming)
>>>                    : %addr(rate)
>>>                    : HTTP_TIMEOUT
>>>                    : HTTP_USERAGENT
>>>                    : '/tmp/geoptest.xml'
>>> :'https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs'
>>> <https://services.omnitracs.com/otsWebWS/services/OTSWebSvcs%27>);
>>>
>>> Thanks
>>> Ron Koontz
>>>
>>>
>>> -----Original Message-----
>>> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> <mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx>
>>> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> <mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx>] On Behalf Of Scott
>>> Klement
>>> Sent: Thursday, June 01, 2017 2:10 PM
>>> To: FTPAPI/HTTPAPI mailing list
>>>
>>> Subject: Re: [Ftpapi] Simple Soap Action . Used Example18 for a
>>> template (HTTP/1.1 500 Internal Server Error )
>>>
>>> Are you sure this is the correct SOAP message for this web service?
>>> It refers to WebserviceX.NET, which is highly suspicious...
>>>
>>> You should be running the WSDL file through a tool to see what the
>>> SOAP message should look like.  Do NOT just copy another unrelated
>>> web service's SOAP message and assume it's correct.
>>>
>>> A good tool for this is SoapUI.
>>>
>>>
>>> On 6/1/2017 12:37 PM, Ron Koontz wrote:
>>>> Here is my debug dump.
>>>>
>>>> Thanks
>>>>
>>>> Ron Koontz
>>>>
>>>> *From:*ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> <mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx>
>>>> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
>>> <mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx>] *On Behalf Of
>>> *Pargat
>>>> Singh
>>>> *Sent:* Thursday, June 01, 2017 1:15 PM
>>>> *To:* FTPAPI/HTTPAPI mailing list
>>>> *Subject:* Re: [Ftpapi] Simple Soap Action . Used Example18 for a
>>>> template (HTTP/1.1 500 Internal Server Error )
>>>>
>>>> Ron,
>>>>
>>>> Can you advise how are you invoking WS request?
>>>>
>>>> Thanks
>>>>
>>>> Pargat
>>>>
>>>> On Jun 1, 2017 12:09 PM, "Ron Koontz" <rkoontz@xxxxxxxxx
>>> <mailto:rkoontz@xxxxxxxxx>
>>>> <mailto:rkoontz@xxxxxxxxx <mailto:rkoontz@xxxxxxxxx>>> wrote:
>>>>
>>>> Hello all,
>>>>
>>>> I’m getting a HTTP/1.1 500 Internal Server Error …
>>>>
>>>> I not sure 100% what is wrong.  I’m new to sending the SOAP stuff
>>>> this way.  Ideas?
>>>>
>>>> Protocol Used: TLS Version 1
>>>>
>>>> http_persist_post(): entered
>>>>
>>>> http_long_ParseURL(): entered
>>>>
>>>> do_post(): entered
>>>>
>>>> POST /qtracsWebWS/services/QTWebSvcs HTTP/1.1
>>>>
>>>> POST /qtracsWebWS/services/QTWebSvcs HTTP/1.1
>>>>
>>>> Host: www.cnrportal.com <http://www.cnrportal.com>
>>> <http://www.cnrportal.com>
>>>> User-Agent: http-api/1.23
>>>>
>>>> Content-Type: /tmp/geoptest.xml
>>>>
>>>> SOAPAction:
>>>> https://www.cnrportal.com/qtracsWebWS/services/QTWebSvcs
>>>>
>>>> Expect: 100-continue
>>>>
>>>> Content-Length: 604
>>>>
>>>> recvresp(): entered
>>>>
>>>> HTTP/1.1 100 Continue
>>>>
>>>> SetError() #13: HTTP/1.1 100 Continu
>>>>
>>>> senddoc(): entered
>>>>
>>>> <?xml version="1.0" encoding="iso-88………….much other stuff here
>>>>
>>>> recvresp(): entered
>>>>
>>>> HTTP/1.1 500 Internal Server Error
>>>>
>>>> Date: Thu, 01 Jun 2017 15:37:14 GMT
>>>>
>>>> Date: Thu, 01 Jun 2017 15:37:14 GMT
>>>>
>>>> X-Powered-By: Servlet/3.0
>>>>
>>>> Content-Length: 399
>>>>
>>>> Cneonction: close
>>>>
>>>> Content-Type: text/xml; charset=utf-8
>>>>
>>>> Content-Language: en-US
>>>>
>>>> SetError() #13: HTTP/1.1 500 Internal
>>>>
>>>> recvdoc parms: identity 399
>>>>
>>>> header_load_cookies() entered
>>>>
>>>> recvdoc(): entered
>>>>
>>>> SetError() #0:
>>>>
>>>> <soapenv:Envelope xmlns:soapenv="http…other stuff
>>>>
>>>> SetError() #13: HTTP/1.1 500 Internal
>>>>
>>>> http_close(): entered
>>>>
>>>> http_persist_open(): entered
>>>>
>>>> http_long_ParseURL(): entered
>>>>
>>>>
>>>>
>>>>
>>>> *Ron Koontz | IT Manager | Continental Express, Inc*
>>>>
>>>> *10450 State Rt 47 W Sidney, Ohio 45365*
>>>>
>>>> (: Direct: (937) 419.8118 <tel:%28937%29%20419-8118>*| *(: Tel
>>>> (800)
>>>> 497.2100 x118 <tel:%28800%29%20497-2100>*|*Ê: Fax (937) 498.2155
>>>> <tel:%28937%29%20498-2155>**
>>>>
>>>> *:_rkoontz@xxxxxxxxx <mailto:rkoontz@xxxxxxxxx>
>>> <mailto:rkoontz@xxxxxxxxx <mailto:rkoontz@xxxxxxxxx>>_ Visit us on
>>> the
>>> web:
>>>> www.ceioh.com <http://www.ceioh.com> <http://www.ceioh.com/> FB
>>>> <https://www.facebook.com/pages/Continental-Express-Inc/39497029058
>>>> 2
>>>> 85
>>>> 5>Twitter
>>>> <https://twitter.com/CEIOHIO>
>>>>
>>>> -------------------------------------------------------------------
>>>> -
>>>> --
>>>> --
>>>>
>>>>
>>>> The information contained in this e-mail is intended only for the
>>>> individual or entity to whom it is addressed. Its contents
>>>> (including any attachments) may contain confidential and/or
>>>> privileged information. If you are not an intended recipient you
>>>> shall not use, disclose, disseminate, copy or print its contents.
>>>> If you receive this e-mail in error, please notify the sender by
>>>> reply e-mail and delete and destroy the message. Continental Express, Inc.
>>>> and its subsidiaries and affiliates will not be held liable for the
>>>> unintended or unauthorized use of any information contained in this
>>>> email or as a result of any additions or deletions of information
>>>> originally contained in this email.
>>>>
>>>>
>>>> --
>>>> _______________________________________________
>>>> Ftpapi mailing list
>>>> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
>>>> <mailto:Ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
>>> <mailto:Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
>>> <mailto:Ftpapi@xxxxxxxxxxxxxxxxxxxxxx>>
>>>> http://scottklement.com/mailman/listinfo/ftpapi
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> -
>>>> --
>>>> --
>>>>
>>>> The information contained in this e-mail is intended only for the
>>>> individual or entity to whom it is addressed. Its contents
>>>> (including any attachments) may contain confidential and/or
>>>> privileged information. If you are not an intended recipient you
>>>> shall not use, disclose, disseminate, copy or print its contents.
>>>> If you receive this e-mail in error, please notify the sender by
>>>> reply e-mail and delete and destroy the message. Continental Express, Inc.
>>>> and its subsidiaries and affiliates will not be held liable for the
>>>> unintended or unauthorized use of any information contained in this
>>>> email or as a result of any additions or deletions of information
>>>> originally contained in this email.
>>>>
>>>>
>>> --
>>> _______________________________________________
>>> Ftpapi mailing list
>>> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx <mailto:Ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
>>> http://scottklement.com/mailman/listinfo/ftpapi
>>>
>>> ________________________________
>>>
>>>
>>> The information contained in this e-mail is intended only for the
>>> individual or entity to whom it is addressed. Its contents
>>> (including any attachments) may contain confidential and/or
>>> privileged information. If you are not an intended recipient you
>>> shall not use, disclose, disseminate, copy or print its contents. If
>>> you receive this e-mail in error, please notify the sender by reply
>>> e-mail and delete and destroy the message. Continental Express, Inc.
>>> and its subsidiaries and affiliates will not be held liable for the
>>> unintended or unauthorized use of any information contained in this
>>> email or as a result of any additions or deletions of information
>>> originally contained in this email.
>>>
>>>
>>> --
>>> _______________________________________________
>>> Ftpapi mailing list
>>> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx <mailto:Ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
>>> http://scottklement.com/mailman/listinfo/ftpapi
>>>
>>>
>>> --------------------------------------------------------------------
>>> --
>>> --
>>>
>>> The information contained in this e-mail is intended only for the
>>> individual or entity to whom it is addressed. Its contents
>>> (including any attachments) may contain confidential and/or
>>> privileged information. If you are not an intended recipient you
>>> shall not use, disclose, disseminate, copy or print its contents. If
>>> you receive this e-mail in error, please notify the sender by reply
>>> e-mail and delete and destroy the message. Continental Express, Inc.
>>> and its subsidiaries and affiliates will not be held liable for the
>>> unintended or unauthorized use of any information contained in this
>>> email or as a result of any additions or deletions of information
>>> originally contained in this email.
>>>
>>>
>> --
>> _______________________________________________
>> Ftpapi mailing list
>> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
>> http://scottklement.com/mailman/listinfo/ftpapi
>>
>> ________________________________
>>
>> The information contained in this e-mail is intended only for the
>> individual or entity to whom it is addressed. Its contents (including
>> any attachments) may contain confidential and/or privileged
>> information. If you are not an intended recipient you shall not use,
>> disclose, disseminate, copy or print its contents. If you receive
>> this e-mail in error, please notify the sender by reply e-mail and
>> delete and destroy the message. Continental Express, Inc. and its
>> subsidiaries and affiliates will not be held liable for the
>> unintended or unauthorized use of any information contained in this
>> email or as a result of any additions or deletions of information
>> originally contained in this email.
>
>
>


________________________________

The information contained in this e-mail is intended only for the individual or entity to whom it is addressed. Its contents (including any attachments) may contain confidential and/or privileged information. If you are not an intended recipient you shall not use, disclose, disseminate, copy or print its contents. If you receive this e-mail in error, please notify the sender by reply e-mail and delete and destroy the message. Continental Express, Inc. and its subsidiaries and affiliates will not be held liable for the unintended or unauthorized use of any information contained in this email or as a result of any additions or deletions of information originally contained in this email.
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi
     H BNDDIR('DSBNDDIR':'HTTPAPI':'QC2LE':'UTBNDDIR')
      *------------------------------------------------------------------------*
      * DSRPERFMON - Download Performance Monitoring data from SHAW.           *
      * Created by : Paul Reid                                                 *
      * Created on : Jan 08,2014                                               *
      * Currently this program receives two differnt transactions from the web *
      * service: 1 : T.4.01.0 - PM Performance Data Transaction Type.          *
      *          2 : T.3.02.0 - Critical Event Reporting (CER).                *
      * The data from both of these transactions is written out to file        *
      * DSPPERFMON.                                                            *
      *------------------------------------------------------------------------*
      * Prototype call to this program:                                        *
      *------------------------------------------------------------------------*
      *
     D DSRPERFMON      PR                  extpgm('DSRPERFMON')
      *
     D DSRPERFMON      PI
      *
      *------------------------------------------------------------------------*
      * Prototypes:                                                            *
      *------------------------------------------------------------------------*
      *
      * Scott Klement's HTTPAPI.
      /include qrpglesrc,HTTPAPI_H
      *
      * Scott Klement's Base64 encoder/decoder.
      /include qrpglesrc,BASE64_H
      *
      * Write out performance monitoring data to out database.
      /include qcopysrc,DSTPERFUP
      *
      * For sending email notifications.
      /include qcopysrc,UTTEMAIL
      *
      *------------------------------------------------------------------------*
      * incoming - Parse response from SHAW.                                   *
      *------------------------------------------------------------------------*
      *
     D incoming...
     D                 PR
     D   userData...
     D                                8F
     D   nestingDepth...
     D                               10I 0 value
     D   elementName...
     D                             1024A   varying const
     D   elementPath...
     D                            24576A   varying const
     D   elementValue...
     D                                     likeds(Xmlstring_t)
     D   attributes...
     D                                 *   dim(32767)
     D                                     const options(*varsize)
      *
      *------------------------------------------------------------------------*
      * embedded - Parse the embedded XML.                                     *
      *------------------------------------------------------------------------*
      *
     D embedded...
     D                 PR
     D   userData...
     D                                 *   value
     D   nestingDepth...
     D                               10I 0 value
     D   elementName...
     D                             1024A   varying const
     D   elementPath...
     D                            24576A   varying const
     D   elementValue...
     D                            65535A   varying const
     D   attributes...
     D                                 *   dim(32767)
     D                                     const options(*varsize)
      *
      *------------------------------------------------------------------------*
      * All data required to write a record to DSPPERFMON.                     *
      *------------------------------------------------------------------------*
      *
     D allPerfDataDS...
     D                 DS                  likeDS(DSRMPERFUP_allPerfDataDS)
      *
      *------------------------------------------------------------------------*
      * Errors on procedure call when writing to DSPPERFMON.                   *
      *------------------------------------------------------------------------*
      *
     D errorInfo...
     D                 DS                  likeDS(UTTERRDS_errorDS)
      *
      *------------------------------------------------------------------------*
      * Receive data with pointers into a data structure.                      *
      *------------------------------------------------------------------------*
      *
     D XmlString_t...
     D                 DS                  qualified Template
     D  data                           *
     D  len                          10I 0
      *
      *------------------------------------------------------------------------*
      * Last transaction ID.                                                   *
      *------------------------------------------------------------------------*
      *
     D ##PERFMON...
     D                 S             17  0 dtaara(##PERFMON)
      *
      *------------------------------------------------------------------------*
      * Local variables in alphabetical order:                                 *
      *------------------------------------------------------------------------*
      *
     D decodedData...
     D                 S               A   len(2000000) varying
     D decodedLength...
     D                 S             10I 0
     D errorMessage...
     D                 S            100A   inz(*blanks)
     D parserLog...
     D                 S           1000A   varying
     D peErrorNo...
     D                 S             10I 0 inz(*zeros)
     D rc1...
     D                 S             10I 0
     D rc2...
     D                 S             10I 0
     D responseLog...
     D                 S           1000A   varying
     D scMsg...
     D                 S            102A   inz(*blanks)
     D sndGroup...
     D                 S             10A   inz('OPSSUPPORT')
     D sndMessage...
     D                 S           1000A   inz(*blanks)
     D sndSubject...
     D                 S             50A   inz(*blanks)
     D soapRequest...
     D                 S          32767A   varying
     D soapHeader...
     D                 S          32767A   varying
     D soapBody...
     D                 S          32767A   varying
     D subscriberId...
     D                 S              9A   varying
     D transCount...
     D                 S              5P 0 inz(*zeros)
     D transIdIn...
     D                 S             17A   varying
     D transIdOut...
     D                 S             17  0 inz(*zeros)
     D userData...
     D                 S              8F
     D var...
     D                 S             50A   based(p_var)
      *
      *------------------------------------------------------------------------*
      * Mainline:                                                              *
      *------------------------------------------------------------------------*
      *
      /free

          // Assemble an XML SOAP request to be posted to SHAW's Web Service.
          exsr assembleSOAPheader;
          exsr assembleSOAPbody;
          soapRequest = %trim(soapHeader) + %trim(soapBody);

          // Turn on the debugger before the post.
          responseLog = '/PerformanceMonitoring/responseLog.txt';
          http_debug(*on : responseLog);

          // Change the way the XML parser returns the data. We need
          // to return pointers because the amount of data is so large.
          http_XmlReturnPtr(*on);

          // Post XML SOAP request.
          rc1 = http_url_post_xml(
               'https://www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
              : %addr(soapRequest) + 2
              : %len(soapRequest)
              : *NULL
              : %paddr(incoming)
              : %addr(userData)
              : HTTP_TIMEOUT
              : HTTP_USERAGENT
              : 'text/xml'
              : 'http://www.qualcomm.com/dequeue2');

          // Change the XML parser so that no longer just returns pointers.
          http_XmlReturnPtr(*off);

          // Turn off the debugger.
          http_debug(*off);

          // When we recieve a valid response rc1 = 1.
          if rc1 = 1;

             // Only continue process if data was returned (transCount > 0).
             if transCount > 0;

                // Parse the decoded XML eturned from SHAW.
                exsr parseDecodedXML;
             endif;

          // If an error occured while consuming the Web Service then send
          // a message to OPS support.
          else;
             scMsg      = http_error(peErrorNo);
             sndSubject = 'Error retrieving performace data from SHAW. #1';
             sndMessage = 'SHAW Web Service dequeue2 returned an error' +
                          ' &N ' +
                          'Run date . . . :' +
                          %trim(%char(%date())) +
                          ' &N ' +
                          'Run time . . . :' +
                          %trim(%char(%time())) +
                          ' &N ' +
                          'transCount . . :' +
                          %trim(%char(transCount)) +
                          ' &N ' +
                          'transIdOut . . :' +
                          %trim(%char(transIdOut)) +
                          ' &N ' +
                          'Error returned :' +
                          %trim(errorMessage) +
                          ' &N ' +
                          'http_error() . :' +
                          %trim(scMsg) +
                          ' &N ' +
                          'peErrorNo. . . :' +
                          %trim(%char(peErrorNo)) +
                          ' &N ' +
                          'Please Investigate!' +
                          ' &N ' +
                          'Program name = DSRPERFMON' +
                          ' &N ' +
                          'See log /PerformanceMonitoring/responseLog.txt';
             exsr eMailErrorMessage;
          endif;

          // The End.
          *inlr = *on;
          return;

       //-----------------------------------------------------------------------*
       // Parse the decoded XML.                                                *
       //-----------------------------------------------------------------------*

          begsr parseDecodedXML;

             // Initialize all data fields in file DSPPERFMON.
             clear allPerfDataDS;

             // Turn on the dubugger before parsing the embedded XML.
             parserLog = '/PerformanceMonitoring/parserLog.txt';
             http_debug(*on : parserLog);

             // Parse the XML repsponse embedded in the "transactions" element.
             rc2 = http_parse_xml_string(%addr(decodedData: *DATA)
                                       : %len(decodedData)
                                       : 819
                                       : *NULL
                                       : %paddr(embedded)
                                       : *NULL);

             // turn off the debugger.
             http_debug(*off);

             // If the parsing was not successful send an error to Ops support.
             if rc2 <> 0;
                scMsg      = http_error(peErrorNo);
                sndSubject = 'Error parsing performace data from SHAW. #2';
                sndMessage = 'SHAW Web Service dequeue2 parsing error' +
                             ' &N ' +
                             'Run date . . . :' +
                             %trim(%char(%date())) +
                             ' &N ' +
                             'Run time . . . :' +
                             %trim(%char(%time())) +
                             ' &N ' +
                             'transCount . . :' +
                             %trim(%char(transCount)) +
                             ' &N ' +
                             'transIdOut . . :' +
                             %trim(%char(transIdOut)) +
                             ' &N ' +
                             'Error returned :' +
                             %trim(errorMessage) +
                             ' &N ' +
                             'http_error() . :' +
                             %trim(scMsg) +
                             ' &N ' +
                             'peErrorNo. . . :' +
                             %trim(%char(peErrorNo)) +
                             ' &N ' +
                             'Please Investigate!' +
                             ' &N ' +
                             'Program name = DSRPERFMON' +
                             ' &N ' +
                             'See log /PerformanceMonitoring/parserLog.txt';
                exsr eMailErrorMessage;

             // Output the last transaction ID to the data area. The next time
             // we run this process we will start at this transaction number.
             else;
                ##PERFMON = transIdOut + 1;
                out ##PERFMON;
             endif;

          endsr;

       //-----------------------------------------------------------------------*
       // Assemble SOAP header XML request. Username and password have been     *
       // hard coded as they are not expected to change.                        *
       //-----------------------------------------------------------------------*

          begsr assembleSOAPheader;

          soapHeader =
          '<?xml version="1.0" encoding="utf-8"?>'
          +' <soap:Envelope'
          +' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";'
          +' xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing";'
          +' xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
                       +'wss-wssecurity-secext-1.0.xsd"'
          +' xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
                      +'wss-wssecurity-utility-1.0.xsd"'
          +' xmlns:xsd="http://www.w3.org/2001/XMLSchema";'
          +' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>'
          +'<soap:Header>'
          +'<wsse:Security soap:mustUnderstand="1" >'
          +'<wsse:UsernameToken>'
          +'<wsse:Username>yourUserName</wsse:Username>'
          +'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/'
                               +'oasis-200401-wss-username-token-profile-1.0#'
                               +'PasswordText">yourPassword</wsse:Password>'
          +'</wsse:UsernameToken>'
          +'</wsse:Security>'
          +'</soap:Header>';

          endsr;

       //-----------------------------------------------------------------------*
       // Assemble SOAP body XML request. Subsciber ID has been hard coded as   *
       // is not expected to change.                                            *
       //-----------------------------------------------------------------------*

          begsr assembleSOAPbody;

          subscriberId    = 'yourSubcriberId';
          in *lock ##PERFMON;
          transIdIn = %trim(%char(##PERFMON));

             soapBody =
              '<soap:Body>'
                +'<dequeue2>'
                   +'<subscriberId>'
                      + subscriberId
                   +'</subscriberId>'
                   +'<transactionIdIn>'
                      + transIdIn
                   +'</transactionIdIn>'
                +'</dequeue2>'
             +'</soap:Body>'
          +'</soap:Envelope>';

          endsr;

       //-----------------------------------------------------------------------*
       // eMail error message.                                                  *
       //-----------------------------------------------------------------------*

          begsr eMailErrorMessage;

             UTRMEMAIL_sendSimpleToGroup(sndGroup
                                       : sndSubject
                                       : sndMessage);

          endsr;

      /end-free
      *
      *------------------------------------------------------------------------*
      * incoming - Parse XML response from SHAW.                               *
      *------------------------------------------------------------------------*
      *
     P incoming...
     P                 B
      *
     D incoming...
     D                 PI
     D   userData...
     D                                8F
     D   nestingDepth...
     D                               10I 0 value
     D   elementName...
     D                             1024A   varying const
     D   elementPath...
     D                            24576A   varying const
     D   elementValue...
     D                                     likeds(XmlString_t)
     D   attributes...
     D                                 *   dim(32767)
     D                                     const options(*varsize)
      *
      /free

          // The number of transcations returbed on this run.
          if elementName = 'count';
             p_var = elementValue.data;
             transCount = %dec(%subst(var:1:elementValue.len):5:0);

          // The data in the 'transactions' element
          // is a base64 encoded XML document.
          elseif elementName = 'transactions';
             %len(decodedData) = %len(decodedData : *MAX);
             decodedLength = base64_decode( elementValue.data
                                          : elementValue.len
                                          : %addr(decodedData : *data)
                                          : %len(decodedData : *MAX) );
             %len(decodedData) = decodedLength;

          // The last transaction ID that was returned.
          elseif elementName = 'transactionIdOut';
             p_var = elementValue.data;
             transIdOut = %dec(%subst(var:1:elementValue.len):17:0);

          elseif elementName = 'soap:Text';
             p_var = elementValue.data;
             errorMessage = %subst(var:1:elementValue.len);
          endif;

      /end-free
      *
     P incoming        E
      *
      *------------------------------------------------------------------------*
      * embedded - Parse the embedded XML and write to our database.           *
      *------------------------------------------------------------------------*
      *
     P embedded...
     P                 B
      *
     D embedded...
     D                 PI
     D   userData...
     D                                 *   value
     D   nestingDepth...
     D                               10I 0 value
     D   elementName...
     D                             1024A   varying const
     D   elementPath...
     D                            24576A   varying const
     D   elementValue...
     D                            65535A   varying const
     D   attributes...
     D                                 *   dim(32767)
     D                                     const options(*varsize)
      *
      * Local variables:
     D attributeCount...
     D                 S             10I 0
     D attributeName...
     D                 S           1024A   varying
     D attributeValue...
     D                 S          65535A   varying
      *
      * General work fields.
     D mobileType...
     D                 S              2A   inz(*blanks)
     D posType...
     D                 S              1A   inz(*blanks)
     D ignitionStatus...
     D                 S              1A   inz(*blanks)
     D tripStatus...
     D                 S              1A   inz(*blanks)
     D faultFlag...
     D                 S              1A   inz(*blanks)
     D registeredDriver...
     D                 S              1A   inz(*blanks)
      *
      * Work fields used to covert GMT (Greenwich Mean Time) to
      * EST (Eastern Standard Time).
     D gmtDateTime...
     D                 S             20A   inz(*blanks)
     D isoAlphaDateTime...
     D                 S             26A   inz(*blanks)
     D timeStamp...
     D                 S               Z   inz(Z'0001-01-01-00.00.00.000000')
     D isoDate...
     D                 S               D   inz(*loval)
     D isoTime...
     D                 S               T   inz(*loval)
      *
      * Work fields for a Proximity location:
     D  proxCity...
     D                 S             10A   inz(*blanks)
     D  proxDist...
     D                 S              7A   inz(*blanks)
     D  proxDir...
     D                 S              3A   inz(*blanks)
     D  proxPlac...
     D                 S             10A   inz(*blanks)
     D  proxPlTp...
     D                 S              4A   inz(*blanks)
     D  proxStPr...
     D                 S              2A   inz(*blanks)
     D  proxPost...
     D                 S              6A   inz(*blanks)
     D  proxCoun...
     D                 S              2A   inz(*blanks)
      *
      /free

          // Transaction ID - Container for a single transaction (aka: event)
          // of any type.
          select;
          when elementName = 'tran';
               attributeCount = 1;
               dow http_nextXmlAttr(attributes
                                  : attributeCount
                                  : attributeName
                                  : attributeValue);
                   if attributeName = 'ID';
                        allPerfDataDS.pmTransID# = %trim(attributeValue);
                   endif;
               enddo;

               // Write a new record for each T.4.01.0 or
               // T.3.02.0 transaction received.
               if allPerfDataDS.pmTranType = 'T.4.01.0' or
                  allPerfDataDS.pmTranType = 'T.3.02.0';
                  DSRMPERFUP_writeAllPerformanceData(
                             allPerfDataDS :
                             errorInfo);
               endif;

               // Clear fields used to write DSPPERFMON records.
               clear allPerfDataDS;

               // Clear general work fields.
               mobileType       = *blanks;
               posType          = *blanks;
               ignitionStatus   = *blanks;
               tripStatus       = *blanks;
               faultFlag        = *blanks;
               registeredDriver = *blanks;

          // T.4.01.0 - PM Performance Data Transaction Type.
          // T.3.02.0 - Critical Event Reporting (CER) Data Transaction Type.
          when elementName = 'T.4.01.0';
               allPerfDataDS.pmTranType = 'T.4.01.0';
          when elementName = 'T.3.02.0';
               allPerfDataDS.pmTranType = 'T.3.02.0';

          // Date and Time when the event took place.
          when elementName = 'eventTS';
               gmtDateTime = *blanks;
               gmtDateTime = %trim(elementValue);
               exsr convertGMTtoEST;
               allPerfDataDS.pmEvntDate = isoDate;
               allPerfDataDS.pmEvntTime = isoTime;

          // Uniquely define a piece of equipment (truck).
          when elementName = 'equipment';
               attributeCount = 1;
               dow http_nextXmlAttr(attributes
                                  : attributeCount
                                  : attributeName
                                  : attributeValue);

                   // Unique customer-defined equipment identifier.
                   // In our system this is our truck number.
                   select;
                   when attributeName = 'ID';
                        allPerfDataDS.pmEqpID = %trim(attributeValue);

                   // Unique manufacture-assigned address of the
                   // equipment's mobile communication unit.
                   when attributeName = 'unitAddress';
                        allPerfDataDS.pmEqpAddr = %trim(attributeValue);

                   // Indicates the type of equipment, "trailer" or "tractor".
                   when attributeName = 'equipType';
                        allPerfDataDS.pmEqpType = %trim(attributeValue);

                   // Indicates the type of mobile communication device.
                   when attributeName = 'mobileType';
                        mobileType = %trim(attributeValue);
                        select;
                        when mobileType = '0 ';
                             allPerfDataDS.pmEqpMobTp = 'Unknown ';
                        when mobileType = '1 ';
                             allPerfDataDS.pmEqpMobTp = 'MCT     ';
                        when mobileType = '2 ';
                             allPerfDataDS.pmEqpMobTp = 'TMCT    ';
                        when mobileType = '3 ';
                             allPerfDataDS.pmEqpMobTp = 'OmniOne ';
                        when mobileType = '4 ';
                             allPerfDataDS.pmEqpMobTp = 'MCP     ';
                        when mobileType = '5 ';
                             allPerfDataDS.pmEqpMobTp = 'MCP100  ';
                        when mobileType = '6 ';
                             allPerfDataDS.pmEqpMobTp = 'MCP110  ';
                        when mobileType = '7 ';
                             allPerfDataDS.pmEqpMobTp = 'MCP200  ';
                        when mobileType = '8 ';
                             allPerfDataDS.pmEqpMobTp = 'MCP50   ';
                        when mobileType = '10';
                             allPerfDataDS.pmEqpMobTp = 'UTT     ';
                        when mobileType = '11';
                             allPerfDataDS.pmEqpMobTp = 'Tethered';
                        when mobileType = '12';
                             allPerfDataDS.pmEqpMobTp = 'Stingray';
                        endsl;

                   // On-board device identifier.
                   when attributeName = 'deviceID';
                        allPerfDataDS.pmEqpDevID = %trim(attributeValue);
                   endsl;
               enddo;

          // Driver I.D.
          when elementName = 'driverID';
               allPerfDataDS.pmDriverID = %trim(elementValue);

          // Geographical coordinates at a point in time.
          when elementName = 'position';
               attributeCount = 1;
               dow http_nextXmlAttr(attributes
                                  : attributeCount
                                  : attributeName
                                  : attributeValue);
                   select;

                   // Longitude expressed in signed degrees with
                   // floating-point decimal precision.
                   when attributeName = 'lon';
                        allPerfDataDS.pmLongitud = %trim(attributeValue);

                   // Latitude expressed in signed degrees with
                   // floating-point decimal precision.
                   when attributeName = 'lat';
                        allPerfDataDS.pmLatitud = %trim(attributeValue);

                   // Position timestamp in GMT.
                   when attributeName = 'posTS';
                        gmtDateTime = *blanks;
                        gmtDateTime = %trim(attributeValue);
                        exsr convertGMTtoEST;
                        allPerfDataDS.pmPosnDate = isoDate;
                        allPerfDataDS.pmPosnTime = isoTime;
                   endsl;
               enddo;

          // Identifies the hardware that was used to determine the position
          // information contained in the tranaction.
          when elementName = 'posType';
               posType = %trim(elementValue);
               select;
               when posType = '0';
                    allPerfDataDS.pmPosnType = 'Unknown';
               when posType = '1';
                    allPerfDataDS.pmPosnType = 'LORAN  ';
               when posType = '2';
                    allPerfDataDS.pmPosnType = 'QASPR  ';
               when posType = '3';
                    allPerfDataDS.pmPosnType = 'GPS    ';
               endsl;

          // Ignition Status of the truck. "On" or "Off".
          when elementName = 'ignitionStatus';
               ignitionStatus = %trim(elementValue);
               select;
               when ignitionStatus = '1';
               allPerfDataDS.pmIgnStat = 'On ';
               when ignitionStatus = '2';
               allPerfDataDS.pmIgnStat = 'Off';
               endsl;

          // The Trip status of the truck. "In" or "Out" of Trip. Note:
          // The trip status feature requires tha SensorTRACS service
          // to be enabled. and configured.
          when elementName = 'tripStatus';
               tripStatus = %trim(elementValue);
               select;
               when tripStatus = 'I';
               allPerfDataDS.pmTripStat = 'In ';
               when tripStatus = 'O';
               allPerfDataDS.pmTripStat = 'Out';
               endsl;

          // Date and time recording started for this Driver.
          // (Since last extraction reset).
          when elementName = 'dataStartTS';
               gmtDateTime = *blanks;
               gmtDateTime = %trim(elementValue);
               exsr convertGMTtoEST;
               allPerfDataDS.pmStrtDate = isoDate;
               allPerfDataDS.pmStrtTime = isoTime;

          // Date and time that recording ended for this Driver.
          // (Time of this extraction reset).
          when elementName = 'dataEndTS';
               gmtDateTime = *blanks;
               gmtDateTime = %trim(elementValue);
               exsr convertGMTtoEST;
               allPerfDataDS.pmEndDate = isoDate;
               allPerfDataDS.pmEndTime = isoTime;

          // Distance travelled in miles or kilometers.
          when elementName = 'distance';
               allPerfDataDS.pmDistance = %trim(elementValue);

          // The number of minutes recorded for this Driver while ignition was
          // on but excluding intertrip idle time (includes idle time during
          // trip but not between trips).
          when elementName = 'driveTime';
               allPerfDataDS.pmDrivTime = %trim(elementValue);

          // The number of minutes recorded for this Driver while the ignition
          // was on.
          when elementName = 'engineTime';
               allPerfDataDS.pmEngTime = %trim(elementValue);

          // The number of minutes when the vehicle speed was greater than zero.
          when elementName = 'moveTime';
               allPerfDataDS.pmMoveTime = %trim(elementValue);

          // The number of minutes idling between trips (excess idle time for
          // this Driver).
          when elementName = 'intertripIdleTime';
               allPerfDataDS.pmIntIdle   = %trim(elementValue);

          // The number of minutes idling when the duration of the idling period
          // was longer than the end of trip (EOT) threshold, but shorter than
          // the short idle threshold. Note MCT firmware version 14.02 or higher
          // is required.
          when elementName = 'shortIdleTime';
               allPerfDataDS.pmShrtIdle  = %trim(elementValue);

          // The number of minutes the Driver has exceeded the settable RPM
          // threshold.
          when elementName = 'overRPMTime';
               allPerfDataDS.pmOverRPMT  = %trim(elementValue);

          // The number of times the settable RPM threshold was exceeded in
          // one minute.
          when elementName = 'overRPMCount';
               allPerfDataDS.pmOverRPMC  = %trim(elementValue);

          // The longest duration exceeding the settable RPM threshold (rounded
          // up to the next minute).
          when elementName = 'overRPMMax';
               allPerfDataDS.pmOverRPMM  = %trim(elementValue);

          // The number of minutes the Driver exceeded the settable speed
          // threshold.
          when elementName = 'overSpdTime';
               allPerfDataDS.pmOverSpdT = %trim(elementValue);

          // The number of times the settable speed threshold exceeded 1 min.
          when elementName = 'overSpdCount';
               allPerfDataDS.pmOverSpdC  = %trim(elementValue);

          // The longest duration exceeded the settable speed threshold (rounded
          // up to the next minute).
          when elementName = 'overSpdMax';
               allPerfDataDS.pmOverSpdM  = %trim(elementValue);

          // The number of minutes the driver has exceeded the settable
          // excessive speed threshold. Note: MCT firmware version > 10.51
          // required.
          when elementName = 'excessSpdTime';
               allPerfDataDS.pmExceSpdT  = %trim(elementValue);

          // The total amount of fuel burned by this Driver in gallons, liters,
          // or imperial gallons based on the customer's preference. Note: MCT
          // firmware version above 10.51 is required.
          when elementName = 'totalFuelUsed';
               allPerfDataDS.pmTotlFuel = %trim(elementValue);

          // The total amount of fuel burned by this Driver while the vehicle
          // was not moving and a PTO was not active. Units are in gallons,
          // liters, or imperial gallons based on the company's preference.
          // Note MCT firmware version above 10.51 is required.
          when elementName = 'idleFuelUsed';
               allPerfDataDS.pmIdleFuel = %trim(elementValue);

          // The total amount of fuel burned by this Driver while the parking
          // brake was applied. Units are in gallons, liters, or imperial
          // gallons based on the company's preference. Note: MCT firmware
          // version above 10.51 is required.
          when elementName = 'parkIdleFuelUsed';
               allPerfDataDS.pmParkIdle  = %trim(elementValue);

          // Indicates whether or not any fault conditions were present.
          when elementName = 'faultFlag';
               faultFlag = %trim(elementValue);
               select;
               when faultFlag = '0';
                    allPerfDataDS.pmFaultFlg = 'No Faults      ';
               when faultFlag = '1';
                    allPerfDataDS.pmFaultFlg = 'Faults detected';
               endsl;

          // Indicates whether or not the Driver is registered.
          when elementName = 'registeredDriver';
               registeredDriver = %trim(elementValue);
               select;
               when registeredDriver = '0';
                    allPerfDataDS.pmRegiDriv = 'Unregistered';
               when registeredDriver = '1';
                    allPerfDataDS.pmRegiDriv = 'Registered  ';
               endsl;

          // The number of minutes cruise control was active and a speed was
          // set.
          when elementName = 'cruiseCtrlTime';
               allPerfDataDS.pmCruiseCt = %trim(elementValue);

          // The number of minutes vehicle was in top gear.
          when elementName = 'topGearTime';
               allPerfDataDS.pmTopGear = %trim(elementValue);

          // The method or source used to acquire gear data for determining time
          // in top gear. Possible values are: "Vehicle data bus (J1939) is the
          // sole source", "Hybrid combination of data bus and onboard
          // algorithmic sources", or "Onboard algorithm is the sole source".
          when elementName = 'gearDataSource';
               allPerfDataDS.pmGearData = %trim(elementValue);

          // Either "MPH" or "KPH".
          when elementName = 'spdRpmTimes';
               attributeCount = 1;
               dow http_nextXmlAttr(attributes
                                  : attributeCount
                                  : attributeName
                                  : attributeValue);
                   select;
                   when attributeName = 'spdUnits';
                        allPerfDataDS.pmSpeedUOM = %trim(attributeValue);
                   endsl;
               enddo;

          // Proximity - Location information expressed as a reference to a
          // nearby place.
          when elementName = 'proximity';
               attributeCount = 1;
               dow http_nextXmlAttr(attributes
                                  : attributeCount
                                  : attributeName
                                  : attributeValue);

                   select;

                   // Proximity City name.
                   when attributeName = 'city';
                        proxCity = %trim(attributeValue);

                   // The distance to the (proximity) place in miles or kms.
                   when attributeName = 'distance';
                        proxDist = %trim(attributeValue);

                   // Direction to the (proximity) place using a compass notation
                   // notation containing a maximum of 3 characters.
                   // (e.g. N, SE, NNW).
                   when attributeName = 'direction';
                        proxDir = %trim(attributeValue);

                   // The unique customer-defined name of the (proximity) place, if
                   // the place type is not CITY or TOWN.
                   when attributeName = 'placeName';
                        proxPlac = %trim(attributeValue);

                   // Proximity Place Type such as CITY or TOWN.
                   when attributeName = 'placeType';
                        proxPlTp = %trim(attributeValue);

                   // Proximity State or Province code.
                   when attributeName = 'stateProv';
                        proxStPr = %trim(attributeValue);

                   // Proximity Postal code - 12 character maximum.
                   when attributeName = 'postal';
                        proxPost = %trim(attributeValue);

                   // Proximity Country code, possible values are US, CA, MX.
                   when attributeName = 'country';
                        proxCoun = %trim(attributeValue);
                   endsl;
               enddo;

               // If this is a TOWN then populate the Proximity Town fields.
               if proxPlTp = 'TOWN';
                  allPerfDataDS.pmPrxTCity = proxCity;
                  allPerfDataDS.pmPrxTDist = proxDist;
                  allPerfDataDS.pmPrxTDir  = proxDir;
                  allPerfDataDS.pmPrxTPlac = proxPlac;
                  allPerfDataDS.pmPrxTPlTp = proxPlTp;
                  allPerfDataDS.pmPrxTStPr = proxStPr;
                  allPerfDataDS.pmPrxTPost = proxPost;
                  allPerfDataDS.pmPrxTCoun = proxCoun;

               // If this is a CITY then populate the Proximity City fields.
               elseif proxPlTp = 'CITY';
                  allPerfDataDS.pmPrxCCity = proxCity;
                  allPerfDataDS.pmPrxCDist = proxDist;
                  allPerfDataDS.pmPrxCDir  = proxDir;
                  allPerfDataDS.pmPrxCPlac = proxPlac;
                  allPerfDataDS.pmPrxCPlTp = proxPlTp;
                  allPerfDataDS.pmPrxCStPr = proxStPr;
                  allPerfDataDS.pmPrxCPost = proxPost;
                  allPerfDataDS.pmPrxCCoun = proxCoun;
               endif;

               // Reset the proximity work fields.
               proxCity = *blanks;
               proxDist = *blanks;
               proxDir  = *blanks;
               proxPlac = *blanks;
               proxPlTp = *blanks;
               proxStPr = *blanks;
               proxPost = *blanks;
               proxCoun = *blanks;

          // T.3.02.0 - Critical Event Reporting (CER)

          // A unique identifier for this incident.
          when elementName = 'eventKey';
               allPerfDataDS.pmCerEvtKy = %trim(elementValue);

          // Date and Time that this event was sent in.
          when elementName = 'sentTS';
               gmtDateTime = *blanks;
               gmtDateTime = %trim(elementValue);
               exsr convertGMTtoEST;
               allPerfDataDS.pmCerSntDt = isoDate;
               allPerfDataDS.pmCerSntTm = isoTime;

          // The event that triggered this incident.
          when elementName = 'eventTrigger';
               allPerfDataDS.pmCerEvent = %trim(elementValue);

          // Trigger specific data for the incident.
          when elementName = 'triggerData';
               allPerfDataDS.pmCerTrgDa = %trim(elementValue);

          // Purpose of this is similar to the Event Trigger element. But,
          // this will be used specifically for EVIMS with value EVIMS.
          when elementName = 'eventType';
               allPerfDataDS.pmCerEvtTp = %trim(elementValue);

          // Speed.
          when elementName = 'speed';
               allPerfDataDS.pmCerSpeed = %trim(elementValue);

          // Parking Brake Status.
          when elementName = 'parkBrakeStatus';
               allPerfDataDS.pmCerParBk = %trim(elementValue);

          // Message location, date and time.
          when elementName = 'messageLocation';
               allPerfDataDS.pmCerMLon  = allPerfDataDS.pmLongitud;
               allPerfDataDS.pmCerMLat  = allPerfDataDS.pmLatitud;
               allPerfDataDS.pmCerMDate = allPerfDataDS.pmPosnDate;
               allPerfDataDS.pmCerMTime = allPerfDataDS.pmPosnTime;
               allPerfDataDS.pmLongitud = *blanks;
               allPerfDataDS.pmLatitud  = *blanks;
               allPerfDataDS.pmPosnDate = *loval;
               allPerfDataDS.pmPosnTime = *loval;

               // Proximity to the nearest town.
               allPerfDataDS.pmCerTDist = allPerfDataDS.pmPrxTDist;
               allPerfDataDS.pmCerTDir  = allPerfDataDS.pmPrxTDir;
               allPerfDataDS.pmCerTPlac = allPerfDataDS.pmPrxTPlac;
               allPerfDataDS.pmCerTPlTp = allPerfDataDS.pmPrxTPlTp;
               allPerfDataDS.pmCerTCity = allPerfDataDS.pmPrxTCity;
               allPerfDataDS.pmCerTStPr = allPerfDataDS.pmPrxTStPr;
               allPerfDataDS.pmCerTPost = allPerfDataDS.pmPrxTPost;
               allPerfDataDS.pmCerTCoun = allPerfDataDS.pmPrxTCoun;
               allPerfDataDS.pmPrxTDist = *blanks;
               allPerfDataDS.pmPrxTDir  = *blanks;
               allPerfDataDS.pmPrxTPlac = *blanks;
               allPerfDataDS.pmPrxTPlTp = *blanks;
               allPerfDataDS.pmPrxTCity = *blanks;
               allPerfDataDS.pmPrxTStPr = *blanks;
               allPerfDataDS.pmPrxTPost = *blanks;
               allPerfDataDS.pmPrxTCoun = *blanks;

               // Proximity to the nearest city.
               allPerfDataDS.pmCerCDist = allPerfDataDS.pmPrxCDist;
               allPerfDataDS.pmCerCDir  = allPerfDataDS.pmPrxCDir;
               allPerfDataDS.pmCerCPlac = allPerfDataDS.pmPrxCPlac;
               allPerfDataDS.pmCerCPlTp = allPerfDataDS.pmPrxCPlTp;
               allPerfDataDS.pmCerCCity = allPerfDataDS.pmPrxCCity;
               allPerfDataDS.pmCerCStPr = allPerfDataDS.pmPrxCStPr;
               allPerfDataDS.pmCerCPost = allPerfDataDS.pmPrxCPost;
               allPerfDataDS.pmCerCCoun = allPerfDataDS.pmPrxCCoun;
               allPerfDataDS.pmPrxCDist = *blanks;
               allPerfDataDS.pmPrxCDir  = *blanks;
               allPerfDataDS.pmPrxCPlac = *blanks;
               allPerfDataDS.pmPrxCPlTp = *blanks;
               allPerfDataDS.pmPrxCCity = *blanks;
               allPerfDataDS.pmPrxCStPr = *blanks;
               allPerfDataDS.pmPrxCPost = *blanks;
               allPerfDataDS.pmPrxCCoun = *blanks;

          // Message location, date and time.
          when elementName = 'incidentLocation';
               allPerfDataDS.pmCerILon  = allPerfDataDS.pmLongitud;
               allPerfDataDS.pmCerILat  = allPerfDataDS.pmLatitud;
               allPerfDataDS.pmCerIDate = allPerfDataDS.pmPosnDate;
               allPerfDataDS.pmCerITime = allPerfDataDS.pmPosnTime;
               allPerfDataDS.pmLongitud = *blanks;
               allPerfDataDS.pmLatitud  = *blanks;
               allPerfDataDS.pmPosnDate = *loval;
               allPerfDataDS.pmPosnTime = *loval;

          // CER URL.
          when elementName = 'eventUrl';
               allPerfDataDS.pmCerUrl = %trim(elementValue);

          endsl;

       //-----------------------------------------------------------------------*
       // Convert a GMT Date/Time Stamp to EST in ISO format.                   *
       //-----------------------------------------------------------------------*

          begsr convertGMTtoEST;

             isoDate = *loval;
             isoTime = *loval;
             isoAlphaDateTime = *blanks;
             timeStamp        = *loval;
             isoAlphaDateTime = %subst(gmtDateTime:1:4) +
                                '-' +
                                %subst(gmtDateTime:6:2) +
                                '-' +
                                %subst(gmtDateTime:9:2) +
                                '-' +
                                %subst(gmtDateTime:12:2) +
                                '.' +
                                %subst(gmtDateTime:15:2) +
                                  '.' +
                                %subst(gmtDateTime:18:2) +
                                '.' +
                                '000000';
             test(ZE) *ISO isoAlphaDateTime;
             if not %error;
                timeStamp = %timestamp(isoAlphaDateTime:*ISO)
                                       - %hours(5);  // Convert GMT to EST.
                isoDate = %date(%subst(%char(timeStamp):1:10));
                isoTime = %time(%subst(%char(timeStamp):12:8));
             endif;

          endsr;

      /end-free
      *
     P embedded...
     P                 E
      *
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi