Monday, January 13, 2014

UTF-8 string support in API manager - create APIs, Applications with different languages

Here are the steps i followed in order to work UTF8 functionality in API Manager 1.4.0.
01. Create API manager database using scripts found in API Manager distribution.
02. Change master-datasources.xml to point new API manager database.
Configuration is shown below
                    <validationQuery>SELECT 1</validationQuery> 

03. Run alter database and table commands as follows.
   ALTER DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;
   ALTER TABLE database_name_table_names CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

04. Run following command to check changes. All field values should contain utf8_unicode_ci, utf8_general_ci or desired type.
    show variables like 'collation%';

05. add following to /etc/mysql/my.cnf and restart MySQL server.
   collation-server = utf8_unicode_ci
   init-connect='SET NAMES utf8'
   character-set-server = utf8

Also followed below instructions.
 validated that there was a character set filter in /repository/conf/tomcat/carbon/WEB-INF/web.xml
 updated /repository/conf/tomcat/catalina-server.xml and added URIEncoding="UTF-8" in both Connectors
 included -Dfile.encoding=UTF-8 in /bin/ java startup command

06. Start API manager and perform following actions.
    create API with Japanese string. API stored in API manager database and registry properly.
    create Application with Japanese name(application name persisted to database without issue).
    create subscription and generate keys. Invoke APIs.

Here i have attached screen-shots for store and publisher and how data stored in database. After applying those configurations i was able to perform API manager operations as expected.

No comments:

Post a Comment