sponsored links



No announcement yet.

HTTPAPI's http_url_post - what determines CCSID of response stream file?

  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTPAPI's http_url_post - what determines CCSID of response stream file?

    I am teaching myself about sending and recieving XML data over http requests, by rewriting a program that uses http_url_post

    I notice that for this program (no idea if it is the same for others), the recieved stream file has CCSID 819 - ASCII

    What determines this? Can it be changed or overridden?

    The received XML data is encoded with UTF-8 according to the declaration line - is there a chance of incompatibility here, if the recieved data contains characters valid in UTF-8 but not in ASCII?

    What would be the best way to pull the file from the IFS into an RPG program, and parse it into an XML_CLOB? I was thinking:
    exec sql set :clobVar
        = xmlparse(document cast(get_clob_from_file('/ifspath/filename.xml')
                                 as varchar(10000) ccsid 1208))
    Casting it to ccsid 1208 so it matches the UTF-8 encoding in the XML declaration, otherwise xmlparse complains
    Is there a better way?

  • #2
    You can use http_setCCSIDs to control the CCSIDs/


    • #3
      A reply from the man himself! Thanks!

      To confirm my understanding:

      http_setCCSIDs() is the CCSID's used for the actual data exchange, e.g.:
      would mean that http_url_post will convert sent data from 037 to 1208, and convert received data from 1208 to 037

      HTTP_SetfileCCSID() is the CCSID used to set the CCSID property of the received stream file - but that has no bearing on its actual content, which is controlled by http_setCCSIDs()

      Am I right?

      I have some further questions:

      If I have data that is already CSSID 1208, and I want the received stream file to be CCSID 1208 in content and in the CCSID property, Would I use:

      When I set the CCSID's with those functions, what do level do they apply to? Just this instance of the program? The job? Something else?
      And if I do not set them, what are the default values?


      • #4
        Ah, yes, sorry... I misread your original post. http_setCCSIDs() is how the data that is passed to variables in your RPG code is translated.

        http_setFileCCSID() controls the CCSID used when using http_url_post to save a file. In that case, HTTPAPI never translates the data (the data saved to a file is simply written as-is) so you shouldn't have to do anything with http_setCCSIDs in that case.


        • #5
          So when using http_url_post(), http_setCCSIDs() controls translation of the request data host variable, but the response data is saved as-is.

          What about when using http_url_post_stmf()? Does the request stream file get translated according to http_setCCSIDs(), or send as-is?


          • #6
            http_url_post_stmf() does not translate either the request.


            sponsored links