How to Externalize Query in WSO2 ESB - wso2-esb

I have created ESB proxy using WSO2 ESB 4.8.1
Currently DBLookup mediator contains following sql
<sql>select A, B, C from cis-dev.table1 where ... </sql>
Since, cis-dev schema is specific to the dev environment, I need to store this query outside the proxy in order to migrate proxy service to QA and PROD environments.
Is there a way to accomplish this in WSO2 ESB?
Thanks,

There is no direct way store query outside and invoke it as per the environment. But you can parameterize the query and pass parameters with the request to alter values in the query . See the sample below
<dblookup>
<connection>
<pool>
<driver>org.apache.derby.jdbc.ClientDriver</driver>
<url>jdbc:derby://localhost:1527/esbdb;user=esb;password=esb</url>
<user>esb</user>
<password>esb</password>
</pool>
</connection>
<statement>
<sql>select * from company where name =?</sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol"
xmlns:m0="http://services.samples" type="VARCHAR"/>
<result name="company_id" column="id"/>
<result name="company_price_0" column="price" rowIndex="2"/>
<result name="company_price_1" column="price" rowIndex="4"/>
</statement>
</dblookup>

Related

Dynamic url generation using Struts 2 using version [struts2-core-2.0.11.1] [duplicate]

I am working on a project where I want to provide unique URL for each user.
For example:
www.SocialNetwork.com/jhon
www.SocialNetwork.com/jasmine
So far I'm able to achieve this:
www.SocialNetwork.com/profiles/jasmine
here profiles is my action where I can get the user name by
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.patternMatcher" value="namedVariable"/>
<action name="profiles/{username}" class="com.example.actions.ViewProfileAction">
<result name="input">/WEB-INF/jsp/profile.jsp</result>
</action>
but I want to achieve something like this:
www.SocialNetwork.com/jasmine
Just use domain name and username.
Like Twitter does:
www.twitter.com/username
How to achieve this?
If you want to use named patterns in wildcard mapping then you should configure following in the struts.xml:
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex"/>
now assume com.example.actions.ViewProfileAction bean has a property username, and method execute that returns a SUCCESS result. Then you can map the action in the root namespace "/" configured to your package.
<action name="{username}" class="com.example.actions.ViewProfileAction">
<result>/WEB-INF/jsp/profile.jsp</result>
</action>
you can get the name in the JSP using OGNL
<s:property value="username"/>
Also note that you should deploy to the root context to have
your.domain.com/username mapped to your action.
Try this out. It may work. Use Freemarker USE $.
<action name="profiles/${username}" class="com.example.actions.ViewProfileAction">
<result name="input">/WEB-INF/jsp/profile.jsp</result>
</action>
It may work

No process engine found. camunda Webapp cannot work without a process engine

When I set up a camunda BPMN platform, I got the following error
HTTP Status 500 -
org.camunda.bpm.webapp.impl.IllegalWebAppConfigurationException: No
process engine found. camunda Webapp cannot work without a process
engine
Confirming that the both the '/camunda' and '/engine-rest' is deployed and running in Tomcat.
But /engine-rest returns 404 with following error.
description : The requested resource is not available.
Please help!.
You need to configure the shared process engine for your server as described in https://docs.camunda.org/manual/7.5/installation/full/tomcat/manual/#add-bpm-platform-xml
Have added bpm-platform.xml to '/conf'
<?xml version="1.0" encoding="UTF-8"?>
<bpm-platform xmlns="http://www.camunda.org/schema/1.0/BpmPlatform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.camunda.org/schema/1.0/BpmPlatform http://www.camunda.org/schema/1.0/BpmPlatform ">
<job-executor>
<job-acquisition name="default" />
</job-executor>
<process-engine name="default">
<job-acquisition>default</job-acquisition>
<configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
<datasource>java:jdbc/ProcessEngine</datasource>
<properties>
<property name="history">full</property>
<property name="databaseSchemaUpdate">true</property>
<property name="authorizationEnabled">true</property>
<property name="jobExecutorDeploymentAware">true</property>
</properties>
</process-engine>
</bpm-platform>

Wso2 esb tryit tool works but testing with SOAP UI for same proxy does not work

Iteration mediator works with WSo2 Tryit tool but when the same message is sent through SOAP UI the proxy it does not iterate. My proxy service is very simple it has a xslt mediator and then does the iteration. Do I need to change the content type?
Can you paster your proxy service source code.
Try it tool is a evolving tool, but you should always do your testing from SOAP UI.
This is the sample format :-
<iterate expression="//m0:getQuote/m0:request" preservePayload="true"
attachPath="//m0:getQuote"
xmlns:m0="http://services.samples">
<target>
<sequence>
<send>
<endpoint>
<address
uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</sequence>
</target>

Mule - make Global Elements more global

In mule I have many applications running on the same container that access a jdbc connector with the same connection string/user/password set.
Of course any app has configured the same global connector in its xml configuration file, so there is code duplication.
Is there a way to define only once per container the connection and access it from any app?
I would try this: have one app create the datasource and store it in JNDI and have the other apps pick it up from JNDI.
Since there is no strong guarantee of app start ordering, it's possible that one app that needs the JNDI datasource would start too soon. You would need to configure Spring to be able to perform the JNDI lookup again in case of failure and configure a threaded retry policy on the Mule JDBC connector.
Also you will need to install the datasource and database JARs in lib/user so all apps could use them.
Just create a spring bean for your JDBC connector in xml some where in your system and have all your applications load it in your apps:
<spring:import resource="JDBC-beans.xml" />
and the xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
<!-- Initialization for data source -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/TEST"/>
<property name="username" value="root"/>
<property name="password" value="password"/>
</bean>
</beans>
I have solved this kind of problem using a Domain project, where I inserted all database configurations that have been used by other projects.

Can Axis Client-Config.wsdd config be picked up from JBoss?

I have a client for a 3rd party webservice that had to be created using the Azis WSDL2Java tool. Every web request must be encrypted using an Encryption handler provided by the 3rd party and the incoming responses myst be Decrypted in the same format. This all works really well, except that I have the handlers specified in a client-config.wsdd in the src/main/resources of my jar. one of the parameters of the client-config is a username and one is the location to a key file. This will need to be deployed to many different environments where the user and key location will differ, and it's not going to be feasible to change the values each time then rebuild. Is there a way I can either pass in parameters to my wsdd or place the wsdd in the $JBOSS_HOME/server//conf folder etc? (I am using JBoss 5.1.0.GA)
The wsdd looks like this
<?xml version='1.0'?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<requestFlow>
<handler name="EncryptionHandler" type="java:com.3rdparty.services.util.EncryptionHandler" >
<parameter name="userName" value="myuser"/>
<parameter name="keyFile" value="/jboss-5.1.0.GA/server/<name>/conf/my.key"/>
<parameter name="passwordCallbackClass" value="com.3rdparty.security.client.PWCallback"/>
</handler>
</requestFlow>
<responseFlow>
<handler name="DecryptionHandler" type="java:com.3rdparty.services.util.DecryptionHandler" >
<parameter name="userName" value="myuser"/>
<parameter name="keyFile" value="/jboss-5.1.0.GA/server/<name>/conf/my.key"/>
</handler>
</responseFlow>
</globalConfiguration>
<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>
<transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>
<transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/>
</deployment>
You can use the system property axis.ClientConfigFile to specify a particular directory of the client-config.wsdd file.