You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by pz...@apache.org on 2006/01/16 12:36:53 UTC

svn commit: r369436 - /incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java

Author: pzf
Date: Mon Jan 16 03:36:43 2006
New Revision: 369436

URL: http://svn.apache.org/viewcvs?rev=369436&view=rev
Log:
Fixed sample clients to use new ability to disable addressing

Modified:
    incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java

Modified: incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java?rev=369436&r1=369435&r2=369436&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java (original)
+++ incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java Mon Jan 16 03:36:43 2006
@@ -1,87 +1,84 @@
 package samples.userguide;
 
 
+
+
+
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
+
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.*;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.om.*;
-import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.transport.http.HttpTransportProperties;
-import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;
-
-import javax.xml.namespace.QName;
+import org.apache.axis2.om.OMElement;
 
 public class DumbStockQuoteClient {
 
-    /**
-     * <p/>
-     * This is a fairly static test client for Synapse. It makes a StockQuote
-     * request to XMethods stockquote service. There is no EPR and there is no proxy config.
-     * It's sort of a Gateway case. It relies on a Synapse config that will look at the URL or
-     * message and send it to the right place
-     */
-    public static void main(String[] args) {
-
-        if (args.length > 0 && args[0].substring(0, 1).equals("-")) {
-            System.out
-                    .println("This client demonstrates Synapse as a gateway\n"
-                            + "Usage: DumbStockQuoteClient Symbol SynapseURL");
-            System.out
-                    .println("\nDefault values: IBM http://localhost:8080/StockQuote"
-                            + "\nAll examples depend on using the sample synapse.xml");
-            System.exit(0);
-        }
-
-        String symb = "IBM";
-        String url = "http://localhost:8080/StockQuote";
-
-
-        if (args.length > 0)
-            symb = args[0];
-        if (args.length > 1)
-            url = args[1];
-        try {
-
-            // step 1 - create a request payload
-            OMElement getQuote = StockQuoteXMLHandler
-                    .createRequestPayload(symb);
-
-            // step 2 - set up the call object
-
-            // the wsa:To
-            EndpointReference targetEPR = new EndpointReference(url);
-
-            Options options = new Options();
-            options.setTo(targetEPR);
-
-            options.setSoapAction("http://www.webserviceX.NET/GetQuote");
-            // create a lightweight Axis Config with no addressing to
-            // demonstrate "dumb" SOAP
-
-            ServiceClient serviceClient = StockQuoteXMLHandler
-                    .createServiceClient();
-            // make the ServiceClient
-
-            serviceClient.setOptions(options);
-
-            // step 3 - Blocking invocation
-            OMElement result = serviceClient.sendReceive(new QName("getQuote"),
-                    getQuote);
-            // System.out.println(result);
-
-            // step 4 - parse result
-
-            System.out.println("Stock price = $"
-                    + StockQuoteXMLHandler.parseResponse(result));
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+	/**
+	 * 
+	 * <p>
+	 * This is a fairly static test client for Synapse. It makes a StockQuote
+	 * request to XMethods stockquote service. There is no EPR and there is no
+	 * proxy config. It's sort of a Gateway case. It relies on a Synapse config
+	 * that will look at the URL or message and send it to the right place
+	 */
+	public static void main(String[] args) {
+
+		if (args.length > 0 && args[0].substring(0, 1).equals("-")) {
+			System.out
+					.println("This client demonstrates Synapse as a gateway\n"
+							+ "Usage: DumbStockQuoteClient Symbol SynapseURL");
+			System.out
+					.println("\nDefault values: IBM http://localhost:8080/StockQuote"
+							+ "\nAll examples depend on using the sample synapse.xml");
+			System.exit(0);
+		}
+
+		String symb = "IBM";
+		String url = "http://localhost:8080/StockQuote";
+
+		if (args.length > 0)
+			symb = args[0];
+		if (args.length > 1)
+			url = args[1];
+		try {
+
+			// step 1 - create a request payload
+			OMElement getQuote = StockQuoteXMLHandler
+					.createRequestPayload(symb);
+
+			// step 2 - set up the call object
+
+			// the wsa:To
+			EndpointReference targetEPR = new EndpointReference(url);
+
+			Options options = new Options();
+			options.setTo(targetEPR);
+
+			options.setSoapAction("http://www.webserviceX.NET/GetQuote");
+			// create a lightweight Axis Config with no addressing to
+			// demonstrate "dumb" SOAP
+
+			//ServiceClient serviceClient = StockQuoteXMLHandler
+			//		.createServiceClient();
+			// make the ServiceClient
+
+			options.setProperty(Constants.Configuration.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, new Boolean(true));
+			ServiceClient serviceClient = new ServiceClient();
+			serviceClient.setOptions(options);
+
+			// step 3 - Blocking invocation
+			OMElement result = serviceClient.sendReceive(getQuote);
+			// System.out.println(result);
+
+			// step 4 - parse result
+
+			System.out.println("Stock price = $"
+					+ StockQuoteXMLHandler.parseResponse(result));
+
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+	}
 
-    }
-}
\ No newline at end of file
+}



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