synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ind...@apache.org
Subject svn commit: r609894 - in /webservices/synapse/branches/1.1.1: modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java repository/conf/sample/synapse_sample_430.xml src/site/resources/Synapse_Samples.html
Date Tue, 08 Jan 2008 07:22:54 GMT
Author: indika
Date: Mon Jan  7 23:22:54 2008
New Revision: 609894

URL: http://svn.apache.org/viewvc?rev=609894&view=rev
Log:
add a simple sample for callout mediator and upadate the docs 

Added:
    webservices/synapse/branches/1.1.1/repository/conf/sample/synapse_sample_430.xml
Modified:
    webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java
    webservices/synapse/branches/1.1.1/src/site/resources/Synapse_Samples.html

Modified: webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java?rev=609894&r1=609893&r2=609894&view=diff
==============================================================================
--- webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java
(original)
+++ webservices/synapse/branches/1.1.1/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java
Mon Jan  7 23:22:54 2008
@@ -35,6 +35,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.soap.SOAPBody;
 import org.jaxen.JaxenException;
 
 import java.util.List;
@@ -73,14 +74,18 @@
         try {
             Options options = new Options();
             options.setTo(new EndpointReference(serviceURL));
-            options.setAction(action);
+
+            if (action != null) {
+                options.setAction(action);
+            }
+
             options.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.TRUE);
             sc.setOptions(options);
 
             OMElement request = getRequestPayload(synCtx);
             if (traceOrDebugOn) {
-                traceOrDebug(traceOn, "About to invoke service : " + serviceURL +
-                    " with action : " + action);
+                traceOrDebug(traceOn, "About to invoke service : " + serviceURL + (action
!= null ?
+                    " with action : " + action : ""));
                 if (traceOn && trace.isTraceEnabled()) {
                     trace.trace("Request message payload : " + request);
                 }
@@ -120,7 +125,8 @@
             }
 
         } catch (Exception e) {
-            handleException("Error invoking service : " + serviceURL + " with action : "
+ action, e, synCtx);
+            handleException("Error invoking service : " + serviceURL +
+                (action != null ? " with action : " + action : ""), e, synCtx);
         }
 
         if (traceOrDebugOn) {

Added: webservices/synapse/branches/1.1.1/repository/conf/sample/synapse_sample_430.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/branches/1.1.1/repository/conf/sample/synapse_sample_430.xml?rev=609894&view=auto
==============================================================================
--- webservices/synapse/branches/1.1.1/repository/conf/sample/synapse_sample_430.xml (added)
+++ webservices/synapse/branches/1.1.1/repository/conf/sample/synapse_sample_430.xml Mon Jan
 7 23:22:54 2008
@@ -0,0 +1,35 @@
+<!--
+  ~  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.
+  -->
+
+<!-- Simple callout  mediator -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+    <callout serviceURL="http://localhost:9000/soap/SimpleStockQuoteService"
+             action="urn:getQuote">
+        <source xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
+                xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
+                xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
+        <target xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
+                xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
+                xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
+    </callout>
+    <property name="RESPONSE" value="true"/>
+    <header name="To" action="remove"/>
+    <send/>
+    <drop/>
+</definitions>
\ No newline at end of file

Modified: webservices/synapse/branches/1.1.1/src/site/resources/Synapse_Samples.html
URL: http://svn.apache.org/viewvc/webservices/synapse/branches/1.1.1/src/site/resources/Synapse_Samples.html?rev=609894&r1=609893&r2=609894&view=diff
==============================================================================
--- webservices/synapse/branches/1.1.1/src/site/resources/Synapse_Samples.html (original)
+++ webservices/synapse/branches/1.1.1/src/site/resources/Synapse_Samples.html Mon Jan  7
23:22:54 2008
@@ -297,6 +297,13 @@
             synapse for the actual service</a></li>
         </ul>
       </li>
+      <li><a href="#Callout">Synchronize web service invocation with Callout
+        mediator </a> 
+        <ul>
+          <li><a href="#Sample430">Sample 430: Simple Callout Mediator for
+            Synchronize web service invocation</a></li>
+        </ul>
+      </li>
     </ul>
   </li>
 </ul>
@@ -4163,7 +4170,7 @@
         &lt;publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/&gt;
     &lt;/proxy&gt;
 
-&lt;/definitions&gt;                                  </pre>
+&lt;/definitions&gt; </pre>
 
 <p><b>Objective: Introduction transformation using XQuery mediator</b></p>
 
@@ -4362,10 +4369,59 @@
 the requests will be served by the cache inside Synapse. You could observe
 this by looking at the printed line of the axis2 server, as well as by
 observing a constant rate as the response to the client instead of the random
-rate, which changes by each and every 20 seconds.</p>
+rate, which changes by each and every 20 seconds.<br>
+</p>
 
-<p>&#xa0;</p>
+<h2><a name="Callout">Synchronize web service invocation with Callout
+mediator </a></h2>
+
+<p>The Callout mediator does the call for provided service URL with the
+request message which get through source attribute and wait for the response
+and attached received response to the destination which has specified by the
+target. Both of source and target could be a key or a XPath. In the case of
+source ,this key refers to either a message context property or to a local
+entry and for the target this key refers only to a message context property .
+</p>
+
+<h2><a name="Sample430">Sample 430: Simple Callout Mediator for Synchronize
+web service invocation</a></h2>
 
 <p>&#xa0;</p>
+<pre>  
+    &lt;!-- Simple callout  mediator --&gt;
+&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
+    &lt;callout serviceURL="http://localhost:9000/soap/SimpleStockQuoteService"
+             action="urn:getQuote"&gt;
+        &lt;source xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
+                xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
+                xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/&gt;
+        &lt;target xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
+                xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
+                xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/&gt;
+    &lt;/callout&gt;
+    &lt;property name="RESPONSE" value="true"/&gt;
+    &lt;header name="To" action="remove"/&gt;
+    &lt;send/&gt;
+    &lt;drop/&gt;
+&lt;/definitions&gt; </pre>
+
+<div>
+<p> <strong>Objective:</strong> Demonstrate the use of the Callout mediator
+for the synchronize web service invocation</p>
+
+<p><strong>Prerequisites:</strong>Deploy the SimpleStockQuoteService in
+sample Axis2 server and start it on port 9000.</p>
+
+<p>Start Synapse with the sample configuration 430 (i.e. synapse -sample
+430).</p>
+
+<p>In this sample , Callout mediator does the direct service invocation to
+the StockQuoteService using the client request and the get the response and
+set it as the first child of the SOAP message body. Then using send mediator
+message is sent back to the client. </p>
+
+<p>Invoke the client as follows. </p>
+<pre>ant stockquote -Daddurl=http://localhost:9000/soap/SimpleStockQuoteService -Dtrpurl=http://localhost:8080/</pre>
+</div>
 </body>
 </html>



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org


Mime
View raw message