Author: asankha
Date: Wed May 31 05:25:10 2006
New Revision: 410508

URL: http://svn.apache.org/viewvc?rev=410508&view=rev
Log:
checkin sample for proxy service

Added:
    
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/ProxyStockQuoteClient.java
Modified:
    
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
    incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml

Modified: 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?rev=410508&r1=410507&r2=410508&view=diff
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
 (original)
+++ 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
 Wed May 31 05:25:10 2006
@@ -85,10 +85,13 @@
                 // results in an unbound URI exception for no credible reason 
- needs more investigation
                 // seems like a woodstox issue. Use hack for now
                 axisOutMsgContext.getEnvelope().build();
+                
+                log.debug("Reply Body : \n" + axisOutMsgContext.getEnvelope());
 
                 AxisEngine ae = new 
AxisEngine(axisOutMsgContext.getConfigurationContext());
                 try {
                     
axisOutMsgContext.setProperty(org.apache.synapse.Constants.ISRESPONSE_PROPERTY, 
Boolean.TRUE);
+                    
mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, 
Constants.VALUE_TRUE);
                     // check for addressing is alredy engaged for this message.
                     // if engage we should use the address enable Configuraion 
context.
                     ae.send(axisOutMsgContext);

Modified: 
incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml?rev=410508&r1=410507&r2=410508&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml 
(original)
+++ incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml 
Wed May 31 05:25:10 2006
@@ -62,6 +62,13 @@
                ant simplequote 
            ant simplequote [-Dsymbol=IBM] 
[-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] 
[-Dgatewayurl=http://localhost:8080/StockQuote] 
[-Drepository=../synapse_repository]
 
+       ant proxyquote
+           Use Proxy services to query stock prices
+    
+               examples:
+         ant proxyquote
+         ant proxyquote -Dsymbol=IBM 
-Durl=http://www.webservicex.net/stockquote.asmx -Dsynapseurl=http://localhost
+           -Drepository=../synapse_repository"
 
         </echo>
     </target>
@@ -134,6 +141,16 @@
 
     <target name="simplequote" depends="compile">        
         <java classname="samples.config.SimpleStockQuoteClient"
+              classpathref="javac.classpath" fork="true">
+               <arg value="${symbol}"/>
+            <arg value="${investbot_url}"/>
+            <arg value="${gatewayurl}"/>
+            <arg value="${repository}"/>
+        </java>
+    </target>
+    
+    <target name="proxyquote" depends="compile">        
+        <java classname="samples.mediation.ProxyStockQuoteClient"
               classpathref="javac.classpath" fork="true">
                <arg value="${symbol}"/>
             <arg value="${investbot_url}"/>

Added: 
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/ProxyStockQuoteClient.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/ProxyStockQuoteClient.java?rev=410508&view=auto
==============================================================================
--- 
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/ProxyStockQuoteClient.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/ProxyStockQuoteClient.java
 Wed May 31 05:25:10 2006
@@ -0,0 +1,59 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*/
+package samples.mediation;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContextConstants;
+
+public class ProxyStockQuoteClient {
+
+    public static void main(String[] args) {
+
+        String symbol = "IBM";
+        String xurl   = "http://ws.invesbot.com/stockquotes.asmx";;
+        String turl   = 
"http://localhost:8080/axis2/services/InvesbotForwardProxy";;
+
+        if (args.length > 0) symbol = args[0];
+        if (args.length > 1) xurl   = args[1];
+        if (args.length > 2) turl   = args[2];
+
+        ProxyStockQuoteClient.testStandardQuote(symbol, xurl, turl);
+    }
+
+    private static void testStandardQuote(String symbol, String xurl, String 
turl) {
+        try {
+            OMElement getQuote = 
CustomQuoteXMLHandler.createStandardRequestPayload(symbol);
+
+            Options options = new Options();
+            //options.setTo(new EndpointReference(xurl));
+            options.setProperty(MessageContextConstants.TRANSPORT_URL, turl);
+            options.setAction("http://ws.invesbot.com/GetQuote";);
+
+            ServiceClient serviceClient = new ServiceClient();
+            serviceClient.setOptions(options);
+
+            OMElement result = 
serviceClient.sendReceive(getQuote).getFirstElement();
+            System.out.println("Proxy :: Stock price = $" + 
CustomQuoteXMLHandler.parseStandardResponsePayload(result));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to