You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by in...@apache.org on 2007/10/17 10:59:20 UTC
svn commit: r585416 - in /webservices/synapse/trunk/java:
modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/
repository/conf/sample/ src/site/resources/
Author: indika
Date: Wed Oct 17 01:59:19 2007
New Revision: 585416
URL: http://svn.apache.org/viewvc?rev=585416&view=rev
Log:
documents for throttle,xquery
NPE fixed for Xquery
Modified:
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_700.xml
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_701.xml
webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
Modified: webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java?rev=585416&r1=585415&r2=585416&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java (original)
+++ webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java Wed Oct 17 01:59:19 2007
@@ -206,16 +206,27 @@
querySource = (String) o;
}
- if (traceOrDebugOn) {
- traceOrDebug(traceOn, "Picked up the xquery source " + querySource
- + "from the key " + queryKey);
- traceOrDebug(traceOn, "Prepare an expression for the query ");
- }
+ if (querySource != null) {
+
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Picked up the xquery source " + querySource
+ + "from the key " + queryKey);
+ traceOrDebug(traceOn, "Prepare an expression for the query ");
+ }
+
+ //create an XQPreparedExpression using the query source
+ cachedPreparedExpression = cachedConnection.prepareExpression(querySource);
+ // need binding because the expression just has recreated
+ needBind = true;
- //create an XQPreparedExpression using the query source
- cachedPreparedExpression = cachedConnection.prepareExpression(querySource);
- // need binding because the expression just has recreated
- needBind = true;
+ } else {
+
+ if (traceOrDebugOn) {
+ traceOrDebug(traceOn, "Couldn't find the xquery source with a key "
+ + queryKey);
+ }
+ return;
+ }
}
//Bind the external variables to the DynamicContext
Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_700.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_700.xml?rev=585416&r1=585415&r2=585416&view=diff
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_700.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_700.xml Wed Oct 17 01:59:19 2007
@@ -16,7 +16,7 @@
~ specific language governing permissions and limitations
~ under the License.
-->
- <!-- introduction to URL source properties, registry based properties and the XSLT mediator -->
+ <!-- introduction to URL source properties, registry based properties and the XQuery mediator -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
Modified: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_701.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_701.xml?rev=585416&r1=585415&r2=585416&view=diff
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_701.xml (original)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_701.xml Wed Oct 17 01:59:19 2007
@@ -16,7 +16,7 @@
~ specific language governing permissions and limitations
~ under the License.
-->
- <!-- introduction to URL source properties, registry based properties and the XSLT mediator -->
+ <!-- introduction to URL source properties, registry based properties and the XQuery mediator -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
Modified: webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html?rev=585416&r1=585415&r2=585416&view=diff
==============================================================================
--- webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html (original)
+++ webservices/synapse/trunk/java/src/site/resources/Synapse_Samples.html Wed Oct 17 01:59:19 2007
@@ -232,7 +232,7 @@
<!-- Send the messageto implicit destination -->
<send/>
</definitions>
- </pre>
+</pre>
<p><strong>Objective: Introduction to Synapse. Shows how a message could be
made to pass through Synapse </strong><strong>and logged before it is
@@ -2217,8 +2217,8 @@
</proxy>
</definitions></pre>
-<p><strong>Objective: Routing the messages arrived to a proxy service without processing
-the MustUnderstand headers (Security header)</strong></p>
+<p><strong>Objective: Routing the messages arrived to a proxy service without
+processing the MustUnderstand headers (Security header)</strong></p>
<p><strong>Pre-Requisites:</strong><br>
You may also need to download and install the unlimited strength policy files
@@ -2231,28 +2231,30 @@
<p></p>
-<p>The proxy service will recieve secure messages with security headers which are MustUnderstand.
-But hence element 'engageSec' is not present in the proxy configuration synapse
-will not engage that Apache Rampart on this proxy service. It is expected that an MustUnderstand
-failure exception on the AxisEngine would occur before the message arrives Synapse. But Synapse
-handles this message and gets it in by setting all the headers which are MustUnderstand and not
-processed to processed state. This will enable synapse to route the messages without reading the
-Security headers (just routing the messages from client to service, both of which are secure). To
-execute the client, send a stock quote request to the proxy service, and sign
-and encrypt the request by specifying the client side security policy as
-follows:</p>
+<p>The proxy service will recieve secure messages with security headers which
+are MustUnderstand. But hence element 'engageSec' is not present in the proxy
+configuration synapse will not engage that Apache Rampart on this proxy
+service. It is expected that an MustUnderstand failure exception on the
+AxisEngine would occur before the message arrives Synapse. But Synapse
+handles this message and gets it in by setting all the headers which are
+MustUnderstand and not processed to processed state. This will enable synapse
+to route the messages without reading the Security headers (just routing the
+messages from client to service, both of which are secure). To execute the
+client, send a stock quote request to the proxy service, and sign and encrypt
+the request by specifying the client side security policy as follows:</p>
<pre>ant stockquote -Dtrpurl=http://localhost:8080/soap/StockQuoteProxy -Dpolicy=./../../repository/conf/sample/resources/policy/client_policy_3.xml</pre>
<p>By following through the debug logs or TCPMon output, you could see that
the request received by the proxy service was signed and encrypted. Also,
-looking up the WSDL of the proxy service by requesting the
-URL http://localhost:8080/soap/StockQuoteProxy?wsdl reveals the security
-policy attachments are not there and security is not engaged. When sending the message to the
-backend service, you could verify that the security headers were there as in the original
-message to synapse from client, and that the response received does use WS-Security,
-and forwarded back to the client without any modification. You should note that this wont be a
-security hole because the message inside synapse is signed and encrypted and can only be forwarded
-to a secure service to be usefull.</p>
+looking up the WSDL of the proxy service by requesting the URL
+http://localhost:8080/soap/StockQuoteProxy?wsdl reveals the security policy
+attachments are not there and security is not engaged. When sending the
+message to the backend service, you could verify that the security headers
+were there as in the original message to synapse from client, and that the
+response received does use WS-Security, and forwarded back to the client
+without any modification. You should note that this wont be a security hole
+because the message inside synapse is signed and encrypted and can only be
+forwarded to a secure service to be usefull.</p>
<h1><a name="Transport">Transports</a></h1>
@@ -3103,17 +3105,97 @@
<h1><a name="AdvancedMediations">Advanced mediations</a></h1>
-<h2><a name="Sample600">Sample 600</a></h2>
-<pre><definitions xmlns="http://ws.apache.org/ns/synapse"
- xmlns:throttle="http://ws.apache.org/ns/synapse/throttle">
+<h2>Sample 600</h2>
+
+<p></p>
+<pre><definitions xmlns="http://ws.apache.org/ns/synapse">
+ <sequence name="main">
+ <in>
+ <throttle id="A">
+ <policy>
+ <!-- define throttle policy -->
+ <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
+ <throttle:ThrottleAssertion>
+ <throttle:MaximumConcurrentAccess>10</throttle:MaximumConcurrentAccess>
+ </throttle:ThrottleAssertion>
+ </wsp:Policy>
+ </policy>
+ <onAccept>
+ <log level="custom">
+ <property name="text" value="**Access Accept**"/>
+ </log>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </onAccept>
+ <onReject>
+ <log level="custom">
+ <property name="text" value="**Access Denied**"/>
+ </log>
+ <makefault>
+ <code value="tns:Receiver"
+ xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="**Access Denied**"/>
+ </makefault>
+ <property name="RESPONSE" value="true"/>
+ <header name="To" action="remove"/>
+ <send/>
+ <drop/>
+ </onReject>
+ </throttle>
+ </in>
+ <out>
+ <throttle id="A"/>
+ <send/>
+
+
+
+
+
+
+</out>
+ </sequence>
+</definitions> finitions>
+</pre>
+
+<p> <b>Objective: Demonstrate the use of throttle mediator for concurrency
+throttling </b></p>
+
+<p><strong>Pre-Requisites:</strong></p>
+
+<p>Deploy the SimpleStockQuoteService in sample Axis2 server and start it on
+port 9000.</p>
+
+<p>Start Synapse with the sample configuration 600 (i.e. synapse -sample
+600).</p>
+
+<p></p>
+
+<p>Above configuration specifies a throttle mediator inside the in mediator.
+Therefore, all request messages directed to the main sequence will be
+subjected to throttling. Throttle mediator has policy, onAccept and onReject
+tags at top level. Policy tag specifies the throttling policy to be applied
+for messages. In this sample policy contains only component called
+"MaximumConcurrentAccess" .This indicates the maximum number of concurrent
+request that may have passed through the synapse on a single unit of time. To
+test concurrency throttling ,it is required to send concurrent request to
+synapse. For synapse with above configuration ,if client send 20 request
+concurrently ,then approximately half of those will success..</p>
+
+<h2><a name="Sample600">Sample 601</a></h2>
+<pre><definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="main">
<in>
- <throttle:throttle>
+ <throttle id="A">
<policy>
<!-- define throttle policy -->
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
<throttle:ThrottleAssertion>
+ <throttle:MaximumConcurrentAccess>10</throttle:MaximumConcurrentAccess>
<wsp:All>
<throttle:ID throttle:type="IP">Other</throttle:ID>
<wsp:ExactlyOne>
@@ -3181,19 +3263,22 @@
<reason value="**Access Denied**"/>
</makefault>
<property name="RESPONSE" value="true"/>
- <header name="To" expression="get-property('ReplyTo')"/>
+ <header name="To" action="remove"/>
<send/>
<drop/>
</onReject>
- </throttle:throttle>
+ </throttle>
</in>
<out>
+ <throttle id="A"/>
<send/>
</out>
</sequence>
-</definitions></pre>
-<strong>Objective: Demonstrate the use of throttle mediator for restricting
-request counts</strong>
+</definitions>
+</pre>
+
+<p><strong>Objective: Demonstrate the use of throttle mediator for
+restricting request counts</strong> </p>
<p><strong>Pre-Requisites:</strong></p>
@@ -3232,6 +3317,128 @@
[HttpServerWorker-2] INFO LogMediator - text = **Access Accept**
[HttpServerWorker-3] INFO LogMediator - text = **Access Accept**
[HttpServerWorker-4] INFO LogMediator - text = **Access Accept**
-[HttpServerWorker-5] INFO LogMediator - text = **Access Denied**</pre>
+[HttpServerWorker-5] INFO LogMediator - text = **Access Denied** </pre>
+
+<h2>Sample 700</h2>
+<pre><definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <localEntry key="xquery-key-req"
+ src="file:repository/conf/sample/resources/xquery/xquery_req.xq"/>
+ <proxy name="StockQuoteProxy">
+ <target>
+ <inSequence>
+ <xquery key="xquery-key-req">
+ <variable name="payload" type="ELEMENT"/>
+ </xquery>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </inSequence>
+ <outSequence>
+ <out>
+ <xquery key="xquery/xquery_res.xq">
+ <variable name="payload" type="ELEMENT"/>
+ </xquery>
+ <send/>
+ </out>
+ </outSequence>
+ </target>
+ <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/></proxy></definitions> </pre>
+
+<p></p>
+
+<p><b>Objective: Introduction transformation using XQuery mediator</b></p>
+
+<p><b>Pre-Requisites</b>:Start the Synapse configuration numbered 700: i.e.
+synapse -sample 700 </p>
+
+<p>Start the Axis2 server and deploy the SimpleStockQuoteService if not
+already done.</p>
+
+<p></p>
+
+<p>This example uses the XQuery mediator to perform transformations. This
+sample behave same as sample number 8 and only different here is use of
+XQuery instead of XSLT for transformations.</p>
+
+<p></p>
+
+<p>Execute the custom quote client as 'ant stockquote -Dmode=customquote ..'
+</p>
+<pre>ant stockquote -Daddurl=http://localhost:8080/soap/StockQuoteProxy
+ -Dmode=customquote </pre>
+
+<p></p>
+
+<h2>Sample 701</h2>
+
+<p></p>
+<pre><definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) -->
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a resource URL as root + key -->
+ <parameter name="root">file:repository/conf/sample/resources/</parameter>
+ <!-- all resources loaded from the URL registry would be cached for this number of milli seconds -->
+ <parameter name="cachableDuration">15000</parameter>
+ </registry>
+
+ <proxy name="StockQuoteProxy">
+ <target>
+ <inSequence>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </inSequence>
+ <outSequence>
+ <out>
+ <xquery key="xquery/xquery_commisson.xq">
+ <variable name="payload" type="ELEMENT"></variable>
+ <variable name="commission" type="ELEMENT" key="misc/commission.xml"></variable>
+ </xquery>
+ <send/>
+ </out>
+ </outSequence>
+ </target>
+ <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/></proxy></definitions> ns></pre>
+
+<p><b></b></p>
+
+<p><b><strong>Objective: Demonstrate the use of XQuery mediator to import
+external XML documents to the xquery engine</strong></b></p>
+
+<p><strong>Pre-Requisites:</strong>Deploy the SimpleStockQuoteService in
+sample Axis2 server and start it on port 9000.</p>
+
+<p>Start Synapse with the sample configuration 701 (i.e. synapse -sample
+701).</p>
+
+<p>In this sample , data from commission.xml document use inside XQUERY
+document. The stock quote prize from the response and commission from the
+commission.xml document will be added and give as a new prize .</p>
+
+<p></p>
+
+<p>Invoke the client as bellow </p>
+<pre>ant stockquote -Daddurl=http://localhost:8080/soap/StockQuoteProxy
+</pre>
+
+<p></p>
+
+<p></p>
+
+<p></p>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org