Programming Languages on Power

Power Programming Languages

IBM Power, including the AIX, IBM i, and Linux operating systems, support a wide range of programming languages, catering to both traditional enterprise applications and modern development needs.


#Power


#Servers
#Programminglanguages
 View Only
  • 1.  HTTP_XXX functions

    Posted 02/26/24 11:56 AM

    I hope you can help me. My problem: I'm programming a web api using http_xxx functions. My service client are running well if encoding is utf-8. Now I have to communicate with a service that is passing back data using enconding iso-889-1.  When i try to parse the response using xmltable i get SQLState: SQ16168, which means that my encoding is wrong, which is obvious.

    I then changed the encoding declaration in the response like this: set Response_payload = replace(Response_Payload, 'encoding="ISO-8859-1''encoding="utf-8');

    Then I parsed the resonse using xmltable(). success. But there is one caveat: As soon as there are special characters in the response replacing the encoding declaration fails with error SQL0191: A mixed data value is improperly formed.

    I learned that all http_xxx funcions use the axis api and this api passses back data encodes with utf-8.

    Does anyone know of a way to override this behavior or of any other solution to fix this problem?

    Any help would be appreciated!



    ------------------------------
    Klaus-Peter Luttkus
    ------------------------------

    #SQL


  • 2.  RE: HTTP_XXX functions

    Posted 02/27/24 04:38 PM

    You could try  obtaining the data as binary using HTTP_XXX_BLOB, not changing the encoding in the result, and then calling xmltable to process the data.

    This query uses XMLTable to parse an XML document in encoding ISO-8859-1. 

    elect * from xmltable('$d' passing XMLPARSE(DOCUMENT VARBINARY(CAST('<?xml version="1.0"  encoding="ISO-8859-1" ?><Body>Sometext' AS VARCHAR(80) CCSID 1208)) || BX'B6' ||  VARBINARY(CAST('</Body>' AS VARCHAR(80) CCSID 1208))) as "d"  columns Body XML path 'Body') as x

    In ACS Run SQL Scripts this returns:  Sometext¶



    ------------------------------
    Kent Milligan
    ------------------------------