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

RE: Formatting an XML request and receiving the XML response



   Hi Mike,
   Thanks very much for this, it's a great help to me.
   Mike, remembering that I'm a complete novice at this - what would you
   recommend to correct the encoding issues you pointed out?
   I really appreciate this - without the help I've been getting, it
   would take me much longer to get up to speed with this.
   I will likely have more questions for either of you or both, if that's
   ok...
   Thanks!
   Rich

   [1]i'm EMAILING FOR THE GREATER GOOD
   Join me

   > Date: Fri, 29 May 2009 16:34:04 -0500
   > From: sk@xxxxxxxxxxxxxxxx
   > To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
   > Subject: Re: Formatting an XML request and receiving the XML
   response
   >
   > Hi Mike,
   >
   > You're making two mistakes in your encoding:
   >
   > a) You aren't encoding the data to make it a valid XML document. As
   > soon as you get an address with a < or & symbol, your XML document
   will
   > be invalid.
   >
   > b) You aren't using the URL encoder properly. You've created an
   > encoder, but you didn't ask it to encode anything. The URL itself
   > contains all of the data, but if there's any characters that are
   invalid
   > in a URL (that includes blanks, &, =, /, etc) the HTTP protocol is
   going
   > to choke on it.
   >
   >
   >
   > Mike Krebs wrote:
   > > Rich, I played with this app a while back (USPS address
   verification). Here was my test program. I didn't parse the result but
   look at EXAMPLE15 for how to handle that part.
   > >
   > > Mike Krebs
   > >
   > >
   > > H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('LIBHTTP/HTTPAPI')
   > >
   > > D/copy libhttp/qrpglesrc,httpapi_h
   > >
   > > D rc s 10I 0
   > > D msg s 52A
   > >
   > > d USPSUserID s 12a inz('your user id')
   > > d address1 s 38a inz(*blanks)
   > > d address2 s 38a inz('6406 Ivy Lane')
   > > d city s 15a inz('Greenbelt')
   > > d state s 2a inz('MD')
   > > d zip5 s 5a inz(*blanks)
   > > d zip4 s 4a inz(*blanks)
   > >
   > > d Enc s like(HTTP_URL_ENCODER)
   > > d url s 32767a varying
   > > d urlValues s 32767a varying
   > >
   > > C* retrieve the ILE RPG/400 refernece manual from IBM:
   > >
   > > c eval urlValues =
   > > c 'ShippingAPItest.dll?API=Verify'+
   > > c 'ShippingAPItest.dll?API=Verify'+
   > > c '&XML=<AddressValidateRequest '+
   > > c 'USERID="' + %trim(USPSUserID) + '">'
   > > c '<Address ID="0">'+
   > > c '<Address1>' + %trim(Address1) +
   > > c '</Address1>' +
   > > c '<Address2>' + %trim(Address2) +
   > > c '</Address2>' +
   > > c '<City>' + %trim(City) +
   > > c '</City>' +
   > > c '<State>' + %trim(State) +
   > > c '</State>' +
   > > c '<Zip5>' + %trim(Zip5) +
   > > c '</Zip5>' +
   > > c '<Zip4>' + %trim(Zip4) +
   > > c '</Zip4>' +
   > > c '</Address></AddressValidateRequest>'
   > > c eval url =
   > > c 'http://testing.shippingapis.com/'
   > >
   > > c eval Enc = http_url_encoder_new()
   > > c eval rc = http_url_get(url +
   > > c http_url_encoder_getstr(Enc):
   > > c '/tmp/address_valid.txt')
   > > c if rc <> 1
   > > c eval msg = http_error
   > > c dsply msg
   > > c endif
   > >
   > > c callp http_url_encoder_free(Enc)
   > >
   > > c eval *inlr = *on
   > > ****************** End of data *****
   > >
   ----------------------------------------------------------------------
   -
   > > This is the FTPAPI mailing list. To unsubscribe, please go to:
   > > http://www.scottklement.com/mailman/listinfo/ftpapi
   > >
   ----------------------------------------------------------------------
   -
   > >
   >
   >
   ----------------------------------------------------------------------
   -
   > This is the FTPAPI mailing list. To unsubscribe, please go to:
   > http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   ----------------------------------------------------------------------
   -

References

   1. http://im.live.com/Messenger/IM/Home/?source=EML_WLHM_GreaterGood
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------