Using placeholders in WSO2 DSS dbs files for DB connection params - wso2

Is it possible to use placeholders in WSO2 DSS db connection params - e.g. ${prod.db.url} and replace them in runtime from Registry?
Thanks.

The datasource connection is checked and established in the dataservice deployment time. Therefore, you have to provide the datasource configurations such as driver class name, connection url. etc. at the deployment time.

Since the datasource configurations like db url, driver name, user name, password is needed during deployment stage, its not possible to refer the same from registry.
I assume your requirement comes from the need to manage different environments, to achieve the same, have the option to create datasources at server level, called Carbon_Datasources.
These datasources can be referred from .dbs file like the below one. In the below example, serviceDS is the datasource configured.
<config id="rs">
<property name="carbon_datasource_name">serviceDS</property>
</config>
<query id="deliveryService" useConfig="rs">
Refer here for adding different types of datasources and here for managing the same.

Related

Specifying connection parameter values as registry entries in DB report mediator in WSO2 EI

I am trying to insert data into a database using the DB report mediator in WSO2 EI. Using Integration Studio 8.0.0 for developing the API. Everything works fine on hardcoding the connection parameters inline as shown below.
Now, I want to specify the connection parameters as registry entries. So, created local entries under registry config. But not sure how to set them as parameters in DB report configuration. When I tried as below, it reads the entire content of the registry local entry instead of just the value and fails. Need suggestions on how we can set the connection parameters as registry entries?

Cannot browse the h2 database from a web browser in WSO2 api manager

I am trying to browse local H2 db for WSO2 api manager. I made the change in the WSO2_HOME/repository/conf/carbon.xml. I added below configuration.
<H2DatabaseConfiguration>
<property name="web"/>
<property name="webPort">8082</property>
<property name="webAllowOthers"/>
</H2DatabaseConfiguration>
After I restart WSO2 api server the change in the file WSO2_HOME/repository/conf/carbon.xml gets lost. As a result I am not able to connect to H2 db. I am working on version WSO2 3.0.0.
In WSO2 APIM 3.0.0, the configuration model is different. You need to add the following to ../repository/conf/deployment.toml
[database_configuration]
enable_h2_console = true
Ref: https://apim.docs.wso2.com/en/latest/Reference/ConfigCatalog/#enabling-the-h2-database-console
In addition to Bee's answer it is important to mention that we also need to provide proper jdbc URL for that
copy the location of the <API_Manager_home>/repository/database/[databaseName] (here do not copy .mv part i.e extension part)
for me the JDBC URL was jdbc:h2:/Users/akshay/code/w/98/98_base_1/repository/database/WSO2AM_DB
default username and password is wso2carbon/wso2carbon

Access H2 Embedded Database for WSO2 products

I am using stream processor 4.3.0 and need to access the H2 Database for it which comes by default in WSO2 SP application.
Can some please help me here to access/browse the database.
Thanks
And need to access the H2 Database for it which comes by default in WSO2 SP application
For WSO2SP DB configuration stored in:
${carbon.home}/conf/worker/deploymment.yaml
${carbon.home}/conf/dashboard/deploymment.yaml
${carbon.home}/conf/..other module../deploymment.yaml
so you can check the database locations
by default check
${carbon.home}/wso2/worker/database
${carbon.home}/wso2/dashboard/database
${carbon.home}/wso2/..other module../database
You can use H2 Shell to access the databases
Please note the embedded H2 databases are not intended to be accessed from multiple processes concurrently, so stop the wso2sp first
please find the answer below.
Open the /repository/conf/carbon.xml file and paste the following configuration.
Do not uncomment the existing element. Just paste the following configuration below it.
<H2DatabaseConfiguration>
<property name="web"/>
<property name="webPort">8082</property>
<property name="webAllowOthers"/>
</H2DatabaseConfiguration>
3.Restart the WSO2 product and access the following URL via your browser: http://localhost:8082
Tip: If you are logged in to the management console, log out before connecting to the database.
4.Enter the following details and click Connect.
JDBC URL : jdbc:h2:[file path to /repository/database/WSO2CARBON_DB]
username : wso2carbon
password : wso2carbon

WSO2 identity server external JDBC store

