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

RE: HTTPAPI



Scott,

I appreciate you taking the time to look at the problem I'm having. I'm
attaching a copy of the actual program I'm using. Some lines are
commented out since I haven't finished testing the retrieving of the XML
document.

Let me know if you see any problem with the code.

Thanks,
Karl

-----Original Message-----
From: Scott Klement [mailto:sk@xxxxxxxxxxxxxxxx] 
Sent: Thursday, November 20, 2008 2:11 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: HTTPAPI

Hi Karl,

I tried parsing your SOAP response document and I didn't have any 
trouble. Is it possible that it's parsing the data correctly, and you're

simply forgetting to check the "attrs" parameter that contains the 
attributes?

Or, what symptoms are you encountering?   I tried your document, and I 
got all of the attributes and self-closing tags without any problem...


Karl Woods wrote:
> Scott,
> 
> The attached document 'xml version2' contains the request from my
> program (with a few changes to password, etc.) 'VehiclePerformance2'
is
> the response. The returned data starts with '<Entry Id='. I get
'Entry'
> but the rest of the data is not returned.
> 
> Thanks,
> Karl
> 
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
     H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')
     ?********************************************************************
     ?* FILE SPECS
     ?********************************************************************
     FDTCTLL01  IF   E           K DISK
     ?********************************************************************
     ?* EXTENSION SPECS
     ?********************************************************************
      /copy httpapi_h
     ?********************************************************************
     D StartOfElement  PR
     D   UserData                      *   value
     D   depth                       10I 0 value
     D   name                      1024A   varying const
     D   path                     24576A   varying const
     D   attrs                         *   dim(32767)
     D                                     const options(*varsize)
     ?********************************************************************
     D EndOfElement    PR
     D   UserData                      *   value
     D   depth                       10I 0 value
     D   name                      1024A   varying const
     D   path                     24576A   varying const
     D   value                    65535A   varying const
     D   attrs                         *   dim(32767)
     D                                     const options(*varsize)
     ?********************************************************************
     D SOAP            s          32767A   varying
     D rc              s             10I 0
     D act             s             10I 0
     D count           s              4  0
     D wkprox          S             50a
     D wknum           S              5  1
     D wkdir           S              2A
     D Truck#          S             10A
     D wktim           S             12  0
     D @first          S              1A   Inz('Y')
     ?*---------------------------------------------------------------------
     ?* Web Service Credentials for each individual account from control fil
     ?*---------------------------------------------------------------------
     D WBcompany       S             15A   Inz('CpyNme')
     D WBcustnum       S             15A   Inz('CpyNbr')
     D WBusername      S             15A   Inz('UsrNme')
     D WBpassword      S             15A   Inz('PssWrd')
     D WBstrdate       S             15A   Inz('2008-11-09')
     D WBenddate       S             15A   Inz('2008-11-09')
     ?*---------------------------------------------------------------------
     D WKTIME          DS
     D  WKCC                   1      2
     D  WKYR                   3      4
     D  WKMO                   6      7
     D  WKDA                   9     10
     D  WKHH                  12     13
     D  WKMM                  15     16
     D  WKSS                  18     19
     D
     D WKTIME1         DS
     D  WKHH1                  1      2  0
     D  WKMM1                  3      4  0
     D  WKSS1                  5      6  0
     D  WKMO1                  7      8  0
     D  WKDA1                  9     10  0
     D  WKYR1                 11     12  0

     D Form#           DS
     D  FormP                  1      1
     D  FormS                  2      2
     ?********************************************************************
     ?* XML Parsed & put into array.
     ?********************************************************************
     D activity1       ds                  qualified
     D   array1                            dim(100)
     D   EntryId                     20A   overlay(array1)
     D   TruckName                   20A   overlay(array1:*next)
     D   DriverName                  20A   overlay(array1:*next)
     D   DateTime                    20A   overlay(array1:*next)
      *?Communication Elements
     D activity2       ds                  qualified
     D   array2                            dim(100)
     D   CA                          10A   overlay(array2)
     D   CB                          10A   overlay(array2:*next)
     D   CC                          10A   overlay(array2:*next)
     D   CD                          10A   overlay(array2:*next)
     D   CE                          10A   overlay(array2:*next)
     D   CF                          10A   overlay(array2:*next)
     D   CG                          10A   overlay(array2:*next)
     D   CH                          10A   overlay(array2:*next)
     D   CI                          10A   overlay(array2:*next)
     D   CJ                          10A   overlay(array2:*next)
     D   CK                          10A   overlay(array2:*next)
     D   CL                          10A   overlay(array2:*next)
     D   CM                          10A   overlay(array2:*next)
     D   CN                          10A   overlay(array2:*next)
     D   CO                          10A   overlay(array2:*next)
     D   CP                          10A   overlay(array2:*next)
     D   CQ                          10A   overlay(array2:*next)
      *?Driver Performance Elements
     D activity3       ds                  qualified
     D   array3                            dim(100)
     D   DA                          10A   overlay(array3)
     D   DB                          10A   overlay(array3:*next)
     D   DC                          10A   overlay(array3:*next)
     D   DD                          10A   overlay(array3:*next)
     D   DE                          10A   overlay(array3:*next)
     D   DF                          10A   overlay(array3:*next)
     D   DG                          10A   overlay(array3:*next)
     D   DH                          10A   overlay(array3:*next)
     D   DI                          10A   overlay(array3:*next)
     D   DJ                          10A   overlay(array3:*next)
     D   DK                          10A   overlay(array3:*next)
     D   DL                          10A   overlay(array3:*next)
     D   DM                          10A   overlay(array3:*next)
     D   DN                          10A   overlay(array3:*next)
     D   DO                          10A   overlay(array3:*next)
     D   DP                          10A   overlay(array3:*next)
     D   DQ                          10A   overlay(array3:*next)
     D   DR                          10A   overlay(array3:*next)
     D   DSRI                        10A   overlay(array3:*next)
     D   DSRD                        10A   overlay(array3:*next)
      *?Fuel Mileage Elements
     D activity4       ds                  qualified
     D   array4                            dim(100)
     D   FA                          10A   overlay(array4)
     D   FB                          10A   overlay(array4:*next)
     D   FC                          10A   overlay(array4:*next)
     D   FD                          10A   overlay(array4:*next)
     D   FE                          10A   overlay(array4:*next)
     D   FF                          10A   overlay(array4:*next)
     D   FG                          10A   overlay(array4:*next)
     D   FH                          10A   overlay(array4:*next)
     D   FI                          10A   overlay(array4:*next)
     D   FJ                          10A   overlay(array4:*next)
     D   FK                          10A   overlay(array4:*next)
     D   FL                          10A   overlay(array4:*next)
     D   FM                          10A   overlay(array4:*next)
     D   FN                          10A   overlay(array4:*next)
     D   FO                          10A   overlay(array4:*next)
     D   FP                          10A   overlay(array4:*next)
     D   FQ                          10A   overlay(array4:*next)
     D   FR                          10A   overlay(array4:*next)
     D   FS                          10A   overlay(array4:*next)

     ?********************************************************************
     ?* Main Driver - Calls Webservice & retrieves Messages.
     ?********************************************************************
     ?*
      /free
       setll *loval dtctll01;
       read dtctll01;
       //eval WBcompany = %trim(ctcmpcd);
       //eval WBcustnum = %trim(ctcstcd);
       //eval WBusername = %trim(ctusrnm);
       //eval WBpassword = %trim(ctusrpw);

       //?Note:  http_debug(*ON/*OFF) can be used to turn debugging
       //?       on and off.  When debugging is turned on, diagnostic
       //?       info is written to an IFS file named
       //?       /tmp/httpapi_debug.txt     Use "WRKLNK /tmp" cmd

       http_debug(*ON);

       HTTP_setCCSIDs(1208: 0);  // CCSID 1208 = UTF-8

         SOAP =
         '<?xml version="1.0" encoding="utf-8"?>' +
         ' <soapenv:Envelope' +
         ' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";' +
         ' xmlns:ser="urn:DriverTech">' +
         ' <soapenv:Header>' +
         ' <ser:RequestHeader>' +
         ' <ser:CompanyCode>' +%trim(WBcompany) + '</ser:CompanyCode>' +
         ' <ser:CustomerNumber>' + %trim(WBCustnum) + '</ser:CustomerNumber>' +
         ' <ser:UserName>' + %trim(WBusername) + '</ser:UserName>' +
         ' <ser:Password>' + %trim(WBpassword) + '</ser:Password>' +
         ' <ser:RequestId></ser:RequestId>' +
         ' </ser:RequestHeader>' +
         ' </soapenv:Header>' +
         ' <soapenv:Body>' +
         ' <ser:ReportingRequest>' +
         ' <ser:RunParameters>' +
         ' <ser:RecipientList>' +
         ' <ser:RecipientType>AllTrucks</ser:RecipientType>' +
         ' </ser:RecipientList>' +
         ' <ser:DateRange>' +
         ' <ser:StartDate>' + %trim(WBstrdate) + '</ser:StartDate>' +
         ' <ser:EndDate>'   + %trim(WBenddate) + '</ser:EndDate>' +
         ' </ser:DateRange>' +
         ' </ser:RunParameters>' +
         ' <ser:ReportName>VehiclePerformance</ser:ReportName>' +
         ' </ser:ReportingRequest>' +
         ' </soapenv:Body>' +
         ' </soapenv:Envelope>';

       rc = http_url_post_xml(
            'https://www.truck-pc.net/WebServices/V1.2.2/ClientService.asmx'
            : %addr(SOAP) + 2
            : %len(SOAP)
            : %paddr(StartOfElement)
            : %paddr(EndOfElement)
            : *NULL
            : HTTP_TIMEOUT
            : HTTP_USERAGENT
            : 'text/xml; charset=utf-8'
            : 'ClientService/1.2.2/GetReport');

       if (rc <> 1);
              http_crash();
              *inlr = *on;
       endif;

       // ----------------------------------------------------------------
       // Retrieved records from webservice and now processing.
       // ----------------------------------------------------------------

       if act > 0;
       //for count = 1 to act;
           //if activity.TruckName(count) <> *blanks;
             exsr WrtRcd;
           //endif;
       //endfor;
       endif;

       *inlr = *on;
      /end-free
     ?********************************************************************
     ?* Update Unit record and write record to dtinb
     ?********************************************************************
      /free
        Begsr WrtRcd;

        //eval wktime = activity.DateTime(count);
        //eval wkyr1 = %dec(wkyr:2:0);
        //eval wkmo1 = %dec(wkmo:2:0);
        //eval wkda1 = %dec(wkda:2:0);
        //eval wkhh1 = %dec(wkhh:2:0);
        //eval wkmm1 = %dec(wkmm:2:0);
        //eval wkss1 = %dec(wkss:2:0);
        //eval truck# = activity.TruckName(count);

          //?Write to DTINB
        //clear rxrecf;
        //rxtrk# = truck#;
        //rxform = %dec(activity.macro(count):2:0);
        //rxtime = wktime1;
        //rxrecd = %trim(activity.subject(count)) + '|' +
        //         activity.body(count);
        //write rxrecf;

        endsr;

      /end-free
     ?********************************************************************
     ?* Procedure - Start of XML element
     ?********************************************************************
     P StartOfElement  B
     D StartOfElement  PI
     D   UserData                      *   value
     D   depth                       10I 0 value
     D   name                      1024A   varying const
     D   path                     24576A   varying const
     D   attrs                         *   dim(32767)
     D                                     const options(*varsize)
      /free

        if path = '/soap:Envelope/soap:Body';
           act += 1;
        endif;

      /end-free
     P                 E
     ?********************************************************************
     ?* Procedure - End of XML element
     ?********************************************************************
     P EndOfElement    B
     D EndOfElement    PI
     D   UserData                      *   value
     D   depth                       10I 0 value
     D   name                      1024A   varying const
     D   path                     24576A   varying const
     D   value                    65535A   varying const
     D   attrs                         *   dim(32767)
     D                                     const options(*varsize)
      /free

           select;
            when name = 'VehiclePerformance';
             if @first = 'N';
          //   act += 1;
             else;
          //   @first = 'N';
             endif;
          // activity.MessageId(act) = %trim(value);

          //when name = 'TruckName';
          // activity.TruckName(act) = %trim(value);

          //when name = 'TransmissionMode';
          // activity.Transmission(act) = %trim(value);

          //when name = 'DateTime';
          // activity.DateTime(act) = %trim(value);

          //when name = 'Latitude';
          // activity.Latitude(act) = %trim(value);

          //when name = 'Longitude';
          // activity.Longitude(act) = %trim(value);

          //when name = 'City';
          // activity.City(act) = %trim(value);

          //when name = 'Region';
          // activity.Region(act) = %trim(value);

          //when name = 'Proximity';
          // activity.Proximity(act) = %trim(value);

          //when name = 'DriverName';
          // activity.DriverName(act) = %trim(value);

          //when name = 'FreeFormMessage';
          // activity.macro(act) = '00';

          //when name = 'Number';
          // Form# = %trim(value);
          // if FormS = *Blank;
          //   %subst(activity.macro(act):2: 1) = FormP;
          //   %subst(activity.macro(act):1: 1) = '0';
          // else;
          //   activity.macro(act) = Form#;
          // endif;

          //when name = 'Subject';
          // activity.subject(act) = %trim(value);

          //when name = 'Body';
          // activity.body(act) = %trim(value);

          //when name = 'FieldValue' and name <> 'FieldValues';
          // activity.body(act) = %trim(activity.body(act)) +
          //                      %trim(value) + '|';
           endsl;

      /end-free
     P                 E
      **************************************************************
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------