Author: saminda
Date: Thu Jan 19 00:35:06 2006
New Revision: 370437
URL: http://svn.apache.org/viewcvs?rev=370437&view=rev
Log:
Updated samples and build.xmls
Modified:
incubator/synapse/trunk/java/scripts/samples/deprecation_mediator/build.xml
incubator/synapse/trunk/java/scripts/userguide/build.xml
incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java
incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java
incubator/synapse/trunk/java/src/samples/userguide/StockQuoteClient.java
Modified:
incubator/synapse/trunk/java/scripts/samples/deprecation_mediator/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/scripts/samples/deprecation_mediator/build.xml?rev=370437&r1=370436&r2=370437&view=diff
==============================================================================
--- incubator/synapse/trunk/java/scripts/samples/deprecation_mediator/build.xml
(original)
+++ incubator/synapse/trunk/java/scripts/samples/deprecation_mediator/build.xml
Thu Jan 19 00:35:06 2006
@@ -10,7 +10,7 @@
ant compile build the deprecation_mediator sample
- ant StockQuote [Symbol] [webserviceurl] [synapseurl]
+ ant StockQuote [Symbol] [webserviceurl] [synapseurl]
{optional[repository]}
Use the smart client - Synapse in WS-Addressing router mode
</echo>
@@ -19,6 +19,7 @@
<property name="symbol" value="IBM"/>
<property name="url" value="http://www.webservicex.net/stockquote.asmx"/>
<property name="synapseurl" value="http://localhost:8080"/>
+ <property name="repository" value="../synapse_repository"/>
<property name="class.dir" value="target/classes"/>
@@ -40,6 +41,7 @@
<arg value="${symbol}"/>
<arg value="${url}"/>
<arg value="${synapseurl}"/>
+ <arg value="${repository}"/>
</java>
</target>
Modified: incubator/synapse/trunk/java/scripts/userguide/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/scripts/userguide/build.xml?rev=370437&r1=370436&r2=370437&view=diff
==============================================================================
--- incubator/synapse/trunk/java/scripts/userguide/build.xml (original)
+++ incubator/synapse/trunk/java/scripts/userguide/build.xml Thu Jan 19
00:35:06 2006
@@ -1,4 +1,4 @@
-<project name="samples" default="help">
+<project name="samples" default="help" basedir=".">
<target name="help">
<echo>
This script requires Ant 1.5 or higher
@@ -10,13 +10,13 @@
ant compile build the samples
- ant StockQuote [Symbol] [webserviceurl] [synapseurl]
+ ant StockQuote [Symbol] [webserviceurl] [synapseurl]
{optional[repository]}
Use the smart client - Synapse in WS-Addressing router mode
- ant ProxyStockQuote [Symbol] [webserviceurl] [synapseurl]
+ ant ProxyStockQuote [Symbol] [webserviceurl] [synapseurl]
{optional[repository]}
Use the http proxy client - Synapse in "transparent mode"
- ant DumbStockQuote [Symbol] [synapseurl]
+ ant DumbStockQuote [Symbol] [synapseurl] {optional[repository]}
Use the dumb soap client - Synapse in "gateway" mode
</echo>
@@ -25,6 +25,7 @@
<property name="symbol" value="IBM"/>
<property name="url" value="http://www.webservicex.net/stockquote.asmx"/>
<property name="synapseurl" value="http://localhost:8080"/>
+ <property name="repository" value="../synapse_repository"/>
<property name="class.dir" value="target/classes"/>
@@ -46,6 +47,7 @@
<arg value="${symbol}"/>
<arg value="${url}"/>
<arg value="${synapseurl}"/>
+ <arg value="${repository}"/>
</java>
</target>
@@ -55,14 +57,16 @@
<arg value="${symbol}"/>
<arg value="${url}"/>
<arg value="${synapseurl}"/>
+ <arg value="${repository}"/>
</java>
</target>
- <target name="DumbQuoteClient" depends="compile">
+ <target name="DumbStockQuote" depends="compile">
<java classname="samples.userguide.DumbStockQuoteClient"
classpathref="axis.classpath" fork="true">
<arg value="${symbol}"/>
<arg value="${url}"/>
+ <arg value="${repository}"/>
</java>
</target>
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=370437&r1=370436&r2=370437&view=diff
==============================================================================
---
incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java
(original)
+++
incubator/synapse/trunk/java/src/samples/userguide/DumbStockQuoteClient.java
Thu Jan 19 00:35:06 2006
@@ -1,10 +1,9 @@
package samples.userguide;
-
-
-
import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
@@ -13,72 +12,86 @@
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
-
-
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();
- }
+ /**
+ * <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];
+ boolean repository = false;
+ if (args.length > 2) repository = true;
+ try {
+ ServiceClient serviceClient;
+ if (repository) {
+ ConfigurationContextFactory fac =
+ new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ fac.createConfigurationContextFromFileSystem(args[2]);
+ serviceClient = new ServiceClient(configContext, null);
+ } else {
+ serviceClient = new ServiceClient();
+ }
+
+ // 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.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();
+ }
- }
+ }
}
Modified:
incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java?rev=370437&r1=370436&r2=370437&view=diff
==============================================================================
---
incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java
(original)
+++
incubator/synapse/trunk/java/src/samples/userguide/ProxyStockQuoteClient.java
Thu Jan 19 00:35:06 2006
@@ -3,6 +3,8 @@
import java.net.URL;
import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -13,98 +15,116 @@
public class ProxyStockQuoteClient {
- /**
- *
- * <p>
- * This is a fairly static test client for Synapse using the HTTP Proxy
- * model. It makes a StockQuote request to XMethods stockquote service.
- * There is no WS-Addressing To URL but we set the HTTP proxy URL to
point
- * to Synapse. This results in the destination XMethods URL being
embedded
- * in the POST header. Synapse will pick this out and use it to direct
the
- * message
- *
- */
- 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 proxy\n"
- + "Usage:
ProxyStockQuoteClient Symbol StockQuoteURL ProxyURL");
- System.out
- .println("\nDefault values: IBM
http://www.webservicex.net/stockquote.asmx http://localhost:8080");
- System.out
- .println("\nThe XMethods URL will be
used in the <wsa:To> header");
- System.out.println("The Proxy URL will be used as an
HTTP proxy");
- System.out
- .println("\nTo demonstrate Synapse
virtual URLs, set the URL to http://stockquote\n"
- + "\nTo demonstrate
content-based behaviour, set the Symbol to MSFT\n"
- + "\nAll examples
depend on using the sample synapse.xml");
- System.exit(0);
- }
-
- String symb = "IBM";
- String xurl = "http://www.webservicex.net/stockquote.asmx";
- String purl = "http://localhost:8080";
-
- if (args.length > 0)
- symb = args[0];
- if (args.length > 1)
- xurl = args[1];
- if (args.length > 2)
- purl = args[2];
-
- 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(xurl);
-
- Options options = new Options();
- options.setTo(targetEPR);
-
- URL url = new URL(purl);
-
- // engage HTTP Proxy
-
- HttpTransportProperties httpProps = new
HttpTransportProperties();
-
- HttpTransportProperties.ProxyProperties proxyProperties
= httpProps.new ProxyProperties();
- proxyProperties.setProxyName(url.getHost());
- proxyProperties.setProxyPort(url.getPort());
- proxyProperties.setUserName("");
- proxyProperties.setPassWord("");
- proxyProperties.setDomain("");
-
- options.setProperty(HTTPConstants.PROXY,
proxyProperties);
-
-
options.setAction("http://www.webserviceX.NET/GetQuote");
- // create a lightweight Axis Config with no addressing
to
- // demonstrate "dumb" SOAP
-
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();
- }
+ /**
+ * <p/>
+ * This is a fairly static test client for Synapse using the HTTP Proxy
+ * model. It makes a StockQuote request to XMethods stockquote service.
+ * There is no WS-Addressing To URL but we set the HTTP proxy URL to point
+ * to Synapse. This results in the destination XMethods URL being embedded
+ * in the POST header. Synapse will pick this out and use it to direct the
+ * message
+ */
+ 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 proxy\n"
+ +
+ "Usage: ProxyStockQuoteClient Symbol StockQuoteURL
ProxyURL");
+ System.out
+ .println(
+ "\nDefault values: IBM
http://www.webservicex.net/stockquote.asmx http://localhost:8080");
+ System.out
+ .println(
+ "\nThe XMethods URL will be used in the <wsa:To>
header");
+ System.out.println("The Proxy URL will be used as an HTTP proxy");
+ System.out
+ .println(
+ "\nTo demonstrate Synapse virtual URLs, set the
URL to http://stockquote\n"
+ +
+ "\nTo demonstrate content-based behaviour,
set the Symbol to MSFT\n"
+ +
+ "\nAll examples depend on using the sample
synapse.xml");
+ System.exit(0);
+ }
+
+ String symb = "IBM";
+ String xurl = "http://www.webservicex.net/stockquote.asmx";
+ String purl = "http://localhost:8080";
+
+ if (args.length > 0)
+ symb = args[0];
+ if (args.length > 1)
+ xurl = args[1];
+ if (args.length > 2)
+ purl = args[2];
+
+ boolean repository = false;
+ if (args.length > 3) repository = true;
+
+ try {
+ ServiceClient serviceClient;
+ if (repository) {
+ ConfigurationContextFactory fac =
+ new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ fac.createConfigurationContextFromFileSystem(args[3]);
+ serviceClient = new ServiceClient(configContext, null);
+ } else {
+ serviceClient = new ServiceClient();
+ }
+
+ // 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(xurl);
+
+ Options options = new Options();
+ options.setTo(targetEPR);
+
+ URL url = new URL(purl);
+
+ // engage HTTP Proxy
+
+ HttpTransportProperties httpProps = new HttpTransportProperties();
+
+ HttpTransportProperties.ProxyProperties proxyProperties =
+ httpProps.new ProxyProperties();
+ proxyProperties.setProxyName(url.getHost());
+ proxyProperties.setProxyPort(url.getPort());
+ proxyProperties.setUserName("");
+ proxyProperties.setPassWord("");
+ proxyProperties.setDomain("");
+
+ options.setProperty(HTTPConstants.PROXY, proxyProperties);
+
+ options.setAction("http://www.webserviceX.NET/GetQuote");
+ // create a lightweight Axis Config with no addressing to
+ // demonstrate "dumb" SOAP
+ options.setProperty(
+
Constants.Configuration.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
+ new Boolean(true));
+
+
+ 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();
+ }
- }
+ }
}
Modified:
incubator/synapse/trunk/java/src/samples/userguide/StockQuoteClient.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/samples/userguide/StockQuoteClient.java?rev=370437&r1=370436&r2=370437&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/samples/userguide/StockQuoteClient.java
(original)
+++ incubator/synapse/trunk/java/src/samples/userguide/StockQuoteClient.java
Thu Jan 19 00:35:06 2006
@@ -4,81 +4,104 @@
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.om.OMElement;
public class StockQuoteClient {
- /**
- * @param args
- * <p>
- * This is a fairly static test client for Synapse. It makes
a
- * StockQuote request to WebServiceX stockquote service. The
EPR
- * it is sent to is for WebServiceX, but the actual
transport URL
- * is designed to go to the Synapse listener.
- *
- */
- public static void main(String[] args) {
-
- if (args.length > 0 && args[0].substring(0, 1).equals("-")) {
- System.out
- .println("Usage: StockQuoteClient
Symbol StockQuoteURL TransportURL");
- System.out
- .println("\nDefault values: IBM
http://www.webservicex.net/stockquote.asmx http://localhost:8080");
- System.out
- .println("\nThe XMethods URL will be
used in the <wsa:To> header");
- System.out
- .println("The Transport URL will be
used as the actual address to send to");
- System.out
- .println("\nTo bypass Synapse, set the
transport URL to the WebServiceX URL: \n"
- + "e.g.
StockQuoteClient IBM http://www.webservicex.net/stockquote.asmx
http://www.webservicex.net/stockquote.asmx \n"
- + "\nTo demonstrate
Synapse virtual URLs, set the URL to http://stockquote\n"
- + "\nTo demonstrate
content-based behaviour, set the Symbol to MSFT\n"
- + "\nAll examples
depend on using the sample synapse.xml");
- System.exit(0);
- }
-
- String symb = "IBM";
- String xurl = "http://www.webservicex.net/stockquote.asmx";
- String turl = "http://localhost:8080";
-
- if (args.length > 0)
- symb = args[0];
- if (args.length > 1)
- xurl = args[1];
- if (args.length > 2)
- turl = args[2];
-
- try {
- // step 1 - create a request payload
- OMElement getQuote = StockQuoteXMLHandler
- .createRequestPayload(symb);
- // step 2 - set up the call object
- // the wsa:To
-
-
- Options options = new Options();
- EndpointReference targetEPR = new
EndpointReference(xurl);
- options.setTo(targetEPR);
-
-
options.setProperty(MessageContextConstants.TRANSPORT_URL, turl);
-
-
options.setAction("http://www.webserviceX.NET/GetQuote");
-
-
//options.setSoapAction("http://www.webserviceX.NET/GetQuote");
-
- ServiceClient serviceClient = new ServiceClient();
- serviceClient.setOptions(options);
- // step 3 - Blocking invocation
- OMElement result = serviceClient.sendReceive(getQuote);
- // System.out.println(result);
- serviceClient.setOptions(options);
- // step 4 - parse result
- System.out.println("Stock price = $"
- +
StockQuoteXMLHandler.parseResponse(result));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ /**
+ * @param args <p/>
+ * This is a fairly static test client for Synapse. It makes a
+ * StockQuote request to WebServiceX stockquote service. The
EPR
+ * it is sent to is for WebServiceX, but the actual transport
URL
+ * is designed to go to the Synapse listener.
+ */
+ public static void main(String[] args) {
+
+ if (args.length > 0 && args[0].substring(0, 1).equals("-")) {
+ System.out
+ .println(
+ "Usage: StockQuoteClient Symbol StockQuoteURL
TransportURL");
+ System.out
+ .println(
+ "\nDefault values: IBM
http://www.webservicex.net/stockquote.asmx http://localhost:8080");
+ System.out
+ .println(
+ "\nThe XMethods URL will be used in the <wsa:To>
header");
+ System.out
+ .println(
+ "The Transport URL will be used as the actual
address to send to");
+ System.out
+ .println(
+ "\nTo bypass Synapse, set the transport URL to the
WebServiceX URL: \n"
+ +
+ "e.g. StockQuoteClient IBM
http://www.webservicex.net/stockquote.asmx
http://www.webservicex.net/stockquote.asmx \n"
+ +
+ "\nTo demonstrate Synapse virtual URLs,
set the URL to http://stockquote\n"
+ +
+ "\nTo demonstrate content-based behaviour,
set the Symbol to MSFT\n"
+ +
+ "\nAll examples depend on using the sample
synapse.xml");
+ System.exit(0);
+ }
+
+ String symb = "IBM";
+ String xurl = "http://www.webservicex.net/stockquote.asmx";
+ String turl = "http://localhost:8080";
+
+
+ if (args.length > 0)
+ symb = args[0];
+ if (args.length > 1)
+ xurl = args[1];
+ if (args.length > 2)
+ turl = args[2];
+
+ boolean repository = false;
+ if (args.length > 3) repository = true;
+
+ try {
+ // step 1 - create a request payload
+ OMElement getQuote = StockQuoteXMLHandler
+ .createRequestPayload(symb);
+ // step 2 - set up the call object
+ // the wsa:To
+
+ ServiceClient serviceClient;
+ if (repository) {
+ ConfigurationContextFactory fac =
+ new ConfigurationContextFactory();
+ ConfigurationContext configContext =
+ fac.createConfigurationContextFromFileSystem(args[3]);
+ serviceClient = new ServiceClient(configContext, null);
+ } else {
+ serviceClient = new ServiceClient();
+ }
+
+ Options options = new Options();
+ EndpointReference targetEPR = new EndpointReference(xurl);
+ options.setTo(targetEPR);
+
+ options.setProperty(MessageContextConstants.TRANSPORT_URL, turl);
+
+ options.setAction("http://www.webserviceX.NET/GetQuote");
+
+ //options.setSoapAction("http://www.webserviceX.NET/GetQuote");
+
+
+ serviceClient.setOptions(options);
+ // step 3 - Blocking invocation
+ OMElement result = serviceClient.sendReceive(getQuote);
+ // System.out.println(result);
+ serviceClient.setOptions(options);
+ // step 4 - parse result
+ System.out.println("Stock price = $"
+ + StockQuoteXMLHandler.parseResponse(result));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]