Author: saminda
Date: Tue Apr 4 07:48:16 2006
New Revision: 391325
URL: http://svn.apache.org/viewcvs?rev=391325&view=rev
Log:
clean up the code and removed hacks
Modified:
incubator/synapse/trunk/java/modules/core/conf/log4j.properties
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/rules/RegexMediator.java
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/DumbStockQuoteClient.java
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/StockQuoteXMLHandler.java
Modified: incubator/synapse/trunk/java/modules/core/conf/log4j.properties
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/conf/log4j.properties?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/conf/log4j.properties (original)
+++ incubator/synapse/trunk/java/modules/core/conf/log4j.properties Tue Apr 4
07:48:16 2006
@@ -1,7 +1,7 @@
log4j.rootCategory=ERROR,logfile,stdout
# Set the level to DEBUG if you want to log all SlideExceptions (some of them
aren't errors)
-log4j.category.org.apache.axis2=INFO
+#log4j.category.org.apache.axis2=INFO
log4j.category.org.apache.synapse=DEBUG
Modified:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
Tue Apr 4 07:48:16 2006
@@ -174,6 +174,8 @@
smc.getProperty(
org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
+ System.out.println("################# getTo of response :" +
response.getTo());
+
// If request is REST we assume the response is REST, so set the
// variable
response.setDoingREST(smc.isDoingREST());
Modified:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/axis2/Axis2Sender.java
Tue Apr 4 07:48:16 2006
@@ -54,6 +54,7 @@
if (smc.getProperty(Constants.ENGAGE_ADDRESSING_IN_MESSAGE) !=
null)
{
+
messageContext.setProperty(
Constants.ENGAGE_ADDRESSING_IN_MESSAGE, Boolean.TRUE);
@@ -72,75 +73,24 @@
// run all rules on response
- smc.setResponse(true);
-//
///////////////////////////////////////////////////////////////////
-// // special treat for Module Engagement
-// ConfigurationContext configContext = (ConfigurationContext) smc
-// .getProperty(
-//
Constants.ADDRESSING_PROCESSED_CONFIGURATION_CONTEXT);
-// if (configContext != null) {
-// outMsgContext.setProperty(
-// Constants.ADDRESSING_PROCESSED_CONFIGURATION_CONTEXT,
-// configContext);
-// }
-//
//////////////////////////////////////////////////////////////////
+ smc.setResponse(true);//
outMsgContext.setServerSide(true);
- // deal with the fact that AddressingOutHandler has a bug if
- // there is no header at all.
- // fixed in axis 0.9652
- SOAPEnvelope envelope = outMsgContext.getEnvelope();
- // temporarty hack
- SOAPEnvelope newEnvelope;
- if (envelope.getHeader() == null) {
- SOAPFactory soapFactory;
- if (envelope.getNamespace().getName()
- .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
- soapFactory = OMAbstractFactory.getSOAP12Factory();
- newEnvelope = soapFactory.getDefaultEnvelope();
- } else {
- soapFactory = OMAbstractFactory.getSOAP11Factory();
- newEnvelope = soapFactory.getDefaultEnvelope();
-
- }
- /**
- * Need a big fix here. Axis2 folks should fix this
- */
- //envelope.addChild(soapFactory.createSOAPHeader(envelope));
- //todo: bug in Axiom when another tree is declared and copy
some elements from one tree to other
- //todo: the second tree doesn't serialize attribute aware
namespaces properly
- //todo: as a temporartory hack this was taken into account
- Iterator iterator = envelope.getAllDeclaredNamespaces();
- while (iterator.hasNext()) {
- OMNamespace namespace = (OMNamespace) iterator.next();
- if (namespace.getName()
-
.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI) ||
- namespace.getName()
-
.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))
- {
- continue;
- }
- newEnvelope.declareNamespace(namespace);
- }
- newEnvelope.getBody()
- .addChild(envelope.getBody().getFirstElement());
- outMsgContext.setEnvelope(newEnvelope);
- }
-
Object os = messageContext
.getProperty(MessageContext.TRANSPORT_OUT);
outMsgContext.setProperty(MessageContext.TRANSPORT_OUT, os);
TransportInDescription ti = messageContext.getTransportIn();
outMsgContext.setTransportIn(ti);
-
- if (smc.getSynapseEnvironment()==null) {
- throw new SynapseException("no Synapse Env set on message");
+
+ if (smc.getSynapseEnvironment() == null) {
+ throw new SynapseException("no Synapse Env set on message");
}
- smc.getSynapseEnvironment().injectMessage(new
Axis2SynapseMessage(outMsgContext, smc.getSynapseEnvironment()));
+ smc.getSynapseEnvironment().injectMessage(new Axis2SynapseMessage(
+ outMsgContext, smc.getSynapseEnvironment()));
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new SynapseException(e);
}
}
@@ -151,25 +101,14 @@
AxisEngine ae =
new AxisEngine(messageContext.getConfigurationContext());
try {
- if (messageContext.getEnvelope().getHeader() == null) {
- messageContext.getEnvelope().getBody().insertSiblingBefore(
- OMAbstractFactory.getSOAP11Factory()
- .getDefaultEnvelope()
- .getHeader());
-
- }
+//
messageContext
.setProperty(Constants.ISRESPONSE_PROPERTY, Boolean.TRUE);
// check for addressing is alredy engaged for this message.
// if engage we should use the address enable Configuraion context.
-// ConfigurationContext configContext = (ConfigurationContext) smc
-// .getProperty(
-//
Constants.ADDRESSING_PROCESSED_CONFIGURATION_CONTEXT);
-// if (configContext != null) {
-// messageContext.setConfigurationContext(configContext);
-// }
+//
ae.send(messageContext);
} catch (AxisFault e) {
Modified:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/rules/RegexMediator.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/rules/RegexMediator.java?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/rules/RegexMediator.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/rules/RegexMediator.java
Tue Apr 4 07:48:16 2006
@@ -81,7 +81,7 @@
toMatch = headerType.getHeader(smc);
}
- if (toMatch==null) return true;
+ if (toMatch==null) return false;
if (pattern.matcher(toMatch).matches()) {
log.debug("Regex pattern " + pattern.toString() + "
matched "
Modified:
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/DumbStockQuoteClient.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/samples/userguide/DumbStockQuoteClient.java?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
---
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/DumbStockQuoteClient.java
(original)
+++
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/DumbStockQuoteClient.java
Tue Apr 4 07:48:16 2006
@@ -74,7 +74,6 @@
// System.out.println(result);
// step 4 - parse result
-
System.out.println("Stock price = $"
+ StockQuoteXMLHandler.parseResponse(result));
Modified:
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/StockQuoteXMLHandler.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/samples/userguide/StockQuoteXMLHandler.java?rev=391325&r1=391324&r2=391325&view=diff
==============================================================================
---
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/StockQuoteXMLHandler.java
(original)
+++
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/StockQuoteXMLHandler.java
Tue Apr 4 07:48:16 2006
@@ -25,29 +25,27 @@
return getQuote;
}
- public static String parseResponse(OMElement result) throws
XMLStreamException {
- QName gQR = new QName("http://www.webserviceX.NET/",
"GetQuoteResponse");
+ public static String parseResponse(OMElement result)
+ throws XMLStreamException {
+ QName gQR =
+ new QName("http://www.webserviceX.NET/", "GetQuoteResponse");
- OMElement qResp = (OMElement)
result.getChildrenWithName(gQR).next();
+ OMElement qResp = (OMElement) result.getChildrenWithName(gQR).next();
- String text = ((OMText) qResp.getFirstOMChild()).getText();
- // this odd webservice embeds XML as a string inside other XML
- // hmmmm can't say its useful!
-
-
-
-
- StAXOMBuilder builder = new StAXOMBuilder(new
ByteArrayInputStream(
- text.getBytes()));
-
- OMElement parse = builder.getDocumentElement();
-
- OMElement last = (OMElement)
parse.getFirstElement().getFirstElement()
- .getNextOMSibling();
- OMText lastText = (OMText) last.getFirstOMChild();
- return lastText.getText();
-
- }
+ String text = qResp.getText();
+
+
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(
+ text.getBytes()));
+
+ OMElement parse = builder.getDocumentElement();
+
+ OMElement last = (OMElement) parse.getFirstElement().getFirstElement()
+ .getNextOMSibling();
+ OMText lastText = (OMText) last.getFirstOMChild();
+ return lastText.getText();
+
+ }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]