Change content-type for WAM

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
kno_dk
Posts: 127
Joined: Tue Feb 23, 2016 12:00 am

Change content-type for WAM

Post by kno_dk » Mon May 11, 2020 9:09 pm

I have a question regarding WAM. is it possible to change the content-type and charset to “application/json; charset=UTF-8” from the original “text/html; charset=ISO-8859-1”?

If I change the response to *json then it sends the “application/json; charset=UTF-8” but I would like to build the respons in the xsl myself so I have to have the response set to *default.

/klaus

AbelS
Posts: 32
Joined: Wed Nov 16, 2016 1:43 pm
Location: Sydney, Australia
Contact:

Re: Change content-type for WAM

Post by AbelS » Tue May 12, 2020 10:27 am

If you want to prepare your own custom JSON (but not use web services), you can send the response as a CLOB. With a CLOB, you set the response headers yourself.

HTH
Abel

kno_dk
Posts: 127
Joined: Tue Feb 23, 2016 12:00 am

Re: Change content-type for WAM

Post by kno_dk » Tue May 12, 2020 7:07 pm

Hi Abel.

Should I then set the resonse as *Default or JSON in the WAM?
If it is default then I would still have the content-type text/html, and if it is JSON then I have a lot of json describing the wam routine in the respons.
Do you have an example?

/klaus

AbelS
Posts: 32
Joined: Wed Nov 16, 2016 1:43 pm
Location: Sydney, Australia
Contact:

Re: Change content-type for WAM

Post by AbelS » Wed May 13, 2020 9:12 am

HI Klaus

Here is the topic about LOBs and how to create them and set custom HTTP headers:

https://docs.lansa.com/14/en/lansa087/i ... s%7C_____0

Abel

kno_dk
Posts: 127
Joined: Tue Feb 23, 2016 12:00 am

Re: Change content-type for WAM

Post by kno_dk » Wed May 13, 2020 7:54 pm

Hi

I have now tried it like in the manual. if I change the content type to application/json I get this result:

�����������z������G

I have tried to add charset := 'UTF-8' but same result.

If i don't change the Contenttype there is no problem. But I need to have the contenttype to application/json.

this is running on an IBM I.

Any suggestion?

/klaus

AbelS
Posts: 32
Joined: Wed Nov 16, 2016 1:43 pm
Location: Sydney, Australia
Contact:

Re: Change content-type for WAM

Post by AbelS » Thu May 14, 2020 9:40 am

If you use content-type application/* then the runtime won't do any transcoding (that is, it handles the content as binary). If you want to use application/json, then you need to create your BLOB content with the target encoding (ISO-8859-1 or UTF-8 . Note that if you are on IBM i, any text content in native encoding will be in EBCDIC.

Abel

kno_dk
Posts: 127
Joined: Tue Feb 23, 2016 12:00 am

Re: Change content-type for WAM

Post by kno_dk » Thu May 14, 2020 5:46 pm

Hi Abel.

So what you are saying is that this could not be done on an IBM I? or is there a way around this conversion issue?

If I define thr response as JSON then it is convertet correct, but then I am not able to control the output as much as I want

/klaus

soa
Posts: 334
Joined: Mon Dec 07, 2015 3:15 pm

Re: Change content-type for WAM

Post by soa » Fri May 15, 2020 8:42 am

I think you can create a temporary ifs file with the encoding you want and write your content to it then use that file as the http response. Then the temporary file can be automatically deleted.

Post Reply