You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by in...@apache.org on 2007/12/13 10:19:10 UTC
svn commit: r603862 - in /webservices/synapse/trunk/java:
modules/core/src/main/java/org/apache/synapse/endpoints/
modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/
modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/ mod...
Author: indika
Date: Thu Dec 13 01:19:07 2007
New Revision: 603862
URL: http://svn.apache.org/viewvc?rev=603862&view=rev
Log:
add sample PS with loadbalnce and do the required changes to the client
Added:
webservices/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_2.wsdl
webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_154.xml
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/utils/EndpointDefinition.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java
webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/LoadbalanceFailoverClient.java
webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java Thu Dec 13 01:19:07 2007
@@ -23,7 +23,6 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -125,12 +124,11 @@
* having one active child endpoint is enough to consider this as active.
*
* @param synMessageContext MessageContext of the current message. This is not used here.
- *
* @return true if active. false otherwise.
*/
public boolean isActive(MessageContext synMessageContext) {
- if (!active) {
+ if (!active && endpoints != null) {
for (int i = 0; i < endpoints.size(); i++) {
Endpoint endpoint = (Endpoint) endpoints.get(i);
if (endpoint.isActive(synMessageContext)) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java Thu Dec 13 01:19:07 2007
@@ -41,12 +41,12 @@
* Choose an active endpoint using the round robin algorithm. If there are no active endpoints
* available, returns null.
*
- * @param synapseMessageContext
+ * @param synapseMessageContext MessageContext instance which holds all per-message properties
* @return endpoint to send the next message
*/
public Endpoint getNextEndpoint(MessageContext synapseMessageContext) {
- Endpoint nextEndpoint = null;
+ Endpoint nextEndpoint;
int attempts = 0;
do {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java Thu Dec 13 01:19:07 2007
@@ -34,11 +34,15 @@
*/
public class HttpSessionDispatcher implements Dispatcher {
+ private final static String TRANSPORT_HEADERS = "TRANSPORT_HEADERS";
+ /*HTTP Headers */
+ private final static String COOKIE = "Cookie";
+ private final static String SET_COOKIE = "Set-Cookie";
/**
* Map to store session -> endpoint mappings. Synchronized map is used as this is accessed by
* multiple threds (e.g. multiple clients different sessions).
*/
- Map sessionMap = Collections.synchronizedMap(new HashMap());
+ private final Map sessionMap = Collections.synchronizedMap(new HashMap());
/**
* Check if "Cookie" HTTP header is available. If so, check if that cookie is in the session map.
@@ -46,7 +50,6 @@
* that session.
*
* @param synCtx MessageContext possibly containing a "Cookie" HTTP header.
- *
* @return Endpoint Server endpoint for the given HTTP session.
*/
public Endpoint getEndpoint(MessageContext synCtx) {
@@ -54,12 +57,12 @@
Endpoint endpoint = null;
org.apache.axis2.context.MessageContext axis2MessageContext =
- ((Axis2MessageContext) synCtx).getAxis2MessageContext();
+ ((Axis2MessageContext) synCtx).getAxis2MessageContext();
- Object o = axis2MessageContext.getProperty("TRANSPORT_HEADERS");
+ Object o = axis2MessageContext.getProperty(TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
- Object cookie = headerMap.get("Cookie");
+ Object cookie = headerMap.get(COOKIE);
if (cookie != null) {
Object e = sessionMap.get(cookie);
@@ -77,22 +80,22 @@
* session ID is not already in the session map update the session map by mapping the cookie
* to the endpoint.
*
- * @param synCtx MessageContext possibly containing the "Set-Cookie" HTTP header.
+ * @param synCtx MessageContext possibly containing the "Set-Cookie" HTTP header.
* @param endpoint Endpoint to be mapped to the session.
*/
public void updateSession(MessageContext synCtx, Endpoint endpoint) {
org.apache.axis2.context.MessageContext axis2MessageContext =
- ((Axis2MessageContext) synCtx).getAxis2MessageContext();
+ ((Axis2MessageContext) synCtx).getAxis2MessageContext();
- Object o = axis2MessageContext.getProperty("TRANSPORT_HEADERS");
+ Object o = axis2MessageContext.getProperty(TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
- Object cookie = headerMap.get("Set-Cookie");
+ Object cookie = headerMap.get(SET_COOKIE);
if (cookie != null) {
// synchronized to avoid possible replacement of sessions
- synchronized(sessionMap) {
+ synchronized (sessionMap) {
if (!sessionMap.containsKey(cookie)) {
sessionMap.put(cookie, endpoint);
}
@@ -104,12 +107,12 @@
public void unbind(MessageContext synCtx) {
org.apache.axis2.context.MessageContext axis2MessageContext =
- ((Axis2MessageContext) synCtx).getAxis2MessageContext();
+ ((Axis2MessageContext) synCtx).getAxis2MessageContext();
- Object o = axis2MessageContext.getProperty("TRANSPORT_HEADERS");
+ Object o = axis2MessageContext.getProperty(TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
- Object cookie = headerMap.get("Cookie");
+ Object cookie = headerMap.get(COOKIE);
if (cookie != null) {
sessionMap.remove(cookie);
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java Thu Dec 13 01:19:07 2007
@@ -41,7 +41,7 @@
* Map to store session -> endpoint mappings. Synchronized map is used as this is accessed by
* multiple threds (e.g. multiple clients different sessions).
*/
- private Map sessionMap = Collections.synchronizedMap(new HashMap());
+ private final Map sessionMap = Collections.synchronizedMap(new HashMap());
public Endpoint getEndpoint(MessageContext synCtx) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java Thu Dec 13 01:19:07 2007
@@ -51,16 +51,19 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
- if(header != null) {
- OMElement sgcID = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
+ if (header != null) {
+ OMElement sgcElm = header.getFirstChildWithName(
+ new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
- if(sgcID != null && sgcID.getText() != null) {
+ if (sgcElm != null) {
+ String sgcID = sgcElm.getText();
- Object e = sessionMap.get(sgcID.getText());
+ if (sgcID != null) {
+ Object e = sessionMap.get(sgcID);
- if (e != null) {
- endpoint = (Endpoint) e;
+ if (e != null) {
+ endpoint = (Endpoint) e;
+ }
}
}
}
@@ -84,22 +87,24 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
- if(header != null) {
+ if (header != null) {
OMElement replyTo = header.getFirstChildWithName
- (new QName("http://www.w3.org/2005/08/addressing", "ReplyTo", "wsa"));
+ (new QName("http://www.w3.org/2005/08/addressing", "ReplyTo", "wsa"));
- if(replyTo != null) {
+ if (replyTo != null) {
OMElement referenceParameters = replyTo.getFirstChildWithName(new QName(
- "http://www.w3.org/2005/08/addressing", "ReferenceParameters", "wsa"));
+ "http://www.w3.org/2005/08/addressing", "ReferenceParameters", "wsa"));
- if(referenceParameters != null) {
- OMElement sgcID = referenceParameters.getFirstChildWithName(new QName(
- "http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
+ if (referenceParameters != null) {
+ OMElement sgcElm = referenceParameters.getFirstChildWithName(new QName(
+ "http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
// synchronized to avoid possible replacement of sessions
- synchronized(sessionMap) {
- if(!sessionMap.containsKey(sgcID.getText())) {
- sessionMap.put(sgcID.getText(), endpoint);
+ synchronized (sessionMap) {
+ String sgcID = sgcElm.getText();
+
+ if (!sessionMap.containsKey(sgcID)) {
+ sessionMap.put(sgcID, endpoint);
}
}
}
@@ -111,11 +116,16 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
- if(header != null) {
- OMElement sgcID = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
- if(sgcID != null && sgcID.getText() != null) {
- sessionMap.remove(sgcID.getText());
+ if (header != null) {
+ OMElement sgcIDElm = header.getFirstChildWithName(
+ new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
+
+ if (sgcIDElm != null) {
+ String sgcID = sgcIDElm.getText();
+
+ if (sgcID != null) {
+ sessionMap.remove(sgcID);
+ }
}
}
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/utils/EndpointDefinition.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/utils/EndpointDefinition.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/utils/EndpointDefinition.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/utils/EndpointDefinition.java Thu Dec 13 01:19:07 2007
@@ -262,7 +262,7 @@
/**
* To set the statistics enable variable value
*
- * @param statisticsState
+ * @param statisticsState Indicates whether statictics is enable or not
*/
public void setStatisticsState(int statisticsState) {
this.statisticsState = statisticsState;
Modified: webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java (original)
+++ webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/throttle/ThrottleMediator.java Thu Dec 13 01:19:07 2007
@@ -34,8 +34,8 @@
/**
- * The Mediator for the throttling - Throtting will occur according to the ws-policy which is specified as
- * the key for lookup from the registry or the inline policy
+ * The Mediator for the throttling - Throtting will occur according to the ws-policy
+ * which is specified as the key for lookup from the registry or the inline policy
* Only support IP based throttling- Throotling can manage per IP using the throttle policy
*/
@@ -59,7 +59,8 @@
private AccessRateController accessControler;
/* ConcurrentAccessController - limit the remote calleres concurrent access */
private ConcurrentAccessController concurrentAccessController = null;
- /* The property key that used when the ConcurrentAccessController look up from ConfigurationContext */
+ /* The property key that used when the ConcurrentAccessController
+ look up from ConfigurationContext */
private String key;
/* Is this env. support clustering*/
private boolean isClusteringEnable = false;
@@ -98,7 +99,7 @@
//To ensure check for clustering environment only happens one time
if ((throttle == null && !isResponse) || (isResponse
- && concurrentAccessController == null)) {
+ && concurrentAccessController == null)) {
ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
if (clusterManager != null &&
clusterManager.getContextManager() != null) {
@@ -108,7 +109,8 @@
// Throttle only will be created ,if the massage flow is IN
if (!isResponse) {
- //check the availability of the ConcurrentAccessControler if this is a clustered environment
+ //check the availability of the ConcurrentAccessControler
+ //if this is a clustered environment
if (isClusteringEnable) {
concurrentAccessController =
(ConcurrentAccessController) cc.getProperty(key);
@@ -120,7 +122,7 @@
if (traceOn && trace.isTraceEnabled()) {
trace.trace("Initializing using static throttling policy : "
- + inLinePolicy);
+ + inLinePolicy);
}
try {
// process the policy
@@ -133,7 +135,8 @@
//if this is the first instance on the cluster ,
// that message mediation has occurred through this mediator.
if (throttle != null && concurrentAccessController == null) {
- concurrentAccessController = throttle.getConcurrentAccessController();
+ concurrentAccessController =
+ throttle.getConcurrentAccessController();
if (concurrentAccessController != null) {
cc.setProperty(key, concurrentAccessController);
}
@@ -151,7 +154,7 @@
Entry entry = synCtx.getConfiguration().getEntryDefinition(policyKey);
if (entry == null) {
handleException("Cannot find throttling policy using key : "
- + policyKey, synCtx);
+ + policyKey, synCtx);
} else {
boolean reCreate = false;
@@ -166,7 +169,7 @@
if (entryValue == null) {
handleException(
"Null throttling policy returned by Entry : "
- + policyKey, synCtx);
+ + policyKey, synCtx);
} else {
if (!(entryValue instanceof OMElement)) {
@@ -179,7 +182,8 @@
// is not null and throttle is not null , then must reload.
if (isClusteringEnable && concurrentAccessController != null
&& throttle != null) {
- concurrentAccessController = null; // set null ,because need reload
+ concurrentAccessController = null; // set null ,
+ // because need reload
}
try {
@@ -188,10 +192,11 @@
PolicyEngine.getPolicy((OMElement) entryValue));
//For non-clustered environment , must re-initiates
- //For clustered environment, if concurrent access controller is null ,
+ //For clustered environment,
+ //concurrent access controller is null ,
//then must re-initiates
if (throttle != null && (concurrentAccessController == null
- || !isClusteringEnable)) {
+ || !isClusteringEnable)) {
concurrentAccessController =
throttle.getConcurrentAccessController();
if (concurrentAccessController != null) {
@@ -235,7 +240,8 @@
}
Replicator.replicate(cc);
} catch (ClusteringFault clusteringFault) {
- handleException("Error during the replicating states ", clusteringFault, synCtx);
+ handleException("Error during the replicating states ",
+ clusteringFault, synCtx);
}
}
}
@@ -278,9 +284,10 @@
/**
* Helper method that handles the concurrent access through throttle
- * @param isResponse Current Message is response or not
+ *
+ * @param isResponse Current Message is response or not
* @param traceOrDebugOn is trace or debug on?
- * @param traceOn is trace on?
+ * @param traceOn is trace on?
* @return true if the caller can access ,o.w. false
*/
private boolean doThrottleByConcurrency(boolean isResponse, boolean traceOrDebugOn, boolean traceOn) {
@@ -297,14 +304,15 @@
available = concurrentAccessController.getAndDecrement();
canAcess = available > 0;
if (traceOrDebugOn) {
- traceOrDebug(traceOn, "Concurrency Throttle : Access " + (canAcess ? "allowed" : "denied") +
- " :: " + available + " of available of " + concurrentLimit + " connections");
+ traceOrDebug(traceOn, "Concurrency Throttle : Access " +
+ (canAcess ? "allowed" : "denied") + " :: " + available
+ + " of available of " + concurrentLimit + " connections");
}
} else {
available = concurrentAccessController.incrementAndGet();
if (traceOrDebugOn) {
- traceOrDebug(traceOn, "Concurrency Throttle : Connection returned" +
- " :: " + available + " of available of " + concurrentLimit + " connections");
+ traceOrDebug(traceOn, "Concurrency Throttle : Connection returned" + " :: " +
+ available + " of available of " + concurrentLimit + " connections");
}
}
}
@@ -312,12 +320,13 @@
}
/**
- * Helper method that handles the access-rate based throttling
- * @param synCtx MessageContext(Synapse)
- * @param axisMC MessageContext(Axis2)
- * @param cc ConfigurationContext
+ * Helper method that handles the access-rate based throttling
+ *
+ * @param synCtx MessageContext(Synapse)
+ * @param axisMC MessageContext(Axis2)
+ * @param cc ConfigurationContext
* @param traceOrDebugOn is trace or debug on?
- * @param traceOn is trace on?
+ * @param traceOn is trace on?
* @return ue if the caller can access ,o.w. false
*/
private boolean throttleByAccessRate(MessageContext synCtx, org.apache.axis2.context.MessageContext axisMC, ConfigurationContext cc, boolean traceOrDebugOn, boolean traceOn) {
@@ -330,8 +339,8 @@
//domain name of the caller
String domainName = (String) axisMC.getPropertyNonReplicable(NhttpConstants.REMOTE_HOST);
- //Using remote caller domain name , If there is a throttle configuration for this domain name ,
- //then throttling will occur according to that configuration
+ //Using remote caller domain name , If there is a throttle configuration for
+ // this domain name ,then throttling will occur according to that configuration
if (domainName != null) {
// do the domain based throttling
if (traceOrDebugOn) {
@@ -423,7 +432,8 @@
callerId, ThrottleConstants.IP_BASE);
if (traceOrDebugOn) {
- traceOrDebug(traceOn, "Access " + (canAccess ? "allowed" : "denied")
+ traceOrDebug(traceOn, "Access " +
+ (canAccess ? "allowed" : "denied")
+ " for IP : " + remoteIP);
}
//In the case of both of concurrency throttling and
Modified: webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/LoadbalanceFailoverClient.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/LoadbalanceFailoverClient.java?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/LoadbalanceFailoverClient.java (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/LoadbalanceFailoverClient.java Thu Dec 13 01:19:07 2007
@@ -35,11 +35,16 @@
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.wsdl.WSDLConstants;
import javax.xml.namespace.QName;
import java.util.Random;
import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
public class LoadbalanceFailoverClient {
@@ -73,13 +78,16 @@
int iterations = 100;
boolean infinite = true;
- String pPort = System.getProperty("port");
- String pIterations = System.getProperty("i");
+ String pPort = getProperty("port", synapsePort);
+ String pIterations = getProperty("i", null);
+ String addUrl = getProperty("addurl", null);
+ String trpUrl = getProperty("trpurl", null);
+ String prxUrl = getProperty("prxurl", null);
if (pPort != null) {
try {
- stringToInt(pPort);
- synapsePort = System.getProperty("port");
+ Integer.parseInt(pPort);
+ synapsePort = pPort;
} catch (NumberFormatException e) {
// run with default value
}
@@ -87,7 +95,7 @@
if (pIterations != null) {
try {
- iterations = stringToInt(pIterations);
+ iterations = Integer.parseInt(pIterations);
if (iterations != -1) {
infinite = false;
}
@@ -103,23 +111,47 @@
Options options = new Options();
options.setTo(new EndpointReference("http://localhost:" + synapsePort));
- options.setAction("sampleOperation");
+ options.setAction("urn:sampleOperation");
String repo = System.getProperty("repository");
ConfigurationContext configContext;
if (repo != null) {
configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
- repo, repo + File.separator + "conf" + File.separator + "axis2.xml");
+ repo, repo + File.separator + "conf" + File.separator + "axis2.xml");
} else {
configContext = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem("client_repo", null);
+ createConfigurationContextFromFileSystem("client_repo", null);
}
ServiceClient client = new ServiceClient(configContext, null);
options.setTimeOutInMilliSeconds(10000000);
- client.setOptions(options);
- client.engageModule("addressing");
+ // set addressing, transport and proxy url
+ if (addUrl != null && !"null".equals(addUrl)) {
+ client.engageModule("addressing");
+ options.setTo(new EndpointReference(addUrl));
+ }
+ if (trpUrl != null && !"null".equals(trpUrl)) {
+ options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
+ } else {
+ client.engageModule("addressing");
+ }
+ if (prxUrl != null && !"null".equals(prxUrl)) {
+ HttpTransportProperties.ProxyProperties proxyProperties =
+ new HttpTransportProperties.ProxyProperties();
+ try {
+ URL url = new URL(prxUrl);
+ proxyProperties.setProxyName(url.getHost());
+ proxyProperties.setProxyPort(url.getPort());
+ proxyProperties.setUserName("");
+ proxyProperties.setPassWord("");
+ proxyProperties.setDomain("");
+ options.setProperty(HTTPConstants.PROXY, proxyProperties);
+ } catch (MalformedURLException e) {
+ throw new AxisFault("Error creating proxy URL", e);
+ }
+ }
+ client.setOptions(options);
String testString = "";
long i = 0;
@@ -148,13 +180,17 @@
int iterations = 100;
boolean infinite = true;
- String pPort = System.getProperty("port");
- String pIterations = System.getProperty("i");
+ String pPort = getProperty("port", synapsePort);
+ String pIterations = getProperty("i", null);
+ String addUrl = getProperty("addurl", null);
+ String trpUrl = getProperty("trpurl", null);
+ String prxUrl = getProperty("prxurl", null);
if (pPort != null) {
try {
- stringToInt(pPort);
- synapsePort = System.getProperty("port");
+
+ Integer.parseInt(pPort);
+ synapsePort = pPort;
} catch (NumberFormatException e) {
// run with default value
}
@@ -162,7 +198,7 @@
if (pIterations != null) {
try {
- iterations = stringToInt(pIterations);
+ iterations = Integer.parseInt(pIterations);
if (iterations != -1) {
infinite = false;
}
@@ -173,9 +209,10 @@
Options options = new Options();
options.setTo(new EndpointReference("http://localhost:" + synapsePort));
- options.setAction("sampleOperation");
+ options.setAction("urn:sampleOperation");
options.setTimeOutInMilliSeconds(10000000);
+
try {
SOAPEnvelope env1 = buildSoapEnvelope("c1", "v1");
@@ -184,10 +221,35 @@
SOAPEnvelope[] envelopes = {env1, env2, env3};
ConfigurationContext configContext = ConfigurationContextFactory.
- createConfigurationContextFromFileSystem("client_repo", null);
+ createConfigurationContextFromFileSystem("client_repo", null);
ServiceClient client = new ServiceClient(configContext, null);
+
+ // set addressing, transport and proxy url
+ if (addUrl != null && !"null".equals(addUrl)) {
+ client.engageModule("addressing");
+ options.setTo(new EndpointReference(addUrl));
+ }
+ if (trpUrl != null && !"null".equals(trpUrl)) {
+ options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
+ } else {
+ client.engageModule("addressing");
+ }
+ if (prxUrl != null && !"null".equals(prxUrl)) {
+ HttpTransportProperties.ProxyProperties proxyProperties =
+ new HttpTransportProperties.ProxyProperties();
+ try {
+ URL url = new URL(prxUrl);
+ proxyProperties.setProxyName(url.getHost());
+ proxyProperties.setProxyPort(url.getPort());
+ proxyProperties.setUserName("");
+ proxyProperties.setPassWord("");
+ proxyProperties.setDomain("");
+ options.setProperty(HTTPConstants.PROXY, proxyProperties);
+ } catch (MalformedURLException e) {
+ throw new AxisFault("Error creating proxy URL", e);
+ }
+ }
client.setOptions(options);
- client.engageModule("addressing");
int i = 0;
int sessionNumber = 0;
@@ -204,14 +266,14 @@
op.execute(true);
MessageContext responseContext =
- op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPEnvelope responseEnvelope = responseContext.getEnvelope();
OMElement vElement =
- responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
+ responseEnvelope.getBody().getFirstChildWithName(new QName("Value"));
System.out.println(
- "Request: " + i + " Session number: " +
- sessionNumber + " " + vElement.getText());
+ "Request: " + i + " Session number: " +
+ sessionNumber + " " + vElement.getText());
}
} catch (AxisFault axisFault) {
@@ -232,7 +294,7 @@
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
OMNamespace wsaNamespace = soapFactory.
- createOMNamespace("http://www.w3.org/2005/08/addressing", "wsa");
+ createOMNamespace("http://www.w3.org/2005/08/addressing", "wsa");
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
@@ -240,7 +302,7 @@
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.
- createOMNamespace("http://ws.apache.org/namespaces/synapse", "syn");
+ createOMNamespace("http://ws.apache.org/namespaces/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
@@ -255,10 +317,11 @@
return envelope;
}
- private int stringToInt(String stringNumber) {
-
- int number = new Integer(stringNumber).intValue();
-
- return number;
+ private static String getProperty(String name, String def) {
+ String result = System.getProperty(name);
+ if (result == null || result.length() == 0) {
+ result = def;
+ }
+ return result;
}
}
Modified: webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml?rev=603862&r1=603861&r2=603862&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml (original)
+++ webservices/synapse/trunk/java/modules/samples/src/main/scripts/build.xml Thu Dec 13 01:19:07 2007
@@ -156,6 +156,9 @@
<sysproperty key="mode" value="${mode}"/>
<sysproperty key="port" value="${port}"/>
<sysproperty key="i" value="${i}"/>
+ <sysproperty key="addurl" value="${addurl}"/>
+ <sysproperty key="trpurl" value="${trpurl}"/>
+ <sysproperty key="prxurl" value="${prxurl}"/>
</java>
</target>
Added: webservices/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_2.wsdl
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_2.wsdl?rev=603862&view=auto
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_2.wsdl (added)
+++ webservices/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_2.wsdl Thu Dec 13 01:19:07 2007
@@ -0,0 +1,289 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+ xmlns:ns0="http://services.samples"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:ns1="http://org.apache.axis2/xsd"
+ xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ targetNamespace="http://services.samples">
+ <wsdl:documentation>LBService1</wsdl:documentation>
+ <wsdl:types>
+ <xs:schema xmlns:ns="http://services.samples" attributeFormDefault="qualified"
+ elementFormDefault="qualified" targetNamespace="http://services.samples">
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+
+ </xs:complexType>
+ <xs:element name="loadOperation">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="param" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="loadOperationResponse">
+
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sampleOperation">
+ <xs:complexType>
+ <xs:sequence>
+
+ <xs:element minOccurs="0" name="param" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sampleOperationResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="setClientName">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="cName" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="setClientNameResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sleepOperation">
+ <xs:complexType>
+
+ <xs:sequence>
+ <xs:element minOccurs="0" name="param" nillable="true" type="xs:anyType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="sleepOperationResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType"/>
+
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="sleepOperationRequest">
+ <wsdl:part name="parameters" element="ns0:sleepOperation"/>
+ </wsdl:message>
+ <wsdl:message name="sleepOperationResponse">
+
+ <wsdl:part name="parameters" element="ns0:sleepOperationResponse"/>
+ </wsdl:message>
+ <wsdl:message name="setClientNameRequest">
+ <wsdl:part name="parameters" element="ns0:setClientName"/>
+ </wsdl:message>
+ <wsdl:message name="setClientNameResponse">
+ <wsdl:part name="parameters" element="ns0:setClientNameResponse"/>
+ </wsdl:message>
+ <wsdl:message name="sampleOperationRequest">
+
+ <wsdl:part name="parameters" element="ns0:sampleOperation"/>
+ </wsdl:message>
+ <wsdl:message name="sampleOperationResponse">
+ <wsdl:part name="parameters" element="ns0:sampleOperationResponse"/>
+ </wsdl:message>
+ <wsdl:message name="loadOperationRequest">
+ <wsdl:part name="parameters" element="ns0:loadOperation"/>
+ </wsdl:message>
+ <wsdl:message name="loadOperationResponse">
+
+ <wsdl:part name="parameters" element="ns0:loadOperationResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="LBService1PortType">
+ <wsdl:operation name="sleepOperation">
+ <wsdl:input message="ns0:sleepOperationRequest" wsaw:Action="urn:sleepOperation"/>
+ <wsdl:output message="ns0:sleepOperationResponse"
+ wsaw:Action="urn:sleepOperationResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="setClientName">
+ <wsdl:input message="ns0:setClientNameRequest" wsaw:Action="urn:setClientName"/>
+
+ <wsdl:output message="ns0:setClientNameResponse"
+ wsaw:Action="urn:setClientNameResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="sampleOperation">
+ <wsdl:input message="ns0:sampleOperationRequest" wsaw:Action="urn:sampleOperation"/>
+ <wsdl:output message="ns0:sampleOperationResponse"
+ wsaw:Action="urn:sampleOperationResponse"/>
+ </wsdl:operation>
+ <wsdl:operation name="loadOperation">
+ <wsdl:input message="ns0:loadOperationRequest" wsaw:Action="urn:loadOperation"/>
+ <wsdl:output message="ns0:loadOperationResponse"
+ wsaw:Action="urn:loadOperationResponse"/>
+
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="LBService1SOAP11Binding" type="ns0:LBService1PortType">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="sleepOperation">
+ <soap:operation soapAction="urn:sleepOperation" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="setClientName">
+ <soap:operation soapAction="urn:setClientName" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sampleOperation">
+ <soap:operation soapAction="urn:sampleOperation" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="loadOperation">
+ <soap:operation soapAction="urn:loadOperation" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="LBService1SOAP12Binding" type="ns0:LBService1PortType">
+ <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <wsdl:operation name="sleepOperation">
+ <soap12:operation soapAction="urn:sleepOperation" style="document"/>
+
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="setClientName">
+ <soap12:operation soapAction="urn:setClientName" style="document"/>
+
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="sampleOperation">
+ <soap12:operation soapAction="urn:sampleOperation" style="document"/>
+
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="loadOperation">
+ <soap12:operation soapAction="urn:loadOperation" style="document"/>
+
+ <wsdl:input>
+ <soap12:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap12:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="LBService1HttpBinding" type="ns0:LBService1PortType">
+
+ <http:binding verb="POST"/>
+ <wsdl:operation name="sleepOperation">
+ <http:operation location="LBService1/sleepOperation"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="sleepOperation"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="sleepOperation"/>
+ </wsdl:output>
+
+ </wsdl:operation>
+ <wsdl:operation name="setClientName">
+ <http:operation location="LBService1/setClientName"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="setClientName"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="setClientName"/>
+ </wsdl:output>
+
+ </wsdl:operation>
+ <wsdl:operation name="sampleOperation">
+ <http:operation location="LBService1/sampleOperation"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="sampleOperation"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="sampleOperation"/>
+ </wsdl:output>
+
+ </wsdl:operation>
+ <wsdl:operation name="loadOperation">
+ <http:operation location="LBService1/loadOperation"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="loadOperation"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="loadOperation"/>
+ </wsdl:output>
+
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="LBService1">
+ <wsdl:port name="LBService1SOAP11port_https" binding="ns0:LBService1SOAP11Binding">
+ <soap:address location="https://indika:9005/soap/LBService1"/>
+ </wsdl:port>
+ <wsdl:port name="LBService1SOAP11port_http1" binding="ns0:LBService1SOAP11Binding">
+ <soap:address location="http://indika:9001/soap/LBService1"/>
+ </wsdl:port>
+
+ <wsdl:port name="LBService1SOAP12port_https" binding="ns0:LBService1SOAP12Binding">
+ <soap12:address location="https://indika:9005/soap/LBService1"/>
+ </wsdl:port>
+ <wsdl:port name="LBService1SOAP12port_http1" binding="ns0:LBService1SOAP12Binding">
+ <soap12:address location="http://indika:9001/soap/LBService1"/>
+ </wsdl:port>
+ <wsdl:port name="LBService1Httpport" binding="ns0:LBService1HttpBinding">
+ <http:address location="https://indika:9005/soap/LBService1"/>
+ </wsdl:port>
+
+ <wsdl:port name="LBService1Httpport1" binding="ns0:LBService1HttpBinding">
+ <http:address location="http://indika:9001/soap/LBService1"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Added: webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_154.xml
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_154.xml?rev=603862&view=auto
==============================================================================
--- webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_154.xml (added)
+++ webservices/synapse/trunk/java/repository/conf/sample/synapse_sample_154.xml Thu Dec 13 01:19:07 2007
@@ -0,0 +1,71 @@
+<!--
+ ~ 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.
+ -->
+ <!-- A proxy service with a loadbalace endpoint -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <proxy name="LBProxy" transports="https http" startOnLoad="true">
+ <target faultSequence="errorHandler">
+ <inSequence>
+ <send>
+ <endpoint>
+ <session type="simpleClientSession"/>
+ <loadbalance algorithm="roundRobin">
+ <endpoint>
+ <address uri="http://localhost:9001/soap/LBService1">
+ <enableAddressing/>
+ <suspendDurationOnFailure>20</suspendDurationOnFailure>
+ </address>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9002/soap/LBService1">
+ <enableAddressing/>
+ <suspendDurationOnFailure>20</suspendDurationOnFailure>
+ </address>
+ </endpoint>
+ <endpoint>
+ <address uri="http://localhost:9003/soap/LBService1">
+ <enableAddressing/>
+ <suspendDurationOnFailure>20</suspendDurationOnFailure>
+ </address>
+ </endpoint>
+ </loadbalance>
+ </endpoint>
+ </send>
+ </inSequence>
+ <outSequence>
+ <send/>
+ </outSequence>
+ </target>
+ <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_2.wsdl"/>
+ </proxy>
+
+ <sequence name="errorHandler">
+
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="COULDN'T SEND THE MESSAGE TO THE SERVER."/>
+ </makefault>
+
+ <header name="To" action="remove"/>
+ <property name="RESPONSE" value="true"/>
+
+ <send/>
+ </sequence>
+
+</definitions>
\ 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