I want to use a external JDBC store as default store instead of the default LDAP store. Followed the documentation in this link.
http://docs.wso2.org/wiki/display/IS400/Configuring+an+External+JDBC+User+Store
Getting the following exception Appreciate any help.
An unknown exception occurred while starting LDAP server.java.lang.NullPointerException: Name is null
You can configure WSO2 IS 4.0.0 with an external JDBC users store.The problem is due to an issue with the instructions in the documentation(1) as some configuration steps are missing there.I have created the jira [DOCUMENTATION-17] to track this doc issue.
Please follow below steps to connect IS 4.0.0 with external jdbc users-store.
1) Change the UserStoreManager class to JDBCUserStoreManager from user-mgt.xml [IS_Home/repository/conf] and add the related database connection property to it as mentioned in (1)
2) Add 'passwordHashMethod' propert within JDBCUserStoreManager and set the value to 'SHA' or 'PLAIN_TEXT' in {IS_HOME}/repository/conf/user-mgt.xml.
Eg: <Property name="passwordHashMethod">SHA</Property>
3) Set value of the 'MultiTenantRealmConfigBuilder' property to 'org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder' in {IS_HOME}/repository/conf/user-mgt.xml.
Eg: <Property name="MultiTenantRealmConfigBuilder">org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder</Property>
4) Enable JDBCTenantManager in tenant-mgt.xml and comment out the config section for CommonHybridLDAPTenantManager.
Once you did above configurations,you'll able to configure WSO2 Identity Server to an external jdbc user store successfully.
(1) http://docs.wso2.org/wiki/display/IS400/Configuring+an+External+JDBC+User+Store
I was able to resolve this.
Start with a clean install of WSO2 IS 4.0.0 if possible.
Apart from following the directions given in the documentation to setup a JDBC datastore; you need to do the following :
Enable JDBCTenantManager in tenant-mgt.xml and comment out CommonHybridLDAPTenantManager2
Set the enable property to false for EmbeddedLDAP in embedded-ldap.xml

Getting WSO2 ESB endpoint meta data programmatically

I am trying to programmatically retrieve the meta data of the end points configured to WSO2 ESB (Eg: ServiceName, WebMethods, Input/Output Parameters with Return types etc). Can someone direct me to some way/docs which could help me fetch this data.
Unfortunately it's not really clear what you want to do. Here some examples how to access properties (Meta-Data?)
inside a proxy/sequence access properties:
<property name="some name" expression="get-property('registry','conf:resource/path')"/>
<property name="some name" expression="get-property('registry',gov:resource/path')"/>
<property name="some name" expression="get-property('registry','resourceName')"/>
Or inside a Custom Mediator:
String property = (String)messageContext.getProperty("nameOfThePropery");
Or inside a Custom Mediator (getting the filename from the Transport Layer):
org.apache.axis2.context.MessageContext axis2messageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
// print the filename of the current transport
myLog.info("FileName: " + axis2messageContext.getTransportIn().getName());
Hope this helps you a little bit further, otherwise improve you question.
To further improve on Abdul's question, we are developing a web-service gateway between a legacy client on side and on the other side are external web-services. We have created a template/sequences in WSo2 where we trap the legacy client request and redirect it to the correct web-service based on a internal protocol.
The external web services are registered in WSo2 as endpoints. So far we have been configuring these endpoints manually using the admin console. We are looking at automating this step so that our gateway will hit WSo2 and provide the WSDL URL. A class mediator would then invoke the WSo2 / Synapse APIs to save this endpoint in the Synapse configuration. We have not been successful in this.
We have also read the docs which say that changing synapse config thru mediator is not recommended, hence would like to see if there are other options that would do this job for us.
One workaround would be to create those endpoints from the client side itself. This can be done by calling the AdminService APIs exposed by the carbon framework. In carbon, a front end of any carbon component talks to its back end through Admin Services. For example, if we take endpoints related functionalities, when you use the management console to create/delete or to do any functionalities, it would in turn call the respective back end via the "EndPointAdmin" admin service. Therefore I believe, if you want to programmatically create those endpoints, you can call the EndPointAdmin backend admin service (via EndPointAdminStub - it is the client stub corresponding to the aforesaid back end service) directly from your client side and get your requirement fulfilled.
Regards,
Prabath