Databases :
DB customer should be created with the required tables.
DB : customerDetails
table : customers
Proxy :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestProxyUsh"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence onError="testError">
<dblookup>
<connection>
<pool>
<password>root</password>
<user>root</user>
<url>jdbc:mysql://host:3306/customerDetails</url>
<driver>com.mysql.jdbc.Driver</driver>
</pool>
</connection>
<statement>
<sql>SELECT * FROM customers WHERE name =?</sql>
<parameter value="WSO2" type="INTEGER"/>
<result name="company_id" column="id"/>
</statement>
</dblookup>
</inSequence>
<faultSequence>
<log level="custom">
<property name="text" value="An unexpected error occurred for the service"/>
</log>
</faultSequence>
</target>
<description/>
</proxy>
onError targeting sequence :
<sequence xmlns="http://ws.apache.org/ns/synapse" name="testError">
<log>
<property name="error" value="Error Occurred"/>
</log>
</sequence>
Invoke :
curl -v http://host:8280/services/TestProxyUsh
No comments:
Post a Comment