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

RE: Help wanted for the use of HTTPAPIR4



Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>


Hello,


D HTTP_CONTTYPE   C                   CONST('text/xml')
I comment out the line above and inserted the line below
D HTTP_CONTTYPE   C                   CONST('application/+
D                                     x-www-form-urlencoded')

What you've done is changed the _default_ from XML data to URL Encoded data. And that's fine, you can do that if you want to. The other alternative is to pass the content-type on each call to HTTP_url_post (or post_Raw, or post_xml, or post_stmf or whatever you're using)


Once you do that, what you're doing is promising that the data that you send will be URL encoded.


    1   'dataXML=<?xml version="1.0" encoding="ISO-8859-1" ?><Generic'
   61   'Invoice><Request>Open</Request><Orignator>FIS2000</Orignator'
  121   '><CompanyId>Bedrijf 3</CompanyId></GenericInvoice>&dataHandl'
  181   'er=nl.ibs.fac.external.GenericInvoiceHandler                '

Unfortunately, even though you told the HTTP server that your data is URL encoded, that data above is definitely NOT URL encoded.


To encode it, you need to call the URL encoding routines in HTTPAPI. You do that by writing code like this:

     D Enc             s                   like(HTTP_URL_ENCODER)
     D Xml             s          32767A   varying
       .
       .

       xml = '<?xml version="1.0" encoding="ISO-8859-1" ?>'
           + '... and so on, with the rest of your XML doc here ...';

       Enc = http_url_encoder_new();
       http_url_encoder_addvar(Enc: 'dataXML'
                                  : %addr(xml) + 2
                                  : %len(xml) );
       http_url_encoder_addvar_s(Enc: 'dataHandler'
                         : 'nl.ibs.fac.external.GenericInvoiceHandler');

This will result in data that has been URL encoded. That URL encoded data will be stored in temporary memory that's inside the "Enc" variable (the URL Encoder) that you declared on the D-spec.

Once all of your data has been encoded, you can do something like this to send it:
D Data s *
D size s 10I 0


         http_url_encoder_getptr(enc: data: size);
         rc = http_url_post_raw( %trimr(url) : data: size
                               : 1: %paddr(incoming));


When you're done, make sure you free up the temporary memory that the URL encoder was using by doing this:


http_url_encoder_free(enc);


I am wondering if there are some values that are in conflict of the
settings of my system (CCSID or code tables)?

that wouldn't cause the errors that you're describing, but it might cause a different error later. :)


Since you told it that the XML data is encoded in ISO 8859-1, it might be smart to call the following prior to the POST:

http_SetCCSIDs( 819 : 0 );

(Because 819 = ISO 8859-1)

But that's not the current problem.
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------