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

RE: Formatting an XML request and receiving the XML response



   Hi Mike,
   I used your example program, substituting my userid, and have been
   getting "403 Forbidden" errors when I try to run it.  The following
   debug list shows that the USPS server thinks I'm trying to request a
   directory listing, which I'm not.  I tried sending the URL through a
   browser and got errors as well, but once I replaced the blanks with
   "%20" it ran without a problem.  I'm not certain what I'm doing wrong
   on the i, but could use a little clarification...
    ************Beginning of
   data**************
   HTTPAPI Ver 1.23 released
   2008-04-24
   OS/400 Ver
   V5R1M0


   New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819.
   ProtLoc=0
   http_url_get():
   entered
   http_persist_open():
   entered
   http_long_ParseURL():
   entered
   DNS resolver retrans:
   2
   DNS resolver retry  :
   2
   DNS resolver options:
   x'00000136'
   DNS default domain:
   S105VX7M.COM
   DNS server found:
   205.171.2.65
   DNS server found:
   205.171.3.65
   http_persist_get():
   entered
   http_long_ParseURL():
   entered
   do_get():
   entered
   GET /
   HTTP/1.1
   Host:
   testing.shippingapis.com
   User-Agent:
   http-api/1.23



   recvresp():
   entered

   HTTP/1.1 403
   Forbidden

   Content-Length:
   218

   Content-Type:
   text/html

   Server:
   Microsoft-IIS/6.0

   X-Powered-By:
   ASP.NET

   Date: Fri, 05 Jun 2009 19:38:28
   GMT



   SetError() #13: HTTP/1.1 403
   Forbidden

   recvdoc parms: identity
   218

   header_load_cookies()
   entered

   recvdoc():
   entered

   SetError()
   #0:

   <html><head><title>Error</title></head><body><head><title>Directory
   Listing Denied</title></head> <body><h1>Directory Listing
   Denied</h1>This Virtual Directory does not allow contents to be
   listed.</body></body></html>
   SetError() #13: HTTP/1.1 403 Forbidden
   http_close(): entered
   Thanks!
   Rich
   > From: richardkitterman@xxxxxxxxxxx
   > To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
   > Subject: RE: Formatting an XML request and receiving the XML
   response
   > Date: Mon, 1 Jun 2009 13:08:17 -0600
   >
   >
   > 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
   >
   >
   >
   > 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
   > >
   ----------------------------------------------------------------------
   -
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------