- Add Plugin Manager to Notepad++ if it is not listed under "Plugins".
- Download the latest Notepad++ plugin manager from here.
- Extract the downloaded zip file.
- Import "PluginManager.dll" to Notepad++ ( Settings > Import > Import plugin(s) ) inside the plugin folder of the extracted folder.
- If it is not working, copy PluginManager.dll to plugins folder inside Notepad++ installed folder.

- Copy gpup.exe inside the plugin folder of the extracted folder to updater directory where Notepad++ installed.
- Now you will see "Plugin Manager" in Notepad++ (Plugins -> Plugin Manager)
- Then go to Plugins > Plugin Manager > Show Plugin Manager. Then select XML Tools plugin and click Install.
- Open XML document you want to validate and go to Plugins > XML Tools > Validate Now. Then, the following dialog will be open.
- Then select the relevant xsd file and click OK.
- If the validations are fine, you will receive following message.
- Else you will receive the following message with error reasons.
Thursday, August 30, 2018
Validate XML against XSD with Notepad++
Friday, May 26, 2017
How to allow remote connection to mysql
By default, In MySQL, remote access is disabled.
First, execute below SQL command to enable all the privileges. Here, I'm using "root" as the user and "abc123" as the password.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'abc123' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Then open /etc/mysql/my.cnf from Unix/OSX systems. If it's a Windows system, you can find it in the MySQL installation directory, usually, something like
And then find the following line from my.inf and comment out .
C:\Program Files\MySQL\MySQL Server 5.5\ and the filename will be my.iniAnd then find the following line from my.inf and comment out .
Change line
bind-address = 127.0.0.1
to
#bind-address = 127.0.0.1
Then, restart MYSQL server for the changes to take effect.
Tuesday, February 28, 2017
How to block the login for the Management Console of WSO2 IoT Server
Put the following config to <IoTS_HOME>/core/repository/conf/tomcat/carbon/WEB-INF/web.xml.
Then restart the server.
<security-constraint>
<display-name>Restrict direct access to certain folders</display-name>
<web-resource-collection>
<web-resource-name>Restricted folders</web-resource-name>
<url-pattern>/carbon/*</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
Wednesday, January 18, 2017
[WSO2 IoT] How to Self-unsubscribe from Mobile Apps.
In default WSO2 IoT server, you can't uninstall mobile apps from the apps store. But, you can self-unsubscribe from mobile apps by changing a config. For that, you have to set "EnableSelfUnsubscription" as true in <IoT_HOME>/core/repository/conf/app-manager.xml
Then, restart the server.
Login to store and click on "My Apps" tab. Click on the button (with 3 dots) in the bottom right corner of the app and click on "Uninstall".
That's all. :)
<Config name="EnableSelfUnsubscription">true</Config>
Then, restart the server.
Login to store and click on "My Apps" tab. Click on the button (with 3 dots) in the bottom right corner of the app and click on "Uninstall".
That's all. :)
Saturday, December 31, 2016
How to Use log4jdbc with WSO2 Products
log4jdbc is a Java JDBC driver that can log JDBC calls. There are some steps to use it in WSO2 products.
Let's see how to use log4jdbc with WSO2 API Manager.
First, download log4jdbc driver from here. Then, copy it into <APIM_HOME>/repository/components/lib directory.
Then, change JDBC <url> and <driverClassName> of master-datasource.xml in <APIM_HOME>/repository/conf/datasources directory as shown below. Change the every datasource that you want to log. Here, I'm changing datasource of "WSO2AM_DB".
Note: When you are changing JDBC url, you have to add "log4jdbc" part to the url.
Then, you can add logging options to log4j.properties file of <APIM_HOME>/repository/conf directory. There are several logging options.
i. jdbc.sqlonly
If we use this log, it logs all the SQLs executed by Java Code.
If you want to enable that logs of your server, add below line to log4.properties file.
Then restart the server and you will see logs like below.
ii. jdbc.sqltiming
If we use this log, it logs time taken by each JDBC call.
If you want to enable that logs of your server, add below line to log4.properties file.
Then restart the server and you will see logs like below.
iii. jdbc.audit
If we use this log, it logs all the activities of the JDBC call.
If you want to enable that logs of your server, add below line to log4.properties file.
Then restart the server and you will see logs like below.
iv. jdbc.resultset
v. jdbc.connection
Let's see how to use log4jdbc with WSO2 API Manager.
First, download log4jdbc driver from here. Then, copy it into <APIM_HOME>/repository/components/lib directory.
Then, change JDBC <url> and <driverClassName> of master-datasource.xml in <APIM_HOME>/repository/conf/datasources directory as shown below. Change the every datasource that you want to log. Here, I'm changing datasource of "WSO2AM_DB".
<datasource> <name>WSO2AM_DB</name> <description>The datasource used for API Manager database</description> <jndiConfig> <name>jdbc/WSO2AM_DB</name> </jndiConfig> <definition type="RDBMS"> <configuration> <url>jdbc:log4jdbc:h2:repository/database/WSO2AM_DB;DB_CLOSE_ON_EXIT=FALSE</url> <username>wso2carbon</username> <password>wso2carbon</password> <defaultAutoCommit>false</defaultAutoCommit> <driverClassName>net.sf.log4jdbc.DriverSpy</driverClassName> <maxActive>50</maxActive> <maxWait>60000</maxWait> <testOnBorrow>true</testOnBorrow> <validationQuery>SELECT 1</validationQuery> <validationInterval>30000</validationInterval> </configuration> </definition> </datasource>
Note: When you are changing JDBC url, you have to add "log4jdbc" part to the url.
Then, you can add logging options to log4j.properties file of <APIM_HOME>/repository/conf directory. There are several logging options.
i. jdbc.sqlonly
If we use this log, it logs all the SQLs executed by Java Code.
If you want to enable that logs of your server, add below line to log4.properties file.
log4j.logger.jdbc.sqlonly=INFO
Then restart the server and you will see logs like below.
[2016-12-31 23:26:35,099] INFO - JMSListener Started to listen on destination : throttleData of type topic for listener Siddhi-JMS-Consumer#throttleData [2016-12-31 23:26:55,502] INFO - CarbonEventManagementService Starting polling event receivers [2016-12-31 23:27:16,213] INFO - sqlonly SELECT 1 [2016-12-31 23:27:16,214] INFO - sqlonly select * from AM_BLOCK_CONDITIONS [2016-12-31 23:27:16,214] INFO - sqlonly SELECT KEY_TEMPLATE FROM AM_POLICY_GLOBAL [2016-12-31 23:37:24,224] INFO - PermissionUpdater Permission cache updated for tenant -1234 [2016-12-31 23:37:24,316] INFO - CarbonAuthenticationUtil 'admin@carbon.super [-1234]' logged in at [2016-12-31 23:37:24,316+0530] [2016-12-31 23:37:24,587] INFO - sqlonly SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI' AND API.API_VERSION = '1.0.0' [2016-12-31 23:37:24,589] INFO - sqlonly SELECT CAST( SUM(RATING) AS DECIMAL)/COUNT(RATING) AS RATING FROM AM_API_RATINGS WHERE API_ID =2 GROUP BY API_ID [2016-12-31 23:37:24,590] INFO - sqlonly SELECT * FROM AM_API WHERE API_ID = 2 [2016-12-31 23:37:24,590] INFO - sqlonly SELECT NAME FROM AM_POLICY_SUBSCRIPTION WHERE TENANT_ID =-1234 [2016-12-31 23:37:24,593] INFO - sqlonly SELECT grp.CONDITION_GROUP_ID ,AUM.HTTP_METHOD,AUM.AUTH_SCHEME, pol.APPLICABLE_LEVEL, AUM.URL_PATTERN,AUM.THROTTLING_TIER,AUM.MEDIATION_SCRIPT,AUM.URL_MAPPING_ID FROM AM_API_URL_MAPPING AUM INNER JOIN AM_API API ON AUM.API_ID = API.API_ID LEFT OUTER JOIN AM_API_THROTTLE_POLICY pol ON AUM.THROTTLING_TIER = pol.NAME LEFT OUTER JOIN AM_CONDITION_GROUP grp ON pol.POLICY_ID = grp.POLICY_ID where API.CONTEXT= '/pizzashack/1.0.0' AND API.API_VERSION = '1.0.0' ORDER BY AUM.URL_MAPPING_ID [2016-12-31 23:37:24,596] INFO - sqlonly SELECT DISTINCT SB.USER_ID, SB.DATE_SUBSCRIBED FROM AM_SUBSCRIBER SB, AM_SUBSCRIPTION SP, AM_APPLICATION APP, AM_API API WHERE API.API_PROVIDER='admin' AND API.API_NAME='PizzaShackAPI' AND API.API_VERSION='1.0.0' AND SP.APPLICATION_ID=APP.APPLICATION_ID AND APP.SUBSCRIBER_ID=SB.SUBSCRIBER_ID AND API.API_ID = SP.API_ID AND SP.SUBS_CREATE_STATE = 'SUBSCRIBE' [2016-12-31 23:37:31,323] INFO - sqlonly SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI' AND API.API_VERSION = '1.0.0' [2016-12-31 23:37:31,327] INFO - sqlonly SELECT CAST( SUM(RATING) AS DECIMAL)/COUNT(RATING) AS RATING FROM AM_API_RATINGS WHERE API_ID =2 GROUP BY API_ID [2016-12-31 23:37:31,327] INFO - sqlonly SELECT * FROM AM_API WHERE API_ID = 2 [2016-12-31 23:37:31,327] INFO - sqlonly SELECT NAME FROM AM_POLICY_SUBSCRIPTION WHERE TENANT_ID =-1234
ii. jdbc.sqltiming
If we use this log, it logs time taken by each JDBC call.
If you want to enable that logs of your server, add below line to log4.properties file.
log4j.logger.jdbc.sqltiming=INFO
Then restart the server and you will see logs like below.
[2016-12-31 23:42:02,597] INFO - PermissionUpdater Permission cache updated for tenant -1234
[2016-12-31 23:42:02,682] INFO - CarbonAuthenticationUtil 'admin@carbon.super [-1234]' logged in at [2016-12-31 23:42:02,682+0530]
[2016-12-31 23:42:02,912] INFO - sqltiming SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI'
AND API.API_VERSION = '1.0.0'
{executed in 1 msec}
[2016-12-31 23:42:02,913] INFO - sqltiming SELECT CAST( SUM(RATING) AS DECIMAL)/COUNT(RATING) AS RATING FROM AM_API_RATINGS WHERE API_ID
=2 GROUP BY API_ID
{executed in 0 msec}
[2016-12-31 23:42:02,913] INFO - sqltiming SELECT * FROM AM_API WHERE API_ID = 2
{executed in 0 msec}
[2016-12-31 23:42:02,914] INFO - sqltiming SELECT NAME FROM AM_POLICY_SUBSCRIPTION WHERE TENANT_ID =-1234
{executed in 0 msec}
[2016-12-31 23:42:02,917] INFO - sqltiming SELECT grp.CONDITION_GROUP_ID ,AUM.HTTP_METHOD,AUM.AUTH_SCHEME, pol.APPLICABLE_LEVEL, AUM.URL_PATTERN,AUM.THROTTLING_TIER,AUM.MEDIATION_SCRIPT,AUM.URL_MAPPING_ID
FROM AM_API_URL_MAPPING AUM INNER JOIN AM_API API ON AUM.API_ID = API.API_ID LEFT OUTER JOIN
AM_API_THROTTLE_POLICY pol ON AUM.THROTTLING_TIER = pol.NAME LEFT OUTER JOIN AM_CONDITION_GROUP
grp ON pol.POLICY_ID = grp.POLICY_ID where API.CONTEXT= '/pizzashack/1.0.0' AND API.API_VERSION
= '1.0.0' ORDER BY AUM.URL_MAPPING_ID
{executed in 0 msec}
[2016-12-31 23:42:02,920] INFO - sqltiming SELECT DISTINCT SB.USER_ID, SB.DATE_SUBSCRIBED FROM AM_SUBSCRIBER SB, AM_SUBSCRIPTION SP, AM_APPLICATION
APP, AM_API API WHERE API.API_PROVIDER='admin' AND API.API_NAME='PizzaShackAPI' AND API.API_VERSION='1.0.0'
AND SP.APPLICATION_ID=APP.APPLICATION_ID AND APP.SUBSCRIBER_ID=SB.SUBSCRIBER_ID AND API.API_ID
= SP.API_ID AND SP.SUBS_CREATE_STATE = 'SUBSCRIBE'
{executed in 0 msec}
[2016-12-31 23:42:12,871] INFO - sqltiming SELECT 1
{executed in 0 msec}
[2016-12-31 23:42:12,872] INFO - sqltiming SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI'
AND API.API_VERSION = '1.0.0'
{executed in 0 msec}
[2016-12-31 23:42:12,872] INFO - sqltiming SELECT CAST( SUM(RATING) AS DECIMAL)/COUNT(RATING) AS RATING FROM AM_API_RATINGS WHERE API_ID
=2 GROUP BY API_ID
{executed in 0 msec}
[2016-12-31 23:42:12,873] INFO - sqltiming SELECT * FROM AM_API WHERE API_ID = 2
{executed in 0 msec}
[2016-12-31 23:42:12,873] INFO - sqltiming SELECT * FROM AM_POLICY_SUBSCRIPTION WHERE TENANT_ID =-1234
{executed in 0 msec}
[2016-12-31 23:42:12,874] INFO - sqltiming SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI'
AND API.API_VERSION = '1.0.0'
{executed in 0 msec}
[2016-12-31 23:42:12,875] INFO - sqltiming SELECT A.SCOPE_ID, A.SCOPE_KEY, A.NAME, A.DESCRIPTION, A.ROLES FROM IDN_OAUTH2_SCOPE AS A INNER
JOIN AM_API_SCOPES AS B ON A.SCOPE_ID = B.SCOPE_ID WHERE B.API_ID = 2
{executed in 0 msec}
[2016-12-31 23:42:12,875] INFO - sqltiming SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI'
AND API.API_VERSION = '1.0.0'
{executed in 0 msec}
[2016-12-31 23:42:12,875] INFO - sqltiming SELECT URL_PATTERN, HTTP_METHOD, AUTH_SCHEME, THROTTLING_TIER, MEDIATION_SCRIPT FROM AM_API_URL_MAPPING
WHERE API_ID = 2 ORDER BY URL_MAPPING_ID ASC
{executed in 0 msec}
[2016-12-31 23:42:12,876] INFO - sqltiming SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = 'admin' AND API.API_NAME = 'PizzaShackAPI'
AND API.API_VERSION = '1.0.0'
{executed in 0 msec}
[2016-12-31 23:42:12,876] INFO - sqltiming SELECT RS.RESOURCE_PATH, S.SCOPE_KEY FROM IDN_OAUTH2_RESOURCE_SCOPE RS INNER JOIN IDN_OAUTH2_SCOPE
S ON S.SCOPE_ID = RS.SCOPE_ID INNER JOIN AM_API_SCOPES A ON A.SCOPE_ID = RS.SCOPE_ID WHERE
A.API_ID = 2
{executed in 0 msec}
iii. jdbc.audit
If we use this log, it logs all the activities of the JDBC call.
If you want to enable that logs of your server, add below line to log4.properties file.
log4j.logger.jdbc.audit=ON
Then restart the server and you will see logs like below.
[2016-12-31 23:44:55,631] INFO - CarbonAuthenticationUtil 'admin@carbon.super [-1234]' logged in at [2016-12-31 23:44:55,631+0530] [2016-12-31 23:44:55,828] DEBUG - audit 2. Statement.new Statement returned org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:454) [2016-12-31 23:44:55,829] DEBUG - audit 2. Connection.createStatement() returned net.sf.log4jdbc.StatementSpy@44c41ca9 org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:454) [2016-12-31 23:44:55,829] DEBUG - audit 2. Statement.execute(SELECT 1) returned true org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:461) [2016-12-31 23:44:55,830] DEBUG - audit 2. Statement.close() returned org.apache.tomcat.jdbc.pool.PooledConnection.validate(PooledConnection.java:462) [2016-12-31 23:44:55,830] DEBUG - audit 2. PreparedStatement.new PreparedStatement returned sun.reflect.GeneratedMethodAccessor31.invoke(null:-1) [2016-12-31 23:44:55,830] DEBUG - audit 2. Connection.prepareStatement(SELECT API.API_ID FROM AM_API API WHERE API.API_PROVIDER = ? AND API.API_NAME = ? AND API.API_VERSION = ?) returned net.sf.log4jdbc.PreparedStatementSpy@396ee038 sun.reflect.GeneratedMethodAccessor31.invoke(null:-1) [2016-12-31 23:44:55,831] DEBUG - audit 2. PreparedStatement.setString(1, "admin") returned org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getAPIID(ApiMgtDAO.java:6217) [2016-12-31 23:44:55,831] DEBUG - audit 2. PreparedStatement.setString(2, "PizzaShackAPI") returned org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getAPIID(ApiMgtDAO.java:6218) [2016-12-31 23:44:55,831] DEBUG - audit 2. PreparedStatement.setString(3, "1.0.0") returned org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getAPIID(ApiMgtDAO.java:6219) [2016-12-31 23:44:55,831] DEBUG - audit 2. PreparedStatement.executeQuery() returned net.sf.log4jdbc.ResultSetSpy@1e4299fd org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getAPIID(ApiMgtDAO.java:6220) [2016-12-31 23:44:55,831] DEBUG - audit 2. PreparedStatement.close() returned org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer.closeInvoked(StatementFinalizer.java:57) [2016-12-31 23:44:55,832] DEBUG - audit 2. Connection.getAutoCommit() returned false org.wso2.carbon.ndatasource.rdbms.ConnectionRollbackOnReturnInterceptor.invoke(ConnectionRollbackOnReturnInterceptor.java:44) [2016-12-31 23:44:55,832] DEBUG - audit 2. Connection.rollback() returned org.wso2.carbon.ndatasource.rdbms.ConnectionRollbackOnReturnInterceptor.invoke(ConnectionRollbackOnReturnInterceptor.java:45) [2016-12-31 23:44:55,832] DEBUG - audit 2. PreparedStatement.close() returned org.wso2.carbon.apimgt.impl.utils.APIMgtDBUtil.closeStatement(APIMgtDBUtil.java:175) [2016-12-31 23:44:55,833] DEBUG - audit 2. Connection.setAutoCommit(false) returned sun.reflect.GeneratedMethodAccessor32.invoke(null:-1) [2016-12-31 23:44:55,834] DEBUG - audit 2. PreparedStatement.new PreparedStatement returned sun.reflect.GeneratedMethodAccessor31.invoke(null:-1) [2016-12-31 23:44:55,834] DEBUG - audit 2. Connection.prepareStatement( SELECT CAST( SUM(RATING) AS DECIMAL)/COUNT(RATING) AS RATING FROM AM_API_RATINGS WHERE API_ID =? GROUP BY API_ID ) returned net.sf.log4jdbc.PreparedStatementSpy@70a2e307 sun.reflect.GeneratedMethodAccessor31.invoke(null:-1) [2016-12-31 23:44:55,834] DEBUG - audit 2. PreparedStatement.setInt(1, 2) returned org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getAverageRating(ApiMgtDAO.java:3969)
If we use this log, it logs the result set of each JDBC call.
If you want to enable that logs of your server, add below line to log4.properties file.
Then restart the server and you will see logs like below.
log4j.logger.jdbc.resultset=INFO
Then restart the server and you will see logs like below.
[2016-12-31 23:47:41,386] INFO - PermissionUpdater Permission cache updated for tenant -1234 [2016-12-31 23:47:41,478] INFO - CarbonAuthenticationUtil 'admin@carbon.super [-1234]' logged in at [2016-12-31 23:47:41,478+0530] [2016-12-31 23:47:41,683] INFO - resultset 2. ResultSet.new ResultSet returned [2016-12-31 23:47:41,684] INFO - resultset 2. ResultSet.next() returned true [2016-12-31 23:47:41,684] INFO - resultset 2. ResultSet.getInt(API_ID) returned 2 [2016-12-31 23:47:41,685] INFO - resultset 2. ResultSet.close() returned [2016-12-31 23:47:41,686] INFO - resultset 2. ResultSet.new ResultSet returned [2016-12-31 23:47:41,686] INFO - resultset 2. ResultSet.next() returned false [2016-12-31 23:47:41,686] INFO - resultset 2. ResultSet.close() returned [2016-12-31 23:47:41,688] INFO - resultset 2. ResultSet.new ResultSet returned [2016-12-31 23:47:41,688] INFO - resultset 2. ResultSet.next() returned true [2016-12-31 23:47:41,688] INFO - resultset 2. ResultSet.getString(API_TIER) returned null [2016-12-31 23:47:41,688] INFO - resultset 2. ResultSet.next() returned false [2016-12-31 23:47:41,688] INFO - resultset 2. ResultSet.close() returned [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.new ResultSet returned [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.next() returned true [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.getString(NAME) returned Gold [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.getString(QUOTA_TYPE) returned requestCount [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.getString(QUOTA_TYPE) returned requestCount [2016-12-31 23:47:41,689] INFO - resultset 2. ResultSet.getInt(UNIT_TIME) returned 1 [2016-12-31 23:47:41,690] INFO - resultset 2. ResultSet.getString(TIME_UNIT) returned min [2016-12-31 23:47:41,690] INFO - resultset 2. ResultSet.getInt(QUOTA) returned 5000 [2016-12-31 23:47:41,690] INFO - resultset 2. ResultSet.getString(UUID) returned e4eee273-4eb0-4d8c-9f6d-f503b58c7dd0
v. jdbc.connection
If we use this log, it logs connection details like opening and closing the database connections.
If you want to enable that logs of your server, add below line to log4.properties file.
Then restart the server and you will see logs like below.
log4j.logger.jdbc.connection=INFO
Then restart the server and you will see logs like below.
[2016-12-31 23:55:47,521] INFO - connection 2. Connection closed [2016-12-31 23:55:47,523] INFO - connection 4. Connection closed [2016-12-31 23:55:54,447] INFO - EmbeddedRegistryService Configured Registry in 0ms [2016-12-31 23:55:54,708] INFO - connection 5. Connection opened
Friday, December 30, 2016
Disable Chunking in WSO2 API Manager
By default in WSO2 API Manager, chunking is enabled. You can check it by enabling wire logs in API Manager. If you send a "PUT" or "POST" request, you will see "Transfer-Encoding: chunked" header like below in outgoing request.
But sometimes backends don't support chunking. In such cases you have to disable chunking. For that there are two ways.
Method 01 :
If you want to disable chunking in all APIs, you can add highlighted line to <inSequence> of velocity.xml in <APIM_HOME>/repository/resources/api_templates/
Then restart the server. Changing this file will affect future APIs created in API manager. If you want to disable chunking in old APIs as well, you have to republish old APIs.
Method 02 :
If you want to disable chunking only for certain APIs, you can use a custom mediation extension.
1. Create a sequence to disable chunking like below and save it in the file system.
2. Edit the API from API Publisher.
3. Go to "Implement" Tab and check "Enable Message Mediation".
4. Upload above created sequence to "In Flow" under "Message Mediation Policies"
[2016-12-30 11:57:27,125] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "POST /am/sample/pizzashack/v1/api/order HTTP/1.1[\r][\n]" [2016-12-30 11:57:27,125] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Accept-Language: en-US,en;q=0.8[\r][\n]" [2016-12-30 11:57:27,125] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate[\r][\n]" [2016-12-30 11:57:27,125] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Origin: https://localhost:9443[\r][\n]" [2016-12-30 11:57:27,125] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Content-Type: application/json; charset=UTF-8[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Accept: application/json[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Transfer-Encoding: chunked[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Host: localhost:9443[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "a4[\r][\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "{[\n]" [2016-12-30 11:57:27,126] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "customerName": "string",[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "delivered": true,[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "address": "string",[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "pizzaType": "string",[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "creditCardNumber": "string",[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "quantity": 0,[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << " "orderId": 0[\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "}[\r][\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "0[\r][\n]" [2016-12-30 11:57:27,127] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "[\r][\n]"
But sometimes backends don't support chunking. In such cases you have to disable chunking. For that there are two ways.
Method 01 :
If you want to disable chunking in all APIs, you can add highlighted line to <inSequence> of velocity.xml in <APIM_HOME>/repository/resources/api_templates/
<inSequence> ## check and set response caching #if($responseCacheEnabled) <cache scope="per-host" collector="false" hashGenerator="org.wso2.caching.digest.REQUESTHASHGenerator" timeout="$!responseCacheTimeOut"> <implementation type="memory" maxSize="500"/> </cache> #end <property name="api.ut.backendRequestTime" expression="get-property('SYSTEM_TIME')"/> ############## define the filter based on environment type production only, sandbox only , hybrid ############ #if(($environmentType == 'sandbox') || ($environmentType =='hybrid' && !$endpoint_config.get("production_endpoints") )) #set( $filterRegex = "SANDBOX" ) #else #set( $filterRegex = "PRODUCTION" ) #end <property name="DISABLE_CHUNKING" value="true" scope="axis2"/> #if($apiStatus != 'PROTOTYPED') <filter source="$ctx:AM_KEY_TYPE" regex="$filterRegex"> <then> #end #if(($environmentType == 'sandbox') || ($environmentType =='hybrid' && ! $endpoint_config.get("production_endpoints") )) #draw_endpoint( "sandbox" $endpoint_config ) #else #draw_endpoint( "production" $endpoint_config ) #end #if($apiStatus != 'PROTOTYPED') </then> <else> #if($environmentType !='hybrid') <payloadFactory> <format> <error xmlns=""> #if($environmentType == 'production') <message>Sandbox Key Provided for Production Gateway</message> #elseif($environmentType == 'sandbox') <message>Production Key Provided for Sandbox Gateway</message> #end </error> </format> </payloadFactory> <property name="ContentType" value="application/xml" scope="axis2"/> <property name="RESPONSE" value="true"/> <header name="To" action="remove"/> <property name="HTTP_SC" value="401" scope="axis2"/> <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/> <send/> #else #if($endpoint_config.get("production_endpoints") && $endpoint_config.get("sandbox_endpoints")) #draw_endpoint( "sandbox" $endpoint_config ) #elseif($endpoint_config.get("production_endpoints")) <sequence key="_sandbox_key_error_"/> #elseif($endpoint_config.get("sandbox_endpoints")) <sequence key="_production_key_error_"/> #end #end </else> </filter> #end </inSequence>
Then restart the server. Changing this file will affect future APIs created in API manager. If you want to disable chunking in old APIs as well, you have to republish old APIs.
Method 02 :
If you want to disable chunking only for certain APIs, you can use a custom mediation extension.
1. Create a sequence to disable chunking like below and save it in the file system.
<?xml version="1.0" encoding="UTF-8"?> <sequence xmlns="http://ws.apache.org/ns/synapse" name="chunk-disable-sequence"> <property name="DISABLE_CHUNKING" value="true" scope="axis2" /> </sequence>
2. Edit the API from API Publisher.
3. Go to "Implement" Tab and check "Enable Message Mediation".
4. Upload above created sequence to "In Flow" under "Message Mediation Policies"
5. Then save API.
Now chunking is disabled for that particular API.
If you send a "PUT" or "POST" request, you will see "Content-Length" header instead of "Transfer-Encoding: chunked" header like below in outgoing request.
[2016-12-30 13:22:18,877] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "POST /am/sample/pizzashack/v1/api/order HTTP/1.1[\r][\n]"
[2016-12-30 13:22:18,877] DEBUG - wire HTTPS-Sender I/O dispatcher-1 <<<< "Accept-Language: en-US,en;q=0.8[\r][\n]"
[2016-12-30 13:22:18,877] DEBUG - wire HTTPS-Sender I/O dispatcher-1 "Accept-Encoding: gzip, deflate[\r][\n]" [2016-12-30 13:22:18,877] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Origin: https://localhost:9443[\r][\n]" [2016-12-30 13:22:18,877] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Content-Type: application/json; charset=UTF-8[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Accept: application/json[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Content-Length: 135[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Host: localhost:9443[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "[\r][\n]" [2016-12-30 13:22:18,878] DEBUG - wire HTTPS-Sender I/O dispatcher-1 << "{"customerName":"string","delivered":true,"address":"string","pizzaType":"string","creditCardNumber":"string","quantity":0,"orderId":0}" [2016-12-30 13:22:19,084] DEBUG - wire HTTPS-Sender I/O dispatcher-1 >> "HTTP/1.1 201 Created[\r][\n]"
Saturday, December 10, 2016
Adding a New Store Logo to Enterprise Mobility Manager(EMM)
I explained how to change styles (background colors, fonts etc.) of Store of WSO2 EMM from this.
By default, WSO2 EMM Store comes with WSO2 logo. But you can change it easily.
Today, from this post I'm going to show how to change the logo of Store of EMM.
First, Create a directory called "carbon.super/themes" inside <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/.
Then, Create a directory called "custom/libs/theme-wso2_1.0/images" inside <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/carbon.super/themes.
Copy your logo to <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/carbon.super/themes/custom/libs/theme-wso2_1.0/images. Let's assume the image name is "myimage.png".
Then, Add image name to <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/store/partials/header.hbs. Change the Image name of <img> tag with a class name of "logo"
If you want to change the Store name, change the value of <h1> with a class name "display-block-xs".
Refresh store. Store will look like below.
By default, WSO2 EMM Store comes with WSO2 logo. But you can change it easily.
Today, from this post I'm going to show how to change the logo of Store of EMM.
First, Create a directory called "carbon.super/themes" inside <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/.
Then, Create a directory called "custom/libs/theme-wso2_1.0/images" inside <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/carbon.super/themes.
Copy your logo to <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/carbon.super/themes/custom/libs/theme-wso2_1.0/images. Let's assume the image name is "myimage.png".
Then, Add image name to <EMM_HOME>/repository/deployment/server/jaggeryapps/store/themes/store/partials/header.hbs. Change the Image name of <img> tag with a class name of "logo"
<img src="{{customThemeUrl "/libs/theme-wso2_1.0/images/myimage.png"}}" alt="apps-store" title="apps-store" class="logo" />
If you want to change the Store name, change the value of <h1> with a class name "display-block-xs".
<h1 class="display-block-xs">Google Apps Store</h1>
Refresh store. Store will look like below.
Subscribe to:
Posts (Atom)






