You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/05/16 16:15:44 UTC
svn commit: r406952 [2/2] - in /incubator/synapse/trunk/java: bin/ etc/
modules/core/ modules/core/src/org/apache/synapse/
modules/core/src/org/apache/synapse/config/
modules/core/src/org/apache/synapse/config/xml/
modules/core/src/org/apache/synapse/c...
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java Tue May 16 07:15:40 2006
@@ -226,7 +226,7 @@
} else {
if (
- SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX.equals(faultCodeValue.getNamespaceURI()) &&
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(faultCodeValue.getNamespaceURI()) &&
(SOAP12Constants.FAULT_CODE_DATA_ENCODING_UNKNOWN.equals(faultCodeValue.getLocalPart()) ||
SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND.equals(faultCodeValue.getLocalPart()) ||
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/transform/TransformMediator.java Tue May 16 07:15:40 2006
@@ -11,6 +11,7 @@
import org.apache.synapse.SynapseException;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.MediatorProperty;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jaxen.JaxenException;
@@ -27,6 +28,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
+import java.util.ArrayList;
/**
* The transform mediator performs an XSLT or XQuery transformation requested, using
@@ -41,6 +43,7 @@
private URL xsltUrl = null;
private URL xQueryUrl = null;
private AXIOMXPath source = null;
+ private List properties = new ArrayList();
/**
* Transforms this message (or its element specified as the source) using the
@@ -142,7 +145,7 @@
private void handleException(Exception e) {
String msg = "Error performing XSLT/XQ transformation " + e.getMessage();
- log.error(msg);
+ log.error(msg, e);
throw new SynapseException(msg, e);
}
@@ -168,6 +171,14 @@
public void setXQueryUrl(URL xQueryUrl) {
this.xQueryUrl = xQueryUrl;
+ }
+
+ public void addProperty(MediatorProperty p) {
+ properties.add(p);
+ }
+
+ public void addAllProperties(List list) {
+ properties.addAll(list);
}
}
Added: incubator/synapse/trunk/java/modules/core/test-resources/misc/validate2.xsd
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test-resources/misc/validate2.xsd?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test-resources/misc/validate2.xsd (added)
+++ incubator/synapse/trunk/java/modules/core/test-resources/misc/validate2.xsd Tue May 16 07:15:40 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m1="http://www.apache-synapse.org/test" xmlns:m2="http://www.apache-synapse.org/test2" targetNamespace="http://www.apache-synapse.org/test2" elementFormDefault="qualified" attributeFormDefault="unqualified">
+ <xs:import namespace="http://www.apache-synapse.org/test" schemaLocation="validate.xsd"/>
+
+ <xs:element name="CheckPriceRequest2">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code2" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="Outer">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="m1:CheckPriceRequest"/>
+ <xs:element ref="m2:CheckPriceRequest2"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestMessageContext.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestMessageContext.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestMessageContext.java Tue May 16 07:15:40 2006
@@ -26,6 +26,8 @@
import java.util.Map;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
public class TestMessageContext implements MessageContext {
@@ -65,6 +67,10 @@
public void setProperty(String key, Object value) {
properties.put(key, value);
+ }
+
+ public Set getPropertyKeySet() {
+ return properties.keySet();
}
//---------
Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java Tue May 16 07:15:40 2006
@@ -24,6 +24,26 @@
public class ValidateMediatorTest extends TestCase {
+ private static final String VALID_ENVELOPE_TWO_SCHEMAS =
+ "<Outer xmlns=\"http://www.apache-synapse.org/test2\">" +
+ "<m0:CheckPriceRequest xmlns:m0=\"http://www.apache-synapse.org/test\">\n" +
+ "<m0:Code>String</m0:Code>\n" +
+ "</m0:CheckPriceRequest>\n" +
+ "<m1:CheckPriceRequest2 xmlns:m1=\"http://www.apache-synapse.org/test2\">\n" +
+ "<m1:Code2>String</m1:Code2>\n" +
+ "</m1:CheckPriceRequest2>\n" +
+ "</Outer>";
+
+ private static final String INVALID_ENVELOPE_TWO_SCHEMAS =
+ "<Outer xmlns=\"http://www.apache-synapse.org/test2\">" +
+ "<m1:CheckPriceRequest2 xmlns:m1=\"http://www.apache-synapse.org/test2\">\n" +
+ "<m1:Code2>String</m1:Code2>\n" +
+ "</m1:CheckPriceRequest2>\n" +
+ "<m0:CheckPriceRequest xmlns:m0=\"http://www.apache-synapse.org/test\">\n" +
+ "<m0:Code>String</m0:Code>\n" +
+ "</m0:CheckPriceRequest>\n" +
+ "</Outer>";
+
private static final String VALID_ENVELOPE =
"<m0:CheckPriceRequest xmlns:m0=\"http://www.apache-synapse.org/test\">\n" +
"\t<m0:Code>String</m0:Code>\n" +
@@ -80,6 +100,48 @@
validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE));
assertTrue(!onFailInvoked);
+ }
+
+ public void testValidateMedaitorValidCaseTwoSchemas() throws Exception {
+ setOnFailInvoked(false);
+
+ // create a validate mediator
+ ValidateMediator validate = new ValidateMediator();
+
+ // set the schema url, source xpath and any name spaces
+ validate.setSchemaUrl("test-resources/misc/validate.xsd test-resources/misc/validate2.xsd");
+ AXIOMXPath source = new AXIOMXPath("//m0:Outer");
+ source.addNamespace("m0", "http://www.apache-synapse.org/test2");
+ validate.setSource(source);
+
+ // set dummy mediator to be called on fail
+ validate.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE_TWO_SCHEMAS));
+
+ assertTrue(!onFailInvoked);
+ }
+
+ public void testValidateMedaitorInvalidCaseTwoSchemas() throws Exception {
+ setOnFailInvoked(false);
+
+ // create a validate mediator
+ ValidateMediator validate = new ValidateMediator();
+
+ // set the schema url, source xpath and any name spaces
+ validate.setSchemaUrl("test-resources/misc/validate.xsd test-resources/misc/validate2.xsd");
+ AXIOMXPath source = new AXIOMXPath("//m0:Outer");
+ source.addNamespace("m0", "http://www.apache-synapse.org/test2");
+ validate.setSource(source);
+
+ // set dummy mediator to be called on fail
+ validate.addChild(testMediator);
+
+ // test validate mediator, with static enveope
+ validate.mediate(TestUtils.getTestContext(INVALID_ENVELOPE_TWO_SCHEMAS));
+
+ assertTrue(onFailInvoked);
}
public void testValidateMedaitorInvalidCase() throws Exception {
Added: incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java (added)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java Tue May 16 07:15:40 2006
@@ -0,0 +1,102 @@
+/*
+* 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;
+import org.apache.axis2.AxisFault;
+
+public class AdvancedQuoteClient {
+
+ public static void main(String[] args) {
+
+ String symbol = "MSFT";
+ String xurl = "http://ws.invesbot.com/stockquotes.asmx";
+ String turl = "http://localhost:8080/StockQuote";
+
+ testStandardQuote(symbol, xurl, turl);
+ testAdvancedQuote(symbol, xurl, turl);
+ testErroneousQuote(symbol, xurl, turl);
+ }
+
+ private static void testAdvancedQuote(String symbol, String xurl, String turl) {
+ try {
+ OMElement getQuote = CustomQuoteXMLHandler.createCustomRequestPayload(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);
+ System.out.println("Custom :: Stock price = $" + CustomQuoteXMLHandler.parseCustomResponsePayload(result.getFirstElement()));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void testErroneousQuote(String symbol, String xurl, String turl) {
+ try {
+ OMElement getQuote = CustomQuoteXMLHandler.createErroneousRequestPayload(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);
+ System.out.println("Error :: Stock price = $" + CustomQuoteXMLHandler.parseCustomResponsePayload(result.getFirstElement()));
+
+ } catch (Exception e) {
+ if (e instanceof AxisFault) {
+ System.out.println("Fault : " + ((AxisFault)e).getFaultElements());
+ } else {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ 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("Standard :: Stock price = $" + CustomQuoteXMLHandler.parseStandardResponsePayload(result));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
Added: incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomQuoteXMLHandler.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomQuoteXMLHandler.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomQuoteXMLHandler.java (added)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomQuoteXMLHandler.java Tue May 16 07:15:40 2006
@@ -0,0 +1,135 @@
+/*
+* 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.*;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
+
+public class CustomQuoteXMLHandler {
+
+ /**
+ * Create a new custom stock quote request with a body as follows
+ * <m0:CheckPriceRequest xmlns:m0="http://www.apache-synapse.org/test">
+ * <m0:Code>symbol</m0:Code>
+ * </m0:CheckPriceRequest>
+ * @param symbol the stock symbol
+ * @return OMElement for SOAP body
+ */
+ public static OMElement createCustomRequestPayload(String symbol) {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = factory.createOMNamespace("http://www.apache-synapse.org/test", "m0");
+ OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns);
+ OMElement code = factory.createOMElement("Code", ns);
+ chkPrice.addChild(code);
+ code.setText(symbol);
+ return chkPrice;
+ }
+
+ /**
+ * Create a new erroneous custom stock quote request with a body as follows
+ * <m0:CheckPriceRequest xmlns:m0="http://www.apache-synapse.org/test">
+ * <m0:Symbol>symbol</m0:Symbol>
+ * </m0:CheckPriceRequest>
+ * @param symbol the stock symbol
+ * @return OMElement for SOAP body
+ */
+ public static OMElement createErroneousRequestPayload(String symbol) {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = factory.createOMNamespace("http://www.apache-synapse.org/test", "m0");
+ OMElement chkPrice = factory.createOMElement("CheckPriceRequest", ns);
+ OMElement code = factory.createOMElement("Symbol", ns);
+ chkPrice.addChild(code);
+ code.setText(symbol);
+ return chkPrice;
+ }
+
+ /**
+ * Create a new custom stock quote request with a body as follows
+ <m:GetQuote xmlns:m="http://www.webserviceX.NET/">
+ <m:symbol>IBM</m:symbol>
+ </m:GetQuote>
+ * @param symbol the stock symbol
+ * @return OMElement for SOAP body
+ */
+ public static OMElement createStandardRequestPayload(String symbol) {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace ns = factory.createOMNamespace("http://ws.invesbot.com/", "m0");
+ OMElement getQuote = factory.createOMElement("GetQuote", ns);
+ OMElement symb = factory.createOMElement("symbol", ns);
+ getQuote.addChild(symb);
+ symb.setText(symbol);
+ return getQuote;
+ }
+
+ /**
+ * Digests the standard StockQuote response and extracts the last trade price
+ * @param result
+ * @return
+ * @throws XMLStreamException
+ *
+ <GetQuoteResponse xmlns="http://ws.invesbot.com/">
+ <GetQuoteResult>
+ <StockQuote xmlns="">
+ <Symbol>IBM</Symbol>
+ ...
+ <Price>82.47</Price>
+ .......
+ </StockQuote>
+ </GetQuoteResult>
+ </GetQuoteResponse>
+ */
+ public static String parseStandardResponsePayload(OMElement result) throws Exception {
+
+ OMElement getQResp = result.getFirstChildWithName(
+ new QName("http://ws.invesbot.com/", "StockQuote"));
+ if (getQResp != null) {
+ OMElement price = getQResp.getFirstChildWithName(
+ new QName("http://ws.invesbot.com/", "Price"));
+ return price.getText();
+ } else {
+ throw new Exception("Unexpected response : " + result);
+ }
+ }
+
+ /**
+ * Digests the custom quote response and extracts the last trade price
+ * @param result
+ * @return
+ * @throws XMLStreamException
+ *
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Body>
+ <CheckPriceResponse xmlns="http://ws.invesbot.com/" >
+ <Code>IBM</Code>
+ <Price>82.90</Price>
+ </CheckPriceResponse>
+ </soap:Body>
+ </soap:Envelope>
+ */
+ public static String parseCustomResponsePayload(OMElement result) throws Exception {
+
+ OMElement chkPResp = result.getFirstChildWithName(
+ new QName("http://www.apache-synapse.org/test", "CheckPriceResponse"));
+ if (chkPResp != null) {
+ OMElement price = chkPResp.getFirstChildWithName(new QName("http://www.apache-synapse.org/test", "Price"));
+ return price.getText();
+ } else {
+ throw new Exception("Unexpected response : " + result);
+ }
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java (added)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java Tue May 16 07:15:40 2006
@@ -0,0 +1,76 @@
+/*
+* 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.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axiom.om.OMElement;
+
+public class CustomStockQuoteClient {
+
+ public static void main(String[] args) {
+
+ String symbol = "IBM";
+ String xurl = "http://ws.invesbot.com/stockquotes.asmx";
+ String turl = "http://localhost:8080/StockQuote";
+
+ testStandardQuote(symbol, xurl, turl);
+ testCustomQuote(symbol, xurl, turl);
+ }
+
+ private static void testCustomQuote(String symbol, String xurl, String turl) {
+ try {
+ OMElement getQuote = CustomQuoteXMLHandler.createCustomRequestPayload(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("Custom :: Stock price = $" + CustomQuoteXMLHandler.parseCustomResponsePayload(result));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ 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("Standard :: Stock price = $" + CustomQuoteXMLHandler.parseStandardResponsePayload(result));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
Modified: incubator/synapse/trunk/java/repository/conf/axis2.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/axis2.xml?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/axis2.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/axis2.xml Tue May 16 07:15:40 2006
@@ -12,12 +12,16 @@
<!-- Location of the SynapseRepository -->
- <parameter name="SynapseConfiguration" locked="false">conf/synapse.xml</parameter>
+ <parameter name="SynapseConfiguration" locked="false">./../synapse_repository/conf/synapse.xml</parameter>
<parameter name="userName" locked="false">admin</parameter>
<parameter name="password" locked="false">axis2</parameter>
+ <!-- Always engage addressing for Synapse -->
<module ref="addressing"/>
+ <!-- This interceptor initializes Synapse on Axis2 startup -->
+ <listener class="org.apache.synapse.core.axis2.SynapseAxis2Interceptor"/>
+
<!-- ================================================= -->
<!-- Message Receivers -->
Added: incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_0.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_0.xml?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_0.xml (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_0.xml Tue May 16 07:15:40 2006
@@ -0,0 +1,39 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <definitions>
+
+ <sequence name="stockquote">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://www.webservicex.net/stockquote.asmx"/>
+
+ <!-- check if the symbol is MSFT -->
+ <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+ <!-- if it is throw a fault -->
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="Isn't there a Windows API for that?"/>
+ </makefault>
+ </filter>
+ </sequence>
+
+ </definitions>
+
+ <rules>
+ <!-- now log the message using log4j -->
+ <log level="full"/>
+
+ <!-- Check if the URL matches the stockquote gateway/dumb case -->
+ <filter source="get-property('To')" regex=".*/StockQuote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- check if the URL matches the virtual url - either the proxy or ws-add case -->
+ <filter source="get-property('To')" regex="http://stockquote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- send the message on -->
+ <send/>
+ </rules>
+
+</synapse>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_1.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_1.xml?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_1.xml (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_1.xml Tue May 16 07:15:40 2006
@@ -0,0 +1,87 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <definitions>
+
+ <sequence name="customrequest">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://ws.invesbot.com/stockquotes.asmx"/>
+
+ <!-- set correlation field to custom label -->
+ <set-property name="correlate/label" value="customquote"/>
+
+ <!-- transform the custom quote into a standard quote requst -->
+ <transform xslt="file:../synapse_repository/conf/sample/transform.xslt"/>
+
+ <!-- send message to real endpoint and stop -->
+ <send/>
+ <drop/>
+ </sequence>
+
+ <sequence name="customresponse">
+ <!-- transform the custom quote into a standard quote requst -->
+ <transform xslt="file:../synapse_repository/conf/sample/transform_back.xslt"/>
+
+ <!-- now send the custom response back to the client and stop -->
+ <send/>
+ <drop/>
+ </sequence>
+
+ <sequence name="stockquote">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://ws.invesbot.com/stockquotes.asmx"/>
+
+ <!-- check if the symbol is MSFT -->
+ <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+ <!-- if it is throw a fault -->
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="Isn't there a Windows API for that?"/>
+ </makefault>
+ </filter>
+
+ <send/>
+ </sequence>
+
+ <sequence name="standardrequest">
+ <!-- now log the message using log4j -->
+ <log level="full"/>
+
+ <!-- Check if the URL matches the stockquote gateway/dumb case -->
+ <filter source="get-property('To')" regex=".*/StockQuote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- check if the URL matches the virtual url - either the proxy or ws-add case -->
+ <filter source="get-property('To')" regex="http://stockquote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- send the message on -->
+ <send/>
+ </sequence>
+
+ </definitions>
+
+ <rules>
+ <in>
+ <!-- is this a custom stock quote message? -->
+ <filter xpath="//m0:CheckPriceRequest" xmlns:m0="http://www.apache-synapse.org/test">
+ <sequence ref="customrequest"/>
+ </filter>
+
+ <!-- else, proceed as usual with the standard processing rules -->
+ <sequence ref="standardrequest"/>
+ </in>
+
+ <out>
+ <!-- is this a custom stock quote reply? -->
+ <filter source="synapse:get-property('correlate/label')" regex="customquote">
+ <sequence ref="customresponse"/>
+ </filter>
+
+ <!-- just let the message flow through -->
+ <send/>
+ </out>
+ </rules>
+
+</synapse>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_2.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_2.xml?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_2.xml (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_2.xml Tue May 16 07:15:40 2006
@@ -0,0 +1,128 @@
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <definitions>
+
+ <!-- define global properties -->
+ <set-property name="version" value="0.1"/>
+
+ <!-- define a reuseable endpoint definition and use it within config -->
+ <endpoint name="invesbot" address="http://ws.invesbot.com/stockquotes.asmx"/>
+
+ <sequence name="customrequest">
+ <!-- is this a valid custom request ? -->
+ <validate schema="file:../synapse_repository/conf/sample/validate.xsd">
+ <on-fail>
+ <!-- if the request does not validate againt schema throw a fault -->
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="Invalid custom quote request"/>
+ </makefault>
+
+ <!-- send the fault and stop processing -->
+ <send/>
+ <drop/>
+ </on-fail>
+ </validate>
+
+ <switch source="//m0:CheckPriceRequest/m0:Code" xmlns:m0="http://www.apache-synapse.org/test">
+ <case regex="IBM">
+ <set-property name="symbol" value="Great stock - IBM"/>
+ </case>
+ <case regex="MSFT">
+ <set-property name="symbol" value="Are you sure? - MSFT"/>
+ </case>
+ <default>
+ <set-property name="symbol" expression="fn:concat('Normal Stock - ', //m0:CheckPriceRequest/m0:Code)" xmlns:m0="http://www.apache-synapse.org/test"/>
+ </default>
+ </switch>
+
+ <!-- set a dynamic (local) message property -->
+
+
+ <!-- set correlation field to custom label -->
+ <set-property name="correlate/label" value="customquote"/>
+
+ <!-- transform the custom quote into a standard quote requst -->
+ <transform xslt="file:../synapse_repository/conf/sample/transform.xslt"/>
+
+ <log level="custom">
+ <property name="Text" value="Sending quote request"/>
+ <property name="version" expression="synapse:get-property('version')"/>
+ <property name="symbol" expression="synapse:get-property('symbol')"/>
+ </log>
+
+ <!-- send message to real endpoint referenced by name "invesbot" and stop -->
+ <send>
+ <endpoint ref="invesbot"/>
+ </send>
+ <drop/>
+ </sequence>
+
+ <sequence name="customresponse">
+ <!-- transform the custom quote into a standard quote requst -->
+ <transform xslt="file:../synapse_repository/conf/sample/transform_back.xslt"/>
+
+ <!-- now send the custom response back to the client and stop -->
+ <send/>
+ <drop/>
+ </sequence>
+
+ <sequence name="stockquote">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://ws.invesbot.com/stockquotes.asmx"/>
+
+ <!-- check if the symbol is MSFT -->
+ <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+ <!-- if it is throw a fault -->
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="Isn't there a Windows API for that?"/>
+ </makefault>
+ </filter>
+
+ <send/>
+ </sequence>
+
+ <sequence name="standardrequest">
+ <!-- now log the message using log4j -->
+ <log level="full"/>
+
+ <!-- Check if the URL matches the stockquote gateway/dumb case -->
+ <filter source="get-property('To')" regex=".*/StockQuote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- check if the URL matches the virtual url - either the proxy or ws-add case -->
+ <filter source="get-property('To')" regex="http://stockquote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- send the message on -->
+ <send/>
+ </sequence>
+
+ </definitions>
+
+ <rules>
+ <in>
+ <!-- is this a custom stock quote message? -->
+ <filter xpath="//m0:CheckPriceRequest" xmlns:m0="http://www.apache-synapse.org/test">
+ <sequence ref="customrequest"/>
+ </filter>
+
+ <!-- else, proceed as usual with the standard processing rules -->
+ <sequence ref="standardrequest"/>
+ </in>
+
+ <out>
+ <!-- is this a custom stock quote reply? -->
+ <filter source="synapse:get-property('correlate/label')" regex="customquote">
+ <sequence ref="customresponse"/>
+ </filter>
+
+ <!-- just let the message flow through -->
+ <send/>
+ </out>
+ </rules>
+
+</synapse>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/transform.xslt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/transform.xslt?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/transform.xslt (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/transform.xslt Tue May 16 07:15:40 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
+ xmlns:m0="http://www.apache-synapse.org/test"
+ exclude-result-prefixes="m0 fn">
+<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="//m0:CheckPriceRequest" />
+</xsl:template>
+
+<xsl:template match="m0:CheckPriceRequest">
+
+<m:GetQuote xmlns:m="http://ws.invesbot.com/">
+ <m:symbol><xsl:value-of select="m0:Code"/></m:symbol>
+</m:GetQuote>
+
+</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/transform_back.xslt
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/transform_back.xslt?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/transform_back.xslt (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/transform_back.xslt Tue May 16 07:15:40 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
+ xmlns:m0="http://ws.invesbot.com/"
+ exclude-result-prefixes="m0 fn">
+<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="//m0:StockQuote" />
+</xsl:template>
+
+<xsl:template match="m0:StockQuote">
+
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+<soap:Body>
+<m:CheckPriceResponse xmlns:m="http://www.apache-synapse.org/test">
+ <m:Code><xsl:value-of select="m0:Symbol"/></m:Code>
+ <m:Price><xsl:value-of select="m0:Price"/></m:Price>
+</m:CheckPriceResponse>
+</soap:Body>
+</soap:Envelope>
+
+</xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/validate.xsd
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/sample/validate.xsd?rev=406952&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/validate.xsd (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/validate.xsd Tue May 16 07:15:40 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.apache-synapse.org/test" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.apache-synapse.org/test">
+ <xs:element name="CheckPriceRequest">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Code" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
Modified: incubator/synapse/trunk/java/repository/conf/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/synapse.xml?rev=406952&r1=406951&r2=406952&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/synapse.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/synapse.xml Tue May 16 07:15:40 2006
@@ -1,41 +1,39 @@
- <synapse xmlns="http://ws.apache.org/ns/synapse">
- <definitions>
- <sequence name="registration_flow">
- <filter xpath="//regRequest[@Category='GOLD']">
- <log level="full">
- <property name="category" value="GOLD"/>
- </log>
- <drop/>
- </filter>
- <sequence ref="fault_flow"/>
- </sequence>
+<synapse xmlns="http://ws.apache.org/ns/synapse">
- <sequence name="fault_flow">
- <log level="full">
- <property name="application" value="Hello World"/>
- </log>
- <drop/>
- </sequence>
-
- <sequence name="stockquote">
- <log level="full">
- <property name="application" value="StockQuote"/>
- </log>
- <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
- <makefault>
- <reason>Sorry the requested stock is no longer available</reason>
- </makefault>
- </filter>
- <header name="to" value="http://www.webservicex.net/stockquote.asmx"/>
- </sequence>
-
- </definitions>
-
- <rules>
- <filter source="//wsa:To" regex=".*/StockQuote.*" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
- <sequence ref="stockquote"/>
- </filter>
- <send/>
- </rules>
-
- </synapse>
\ No newline at end of file
+ <definitions>
+
+ <sequence name="stockquote">
+ <!-- set the To address to the real endpoint -->
+ <header name="To" value="http://www.webservicex.net/stockquote.asmx"/>
+
+ <!-- check if the symbol is MSFT -->
+ <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="http://www.webserviceX.NET/">
+ <!-- if it is throw a fault -->
+ <makefault>
+ <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/>
+ <reason value="Isn't there a Windows API for that?"/>
+ </makefault>
+ </filter>
+ </sequence>
+
+ </definitions>
+
+ <rules>
+ <!-- now log the message using log4j -->
+ <log level="full"/>
+
+ <!-- Check if the URL matches the stockquote gateway/dumb case -->
+ <filter source="get-property('To')" regex=".*/StockQuote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- check if the URL matches the virtual url - either the proxy or ws-add case -->
+ <filter source="get-property('To')" regex="http://stockquote.*">
+ <sequence ref="stockquote"/>
+ </filter>
+
+ <!-- send the message on -->
+ <send/>
+ </rules>
+
+</synapse>
\ 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