Author: hiranya
Date: Sat Nov 27 23:39:44 2010
New Revision: 1039787
URL: http://svn.apache.org/viewvc?rev=1039787&view=rev
Log:
Sample 4, 5
Added:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample4.xml
- copied, changed from r1039730,
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample5.xml
Modified:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
Modified:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml?rev=1039787&r1=1039786&r2=1039787&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
(original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples.xml
Sat Nov 27 23:39:44 2010
@@ -41,8 +41,8 @@
<li><a href="samples/sample1.html">Sample 1: Simple
content based routing (CBR) of messages</a></li>
<li><a href="samples/sample2.html">Sample 2: CBR with
the Switch-case mediator, using message properties</a></li>
<li><a href="samples/sample3.html">Sample 3: Local
Registry entry definitions, reusable endpoints and sequences</a></li>
- <li><a href="">Sample 4: Introduction to error
handling</a></li>
- <li><a href="">Sample 5: Creating SOAP fault messages
and changing the direction of a message</a></li>
+ <li><a href="samples/sample4.html">Sample 4:
Introduction to error handling</a></li>
+ <li><a href="samples/sample5.html">Sample 5: Creating
SOAP fault messages and changing the direction of a message</a></li>
<li><a href="">Sample 6: Manipulating SOAP headers,
and filtering incoming and outgoing messages</a></li>
<li><a href="">Sample 7: Introduction to local
Registry entries and using Schema validation</a></li>
<li><a href="">Sample 8: Introduction to static and
dynamic registry resources, and using XSLT transformations</a></li>
Copied:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample4.xml
(from r1039730,
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml)
URL:
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample4.xml?p2=synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample4.xml&p1=synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml&r1=1039730&r2=1039787&rev=1039787&view=diff
==============================================================================
---
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/template.xml
(original)
+++
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample4.xml
Sat Nov 27 23:39:44 2010
@@ -20,16 +20,67 @@
<document>
<properties>
- <title>Apache Synapse - Sample X</title>
+ <title>Apache Synapse - Sample 4</title>
</properties>
<body>
- <section name="Sample X: ">
- <div class="xmlConf">
+ <section name="Sample 4: Introduction to Error Handling">
+ <div class="xmlConf"><definitions
xmlns="http://ws.apache.org/ns/synapse">
- </div>
+ <!-- the default fault handling sequence used by Synapse - named
'fault' -->
+ <sequence name="fault">
+ <log level="custom">
+ <property name="text" value="An unexpected error occured"/>
+ <property name="message"
expression="get-property('ERROR_MESSAGE')"/>
+ </log>
+ <drop/>
+ </sequence>
+
+ <sequence name="sunErrorHandler">
+ <log level="custom">
+ <property name="text" value="An unexpected error occured for
stock SUN"/>
+ <property name="message"
expression="get-property('ERROR_MESSAGE')"/>
+ <!--<property name="detail"
expression="get-property('ERROR_DETAIL')"/>-->
+ </log>
+ <drop/>
+ </sequence>
+
+ <sequence name="main">
+ <in>
+ <switch xmlns:m0="http://services.samples"
source="//m0:getQuote/m0:request/m0:symbol">
+ <case regex="IBM">
+ <send>
+ <endpoint>
+ <address
uri="http://localhost:9000/services/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </case>
+ <case regex="MSFT">
+ <send>
+ <endpoint key="bogus"/>
+ </send>
+ </case>
+ <case regex="SUN">
+ <sequence key="sunSequence"/>
+ </case>
+ </switch>
+ <drop/>
+ </in>
+
+ <out>
+ <send/>
+ </out>
+ </sequence>
+
+ <sequence name="sunSequence" onError="sunErrorHandler">
+ <send>
+ <endpoint key="sunPort"/>
+ </send>
+ </sequence>
+
+</definitions></div>
<subsection name="Objective">
<p>
-
+ Introduction to error handling with the 'fault' sequence
</p>
</subsection>
<subsection name="Pre-requisites">
@@ -39,21 +90,65 @@
Deploy the SimpleStockQuoteService in the sample
Axis2 server and start Axis2
</li>
<li>
- Start Synapse using the configuration numbered X
(repository/conf/sample/synapse_sample_X.xml)
+ Start Synapse using the configuration numbered 4
(repository/conf/sample/synapse_sample_4.xml)
<div class="command">
- Unix/Linux: sh synapse.sh -sample X<br/>
- Windows: synapse.bat -sample X
+ Unix/Linux: sh synapse.sh -sample 4<br/>
+ Windows: synapse.bat -sample 4
</div>
</li>
</ul>
</p>
</subsection>
<subsection name="Executing the Client">
- <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/</div>
-
- <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006
SimpleStockQuoteService :: Generating quote for : IBM</div>
-
+ <p>
+ First send a stock quote request from the sample client
for the symbol 'IBM' as
+ follows.
+ </p>
+ <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/ -Dsymbol=IBM</div>
+ <p>
+ The request will be routed to the Axis2 server and client
will receive a response
+ as expected.
+ </p>
<div class="consoleOutput">Standard :: Stock price =
$95.26454380258552</div>
+ <p>
+ Now send another stock quote request for the symbol 'MSFT'
as follows.
+ </p>
+ <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT</div>
+ <p>
+ For MSFT requests Synapse is instructed to route the
messages to an endpoint named
+ 'bogus', which does not exist. Synapse executes the
specified error handler
+ sequence closest to the point where the error was
encountered. In this case, the
+ currently executing sequence is 'main' and it does not
specify an 'onError'
+ attribute. Whenever Synapse cannot find an error handler,
it looks for a sequence
+ named 'fault'. Thus the 'fault' sequence can be seen
executing, and writing the
+ generic error message to the logs.
+ </p>
+ <div class="consoleOutput">[HttpServerWorker-1] DEBUG
SendMediator - Send mediator :: mediate()
+[HttpServerWorker-1] ERROR IndirectEndpoint - Reference to non-existent
endpoint for key : bogus
+[HttpServerWorker-1] DEBUG MediatorFaultHandler - MediatorFaultHandler ::
handleFault
+[HttpServerWorker-1] DEBUG SequenceMediator - Sequence mediator <fault>
:: mediate()
+[HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
+[HttpServerWorker-1] INFO LogMediator text = An unexpected error occured,
message = Couldn't find the endpoint with the key : bogus</div>
+ <p>
+ Now send another stock quote request for the symbol 'SUN'.
+ </p>
+ <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/ -Dsymbol=SUN</div>
+ <p>
+ When the 'SUN' quote is requested, a custom sequence
'sunSequence' is invoked,
+ and it specifies 'sunErrorHandler' as its error handler.
Hence when the send
+ fails, you could see the proper error handler invocation
and the custom error
+ message printed as follows.
+ </p>
+ <div class="consoleOutput">[HttpServerWorker-1] DEBUG
SequenceMediator - Sequence mediator <sunSequence> :: mediate()
+[HttpServerWorker-1] DEBUG SequenceMediator - Setting the onError handler for
the sequence
+[HttpServerWorker-1] DEBUG AbstractListMediator - Implicit Sequence
<SequenceMediator> :: mediate()
+[HttpServerWorker-1] DEBUG SendMediator - Send mediator :: mediate()
+[HttpServerWorker-1] ERROR IndirectEndpoint - Reference to non-existent
endpoint for key : sunPort
+[HttpServerWorker-1] DEBUG MediatorFaultHandler - MediatorFaultHandler ::
handleFault
+[HttpServerWorker-1] DEBUG SequenceMediator - Sequence mediator
<sunErrorHandler> :: mediate()
+[HttpServerWorker-1] DEBUG AbstractListMediator - Implicit Sequence
<SequenceMediator> :: mediate()
+[HttpServerWorker-1] DEBUG LogMediator - Log mediator :: mediate()
+[HttpServerWorker-1] INFO LogMediator text = An unexpected error occured for
stock SUN, message = Couldn't find the endpoint with the key : sunPort</div>
</subsection>
</section>
<p><a href="../samples.html">Back to Catalog</a></p>
Added:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample5.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample5.xml?rev=1039787&view=auto
==============================================================================
---
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample5.xml
(added)
+++
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample5.xml
Sat Nov 27 23:39:44 2010
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<document>
+ <properties>
+ <title>Apache Synapse - Sample 5</title>
+ </properties>
+ <body>
+ <section name="Sample 5: Creating SOAP Faults and Changing the
Direction of Messages">
+ <div class="xmlConf"><definitions
xmlns="http://ws.apache.org/ns/synapse">
+
+ <sequence name="myFaultHandler">
+ <makefault response="true">
+ <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope"
value="tns:Receiver"/>
+ <reason expression="get-property('ERROR_MESSAGE')"/>
+ </makefault>
+ <send/>
+ </sequence>
+
+ <sequence name="main" onError="myFaultHandler">
+ <in>
+ <switch xmlns:m0="http://services.samples"
source="//m0:getQuote/m0:request/m0:symbol">
+ <case regex="MSFT">
+ <send>
+ <endpoint>
+ <address
uri="http://bogus:9000/services/NonExistentStockQuoteService"/>
+ </endpoint>
+ </send>
+ </case>
+ <case regex="SUN">
+ <send>
+ <endpoint>
+ <address
uri="http://localhost:9009/services/NonExistentStockQuoteService"/>
+ </endpoint>
+ </send>
+ </case>
+ </switch>
+ <drop/>
+ </in>
+
+ <out>
+ <send/>
+ </out>
+ </sequence>
+
+</definitions></div>
+ <subsection name="Objective">
+ <p>
+ Introducing the makefault mediator for creating custom
SOAP faults and demonstrating
+ the message direction (in/out) change
+ </p>
+ </subsection>
+ <subsection name="Pre-requisites">
+ <p>
+ <ul>
+ <li>
+ Start Synapse using the configuration numbered 5
(repository/conf/sample/synapse_sample_5.xml)
+ <div class="command">
+ Unix/Linux: sh synapse.sh -sample 5<br/>
+ Windows: synapse.bat -sample 5
+ </div>
+ </li>
+ </ul>
+ </p>
+ </subsection>
+ <subsection name="Executing the Client">
+ <p>
+ When the MSFT stock quote is requested, an unknown host
exception would be
+ generated. A connection refused exception would be
generated for the SUN stock
+ request. These errors are captured and returned to the
original client as a SOAP
+ fault in this example.
+ </p>
+ <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT</div>
+ <p>returns,</p>
+ <div class="consoleOutput"><soapenv:Fault
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <faultcode>soapenv:Client</faultcode>
+ <faultstring>java.net.UnknownHostException: bogus</faultstring>
+ <detail />
+</soapenv:Fault></div>
+ <p>And </p>
+ <div class="command">ant stockquote
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService
-Dtrpurl=http://localhost:8280/ -Dsymbol=SUN</div>
+ <p>returns, </p>
+ <div class="consoleOutput"><soapenv:Fault
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <faultcode>soapenv:Client</faultcode>
+ <faultstring>java.net.ConnectException: Connection
refused</faultstring>
+ <detail />
+</soapenv:Fault></div>
+ <p>
+ Note that the response attribute is set to 'true' on the
makefault mediator.
+ This instructs the mediator to change the direction of
messages to 'response'
+ as messages are transformed into SOAP faults.
+ </p>
+ </subsection>
+ </section>
+ <p><a href="../samples.html">Back to Catalog</a></p>
+ </body>
+</document>
\ No newline at end of file