Author: asankha
Date: Mon Nov 27 07:19:25 2006
New Revision: 479658
URL: http://svn.apache.org/viewvc?view=rev&rev=479658
Log:
Add sample #105 - Pure POX/Text and Binary JMS Proxy services - including MTOM
Added:
incubator/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
incubator/synapse/trunk/java/repository/conf/sample/resources/mtom/
incubator/synapse/trunk/java/repository/conf/sample/resources/mtom/asf-logo.gif
(with props)
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
Modified:
incubator/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
Added:
incubator/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java?view=auto&rev=479658
==============================================================================
---
incubator/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
(added)
+++
incubator/synapse/trunk/java/modules/samples/src/main/java/samples/userguide/GenericJMSClient.java
Mon Nov 27 07:19:25 2006
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+package samples.userguide;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+
+public class GenericJMSClient {
+
+ public static void main(String[] args) throws Exception {
+
+ String dest = "dynamicQueues/JMSTextProxy";
+ String type = "text"; // or binary
+ String param = getRandom(100, 0.9, true) + " " +
+ (int) getRandom(10000, 1.0, true) + " IBM";
+
+ if (args.length > 0) dest = args[0];
+ if (args.length > 1) type = args[1];
+ if (args.length > 2 && param.length() > 0) param = args[2];
+
+ GenericJMSClient app = new GenericJMSClient();
+ if ("text".equalsIgnoreCase(type)) {
+ app.sendTextMessage(dest, param);
+ } else if ("binary".equalsIgnoreCase(type)) {
+ app.sendBytesMessage(dest, getBytesFromFile(param));
+ } else {
+ System.out.println("Unknown JMS message type");
+ }
+ }
+
+ private void sendBytesMessage(String destName, byte[] payload) throws
Exception {
+ InitialContext ic = getInitialContext();
+ ConnectionFactory confac = (ConnectionFactory)
ic.lookup("ConnectionFactory");
+ Connection connection = confac.createConnection();
+ Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer((Destination)
ic.lookup(destName));
+
+ BytesMessage bm = session.createBytesMessage();
+ bm.writeBytes(payload);
+ producer.send(bm);
+ connection.close();
+ }
+
+ private void sendTextMessage(String destName, String payload) throws
Exception {
+ InitialContext ic = getInitialContext();
+ ConnectionFactory confac = (ConnectionFactory)
ic.lookup("ConnectionFactory");
+ Connection connection = confac.createConnection();
+ Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer((Destination)
ic.lookup(destName));
+
+ TextMessage tm = session.createTextMessage(payload);
+ producer.send(tm);
+ connection.close();
+ }
+
+ private InitialContext getInitialContext() throws NamingException {
+ Properties env = new Properties();
+ if (System.getProperty("java.naming.provider.url") == null) {
+ env.put("java.naming.provider.url", "tcp://localhost:61616");
+ }
+ if (System.getProperty("java.naming.factory.initial") == null) {
+ env.put("java.naming.factory.initial",
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
+ }
+ return new InitialContext(env);
+ }
+
+ public static byte[] getBytesFromFile(String fileName) throws IOException {
+
+ File file = new File(fileName);
+ InputStream is = new FileInputStream(file);
+ long length = file.length();
+
+ byte[] bytes = new byte[(int) length];
+
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)
{
+ offset += numRead;
+ }
+
+ // Ensure all the bytes have been read in
+ if (offset < bytes.length) {
+ throw new IOException("Could not completely read file " +
file.getName());
+ }
+
+ is.close();
+ return bytes;
+ }
+
+ private static double getRandom(double base, double varience, boolean
onlypositive) {
+ double rand = Math.random();
+ return (base + ((rand > 0.5 ? 1 : -1) * varience * base * rand))
+ * (onlypositive ? 1 : (rand > 0.5 ? 1 : -1));
+ }
+
+}
Modified:
incubator/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/main/scripts/build.xml?view=diff&rev=479658&r1=479657&r2=479658
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/main/scripts/build.xml
(original)
+++ incubator/synapse/trunk/java/modules/samples/src/main/scripts/build.xml Mon
Nov 27 07:19:25 2006
@@ -23,13 +23,13 @@
This script requires Ant 1.5 or higher
usage:
- ant -help
+ ant -help
display ant help screen
- ant help
+ ant help
display this message
- ant clean
+ ant clean
delete the build directory
- ant compile
+ ant compile
build the samples
These client samples are able to send stock quote and order placement
messages
@@ -41,14 +41,14 @@
examples:
ant stockquote
- ant stockquote [-Dsymbol=IBM]
+ ant stockquote [-Dsymbol=IBM]
[-Durl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
[-Dsynapseurl=http://localhost:8080] [-Drepository=client_repo]
[-Dsecpolicy=..\..\repository\conf\sample\resources\policy\policy_1.xml]
ant proxystockquote
A client that could set Synapse as its HTTP proxy when sending requests
-
+
examples:
ant proxystockquote
ant proxystockquote [-Dsymbol=IBM]
@@ -58,21 +58,21 @@
ant dumbstockquote
A client that could directly invoke the service on a given endpoint.
Could be
used to test Synapse as a 'gateway'
-
+
examples:
ant dumbstockquote
ant dumbstockquote [-Dsymbol=IBM]
[-Dgatewayurl=http://localhost:8080/axis2/services/StockQuoteProxy]
[-Dsecpolicy=..\..\repository\conf\sample\resources\policy\policy_1.xml]
- ant customquote
+ ant customquote
A client which could send out a stock quote request in a custom format.
Synapse is
expected to transform this message to a standard request, and the
response back as
a custom response as expected by this client
-
+
examples:
- ant customquote
- ant customquote [-Dsymbol=IBM]
+ ant customquote
+ ant customquote [-Dsymbol=IBM]
[-Durl=http://localhost:9000/axis2/services/SimpleStockQuoteService]
[-Dsynapseurl=http://localhost:8080]
@@ -82,8 +82,16 @@
examples:
ant placeorder
- ant placeorder
+ ant placeorder
[-Dsymbol=IBM]
[-Dgatewayurl=http://localhost:8080/axis2/services/StockQuoteProxy]
+
+ ant jmsclient
+ A client which could post a JMS text or binary message to a given
destination.
+
+ examples
+ ant jmsclient
+ [-Ddest=dynamicQueues/JMSTextProxy] [-Dtype=text|binary]
+ [-Dpayload="24.34 100 IBM" |
"repository\conf\sample\resources\mtom\asf-logo.gif"]
</echo>
</target>
@@ -93,6 +101,9 @@
<property name="gatewayurl" value="http://localhost:8080/StockQuote"/>
<property name="repository" value="client_repo"/>
<property name="secpolicy" value=""/>
+ <property name="dest" value="dynamicQueues/JMSTextProxy"/>
+ <property name="type" value="text"/> <!-- or "binary" -->
+ <property name="payload" value=""/>
<property name="class.dir" value="target/classes"/>
@@ -107,7 +118,7 @@
<delete dir="${class.dir}" quiet="true"/>
</target>
- <target name="stockquote" depends="compile">
+ <target name="stockquote" depends="compile">
<java classname="samples.userguide.StockQuoteClient"
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
@@ -118,7 +129,7 @@
</java>
</target>
- <target name="proxystockquote" depends="compile">
+ <target name="proxystockquote" depends="compile">
<java classname="samples.userguide.ProxyStockQuoteClient"
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
@@ -127,7 +138,7 @@
</java>
</target>
- <target name="dumbstockquote" depends="compile">
+ <target name="dumbstockquote" depends="compile">
<java classname="samples.userguide.DumbStockQuoteClient"
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
@@ -137,7 +148,7 @@
</java>
</target>
- <target name="customquote" depends="compile">
+ <target name="customquote" depends="compile">
<java classname="samples.userguide.CustomStockQuoteClient"
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
@@ -151,6 +162,15 @@
classpathref="javac.classpath" fork="true">
<arg value="${symbol}"/>
<arg value="${gatewayurl}"/>
+ </java>
+ </target>
+
+ <target name="jmsclient" depends="compile">
+ <java classname="samples.userguide.GenericJMSClient"
+ classpathref="javac.classpath" fork="true">
+ <arg value="${dest}"/>
+ <arg value="${type}"/>
+ <arg value="${payload}"/>
</java>
</target>
Added:
incubator/synapse/trunk/java/repository/conf/sample/resources/mtom/asf-logo.gif
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/resources/mtom/asf-logo.gif?view=auto&rev=479658
==============================================================================
Binary file - no diff available.
Propchange:
incubator/synapse/trunk/java/repository/conf/sample/resources/mtom/asf-logo.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml?view=auto&rev=479658
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
(added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_105.xml
Mon Nov 27 07:19:25 2006
@@ -0,0 +1,65 @@
+<!--
+ ~ 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.
+ -->
+
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- demonstrate JMS raw Text / POX message support -->
+ <definitions>
+ <sequence name="text_proxy">
+ <header name="Action" value="urn:placeOrder"/>
+ <script.js><![CDATA[
+ var args = mc.getPayloadXML().toString().split(" ");
+ mc.setPayloadXML(
+ <m:placeOrder xmlns:m="http://services.samples/xsd">
+ <m:order>
+ <m:price>{args[0]}</m:price>
+ <m:quantity>{args[1]}</m:quantity>
+ <m:symbol>{args[2]}</m:symbol>
+ </m:order>
+ </m:placeOrder>);
+ ]]></script.js>
+ <send>
+ <endpoint
address="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
+ </send>
+ </sequence>
+
+ <sequence name="mtom_proxy">
+ <header name="Action" value="urn:uploadFileUsingMTOM"/>
+ <send>
+ <endpoint
address="http://localhost:9000/axis2/services/MTOMSampleService"
optimize="mtom"/>
+ </send>
+ </sequence>
+ </definitions>
+
+ <proxies>
+ <proxy name="JMSFileUploadProxy" transports="jms">
+ <target inSequence="mtom_proxy"/>
+ <property name="transport.jms.Wrapper"
value="{http://services.samples/xsd}element"/>
+ </proxy>
+ <proxy name="JMSTextProxy" transports="jms">
+ <target inSequence="text_proxy"/>
+ <property name="transport.jms.Wrapper"
value="{http://services.samples/xsd}text"/>
+ </proxy>
+ </proxies>
+
+ <rules>
+ <drop/>
+ </rules>
+
+</synapse>
\ No newline at end of file
Modified: incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=479658&r1=479657&r2=479658
==============================================================================
--- incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
(original)
+++ incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html Mon
Nov 27 07:19:25 2006
@@ -26,56 +26,77 @@
<h1>Running the Synapse Samples</h1>
<h2><a name="TOC">Contents</a></h2>
+
<div class="section-content">
- <ul>
- <li><a href="#Overview">Overview</a>
- </li>
- <li><a href="#Axis2Server">Starting the Axis2 Server</a>
- </li>
- <li><a href="#MediationSamples">Message mediation samples</a>
- <ul>
- <li><a href="#Sample0">Sample 0: Introduction to Synapse - log a
message</a></li>
- <li><a href="#Sample1">Sample 1: Content based routing</a></li>
- <li><a href="#Sample2">Sample 2: Switch-case mediator and writing and
reading of message properties</a></li>
- <li><a href="#Sample3">Sample 3: Simple properties, and reusable
endpoints and sequences</a></li>
- <li><a href="#Sample4">Sample 4: Error handling with the try and
makefault mediators</a></li>
- <li><a href="#Sample5">Sample 5: Error handling within a sequence
using the 'onError' sequence</a></li>
- <li><a href="#Sample6">Sample 6: Header, in and out mediators</a></li>
- <li><a href="#Sample7">Sample 7: Extension mediators, static XML
properties and the validate mediator</a></li>
- <li><a href="#Sample8">Sample 8: URL source properties, registry based
properties and the XSLT mediator</a></li>
- <li><a href="#Sample9">Sample 9: Dynamic sequences with a
Registry</a></li>
- <li><a href="#Sample10">Sample 10: Dynamic endpoints with a
Registry</a></li>
- <li><a href="#Sample11">Sample 11: A full registry based
configuration</a></li>
- </ul>
- </li>
- <li><a href="#WSSecurity">WS-Security</a>
- <ul>
- <li><a href="#Sample50">Sample 50: Connecting to endpoints with
WS-Security</a></li>
- </ul>
- </li>
- <li><a href="#ProxyServices">Synapse Proxy service samples</a>
- <ul>
- <li><a href="#Sample100">Sample 100: Introduction to Synapse proxy
services</a></li>
- <li><a href="#Sample101">Sample 101: Custom sequences and endpoints
for message mediation with proxy services</a></li>
- <li><a href="#Sample102">Sample 102: Attaching service level
WS-Security policies to proxy services</a></li>
- <li><a href="#Sample103">Sample 103: Using WS-Security signing and
encryption with proxy services through WS-Policy</a></li>
- <li><a href="#Sample104">Sample 104: Explicit out sequence in proxy
service level to mediate proxy response</a></li>
- </ul>
- </li>
- <li><a href="#ProxyServices">Transport samples</a>
- <ul>
- <li><a href="#Sample110">Sample 110: Introduction to switching
transports with proxy services</a></li>
- <li><a href="#Sample111">Sample 111: Demonstrate switching from HTTP
to JMS</a></li>
- <li><a href="#Sample112">Sample 112: Demonstrate one way messaging /
fireAndForget</a></li>
- </ul>
- </li>
- <li><a href="#ScriptMediators">Script Mediators</a>
- <ul>
- <li><a href="#Sample500">Sample 500: Introduction to script
mediators</a></li>
- <li><a href="#Sample501">Sample 501: In-line script mediators</a></li>
- </ul>
- </li>
- </ul>
+<ul>
+ <li><a href="#Overview">Overview</a></li>
+ <li><a href="#Axis2Server">Starting the Axis2 Server</a></li>
+ <li><a href="#MediationSamples">Message mediation samples</a>
+ <ul>
+ <li><a href="#Sample0">Sample 0: Introduction to Synapse - log a
+ message</a></li>
+ <li><a href="#Sample1">Sample 1: Content based routing</a></li>
+ <li><a href="#Sample2">Sample 2: Switch-case mediator and writing and
+ reading of message properties</a></li>
+ <li><a href="#Sample3">Sample 3: Simple properties, and reusable
+ endpoints and sequences</a></li>
+ <li><a href="#Sample4">Sample 4: Error handling with the try and
+ makefault mediators</a></li>
+ <li><a href="#Sample5">Sample 5: Error handling within a sequence using
+ the 'onError' sequence</a></li>
+ <li><a href="#Sample6">Sample 6: Header, in and out mediators</a></li>
+ <li><a href="#Sample7">Sample 7: Extension mediators, static XML
+ properties and the validate mediator</a></li>
+ <li><a href="#Sample8">Sample 8: URL source properties, registry based
+ properties and the XSLT mediator</a></li>
+ <li><a href="#Sample9">Sample 9: Dynamic sequences with a
+ Registry</a></li>
+ <li><a href="#Sample10">Sample 10: Dynamic endpoints with a
+ Registry</a></li>
+ <li><a href="#Sample11">Sample 11: A full registry based
+ configuration</a></li>
+ </ul>
+ </li>
+ <li><a href="#WSSecurity">WS-Security</a>
+ <ul>
+ <li><a href="#Sample50">Sample 50: Connecting to endpoints with
+ WS-Security</a></li>
+ </ul>
+ </li>
+ <li><a href="#ProxyServices">Synapse Proxy service samples</a>
+ <ul>
+ <li><a href="#Sample100">Sample 100: Introduction to Synapse proxy
+ services</a></li>
+ <li><a href="#Sample101">Sample 101: Custom sequences and endpoints for
+ message mediation with proxy services</a></li>
+ <li><a href="#Sample102">Sample 102: Attaching service level
+ WS-Security policies to proxy services</a></li>
+ <li><a href="#Sample103">Sample 103: Using WS-Security signing and
+ encryption with proxy services through WS-Policy</a></li>
+ <li><a href="#Sample104">Sample 104: Explicit out sequence in proxy
+ service level to mediate proxy response</a></li>
+ <li><a href="#Sample105">Sample 105: Pure POX/Text and Binary JMS Proxy
+ services - including MTOM</a></li>
+ </ul>
+ </li>
+ <li><a href="#ProxyServices">Transport samples</a>
+ <ul>
+ <li><a href="#Sample110">Sample 110: Introduction to switching
+ transports with proxy services</a></li>
+ <li><a href="#Sample111">Sample 111: Demonstrate switching from HTTP to
+ JMS</a></li>
+ <li><a href="#Sample112">Sample 112: Demonstrate one way messaging /
+ fireAndForget</a></li>
+ </ul>
+ </li>
+ <li><a href="#ScriptMediators">Script Mediators</a>
+ <ul>
+ <li><a href="#Sample500">Sample 500: Introduction to script
+ mediators</a></li>
+ <li><a href="#Sample501">Sample 501: In-line script mediators</a></li>
+ </ul>
+ </li>
+</ul>
</div>
<h2><a name="Overview">Overview</a></h2>
@@ -127,10 +148,9 @@
using the Synapse and Axis2 configuration files located at repository/conf</p>
<p>To start specific sample configurations of Synapse, use the -sample
-<number> switch as follows:
-<br>
-<pre>bin\synapse.bat -sample <number></pre>
+<number> switch as follows: <br>
</p>
+<pre>bin\synapse.bat -sample <number></pre>
<p>The above on a Windows system will use the sample synapse.xml
configuration file located at
@@ -556,7 +576,7 @@
quote client as 'ant stockquote' and see that the message is routed to the
SimpleStockQuoteService on the Axis2 instance. Repeat the above example and
notice that the endpoint is cached and reused by Synapse - similarly to
-example # 8. </p>
+example # 8.</p>
<pre>SimpleStockQuoteService :: Generating quote for : IBM</pre>
<p>Now edit the repository/conf/sample/resources/endpoint/dynamic_endpt_1.xml
@@ -811,9 +831,82 @@
<pre>DEBUG SequenceMediator - Sequence mediator <proxy_out> :: mediate()
DEBUG AbstractListMediator - Implicit Sequence <SequenceMediator> ::
mediate()
DEBUG LogMediator - Log mediator :: mediate()
-INFO LogMediator - message = Executing inside the out sequence</pre>
+INFO LogMediator - message = Executing inside the out sequence
+
+</pre>
+
+<h2>Sample 105:</h2>
+
+<p><strong>Objective: Pure POX/Text and Binary JMS Proxy services - including
+MTOM</strong></p>
+
+<p><strong>Pre-Requisites:</strong><br>
+Configure JMS for Synapse (Refer notes above)<br>
+Configure the script mediator runtime (Refer notes below)<br>
+i.e. make bsf-2.4.0.jar, xbean-2.2.0.jar and js-1.6R2.jar available in lib
+folder)<br>
+Start the Synapse configuration numbered 105: i.e. synapse -sample 105<br>
+Start the Axis2 server and deploy the SimpleStockQuoteService and the
+MTOMSampleService (Refer steps above)</p>
+
+<p>This configuration creates two JMS proxy services named JMSFileUploadProxy
+and JMSTextProxy exposed over JMS queues with the same names. The first part
+of this example demonstrates the pure text message support with JMS, where a
+user sends a text JMS message of the form "<price> <qty>
+<symbol>". Synapse converts this message into a SOAP message and sends
+this to the SimpleStockQuoteServices' placeOrder operation. The mediation
+uses the script mediator to transform the text message into a XML payload.
+The proxy service property named "transport.jms.Wrapper" defines the wrapper
+element QName, to be used when wrapping text/binary content into a SOAP
+envelope. </p>
+
+<p></p>
+
+<p>Execute 'ant jmsclient' which executes the first scenario. The client
+sends a JMS text message with the specified payload to the specified
+destination. Though the debug logs, you could see that Synapse received a
+text message over JMS and converted this to a SOAP message and sent it to the
+SimpleStockQuoteService as follows</p>
+
+<p></p>
+<pre>[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Proxy Service
JMSTextProxy received a new message...</pre>
+<pre>..</pre>
+<pre>[JMSWorker-1] DEBUG ProxyServiceMessageReceiver - Body :</pre>
+<pre><?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
/><soapenv:Body><axis2ns3:text
xmlns:axis2ns3="http://services.samples/xsd">65.05119159089897 6079
IBM</axis2ns3:text></soapenv:Body></soapenv:Envelope></pre>
+<pre>..<br></pre>
+<pre>[JMSWorker-1] DEBUG SendMediator - Sending message to endpoint :: name =
null resolved address =
http://localhost:9000/axis2/services/SimpleStockQuoteService
+<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header
/><soapenv:Body><m:placeOrder
xmlns:m="http://services.samples/xsd"><m:order><m:price>65.05119159089897</m:price><m:quantity>6079</m:quantity><m:symbol>IBM</m:symbol></m:order></m:placeOrder></soapenv:Body></soapenv:Envelope>
+</pre>
+
+<p>The next section uses the 'ant jmsclient -Dtype=binary
+-Dpayload=.\..\..\repository\conf\sample\resources\mtom\asf-logo.gif" which
+sends a JMS bytes message to the defined destination with the content of the
+payload file as its body. Synapse receives the bytes message and creates a
+SOAP envelope. If the axis2.xml used by Synapse enables MTOM optimization
+(through the 'enableMTOM' parameter), then Synapse sends an MTOM optimized
+message to the endpoint as follows, else it encodes the content as Base64:</p>
-<h1><a name="Transports">Transports</a></h1>
+<p></p>
+<pre>POST /axis2/services/MTOMSampleService HTTP/1.1</pre>
+<pre>SOAPAction: "urn:uploadFileUsingMTOM"</pre>
+<pre>User-Agent: Axis2</pre>
+<pre>Host: 127.0.0.1</pre>
+<pre>Content-Length: 8528</pre>
+<pre>Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_3FE7ADC48E69671C2211646391275465;
type="application/xop+xml"; start="<0.urn:uuid:[EMAIL PROTECTED]>";
start-info="text/xml";
charset=UTF-8--MIMEBoundaryurn_uuid_3FE7ADC48E69671C2211646391275465content-type:
application/xop+xml; charset=UTF-8; type="text/xml";content-transfer-encoding:
binarycontent-id:</pre>
+<pre><0.urn:uuid:[EMAIL PROTECTED]></pre>
+<pre><?xml version='1.0' encoding='UTF-8'?></pre>
+<pre><soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"></pre>
+<pre><soapenv:Header>...</soapenv:Header></pre>
+<pre><soapenv:Body></pre>
+<pre><axis2ns2:element
xmlns:axis2ns2="http://services.samples/xsd"></pre>
+<pre><xop:Include href="cid:1.urn:uuid:[EMAIL PROTECTED]"
xmlns:xop="http://www.w3.org/2004/08/xop/include" /></pre>
+<pre></axis2ns2:element></pre>
+<pre></soapenv:Body></pre>
+<pre></soapenv:Envelope>--MIMEBoundaryurn_uuid_3FE7ADC48E69671C2211646391275465content-type:
application/octet-streamcontent-transfer-encoding: binarycontent-id:</pre>
+<pre><1.urn:uuid:[EMAIL PROTECTED]>GIF89aƒd....
;--MIMEBoundaryurn_uuid_3FE7ADC48E69671C2211646391275465-</pre>
+<pre></pre>
+
+<h1><a name="Transports1" id="Transports1">Transports</a></h1>
<h2><a name="Sample110">Sample 110:</a></h2>
@@ -923,32 +1016,49 @@
<h1><a name="ScriptMediators">Script mediators</a></h1>
-<p>Synapse supports Mediators implemented in a variety of scripting languages
such as JavaScript, Python or Ruby.</p>
+<p>Synapse supports Mediators implemented in a variety of scripting languages
+such as JavaScript, Python or Ruby.</p>
-<p>Implementing a Mediator with a script language can have advantages over
using the built in Synapse Mediator types or implementing a custom Java class
Mediator. Script Mediators have all the flexibility of a class Mediator with
access to the Synapse MessageContext and SynapseEnvironment APIs, and the ease
of use and dynamic nature of scripting languages allows rapid development and
prototyping of custom mediators. An additional benefit of some scripting
languages is that they have very simple and elegant XML manipulation
capabilities, for example JavaScript E4X or Ruby REXML, so this makes them well
suited for use in the Synapse mediation environment.</p>
+<p>Implementing a Mediator with a script language can have advantages over
+using the built in Synapse Mediator types or implementing a custom Java class
+Mediator. Script Mediators have all the flexibility of a class Mediator with
+access to the Synapse MessageContext and SynapseEnvironment APIs, and the
+ease of use and dynamic nature of scripting languages allows rapid
+development and prototyping of custom mediators. An additional benefit of
+some scripting languages is that they have very simple and elegant XML
+manipulation capabilities, for example JavaScript E4X or Ruby REXML, so this
+makes them well suited for use in the Synapse mediation environment.</p>
<h2><a name="Sample500">Sample 500:</a></h2>
<p><strong>Objective: Introduction to script mediators</strong></p>
-<p>This sample is similar to sample 8 but instead of using XSLT the
transformation is done with JavaScript and E4X</p>
+<p>This sample is similar to sample 8 but instead of using XSLT the
+transformation is done with JavaScript and E4X</p>
<p><strong>Pre-Requisites:</strong></p>
-<p>
-This sample uses JavaScript/E4X which requires the Mozilla Rhino JavaScript
interpreter and Apache XmlBeans xbean be installed into your Synapse
distribution.
-If you've built Synapse from the src distribution these two jars will be in
your local Maven repository, otherwise you can download them manualy by right
clicking on the following links and choosing 'save link as...':
-<a href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar">rhino</a>
and <a
href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar">xbean</a>.
-Once you've got the two jars copy them to the lib directory of your Synapse
installation.
-</p>
+<p>This sample uses JavaScript/E4X which requires the Mozilla Rhino
+JavaScript interpreter and Apache XmlBeans xbean be installed into your
+Synapse distribution. If you've built Synapse from the src distribution these
+two jars will be in your local Maven repository, otherwise you can download
+them manualy by right clicking on the following links and choosing 'save link
+as...': <a
+href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar">rhino</a>
+and <a
+href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar">xbean</a>.
+Once you've got the two jars copy them to the lib directory of your Synapse
+installation.</p>
-<p>
-Start the Synapse configuration numbered 500: i.e. synapse -sample 500<br>
+<p>Start the Synapse configuration numbered 500: i.e. synapse -sample 500<br>
Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
-above)
-</p>
+above)</p>
-<p>The JavaScript script is in a separate file which the Synapse xml
references by using a static property named 'stockquoteScript'. The script has
two functions, 'transformRequest' and 'transformResponse', and the Synapse xml
script element uses the function attribute to specify which function to use for
the in and out rules.</p>
+<p>The JavaScript script is in a separate file which the Synapse xml
+references by using a static property named 'stockquoteScript'. The script
+has two functions, 'transformRequest' and 'transformResponse', and the
+Synapse xml script element uses the function attribute to specify which
+function to use for the in and out rules.</p>
<p>Execute the custom quote client as 'ant customquote' and check analyze the
the Synapse debug log output as shown below</p>
@@ -960,30 +1070,36 @@
<p>The incoming message is now transformed into a standard stock quote
request as expected by the SimpleStockQuoteService deployed on the local
-Axis2 instance by the JavaScript mediator. The JavaScript mediator uses E4X to
-perform the transformations. The response from the
-SimpleStockQuoteService is converted into the custom format as expected by
-the client during the out message processing.</p>
+Axis2 instance by the JavaScript mediator. The JavaScript mediator uses E4X
+to perform the transformations. The response from the SimpleStockQuoteService
+is converted into the custom format as expected by the client during the out
+message processing.</p>
<h2><a name="Sample501">Sample 501:</a></h2>
<p><strong>Objective: Introduction to in-line script mediators</strong></p>
-<p>This sample is the same as sample 500 but instead of having the JavaScript
source defined in a separate file it is defined in-line within the Synapse
XML.</p>
+<p>This sample is the same as sample 500 but instead of having the JavaScript
+source defined in a separate file it is defined in-line within the Synapse
+XML.</p>
<p><strong>Pre-Requisites:</strong></p>
-<p>
-This sample uses JavaScript/E4X which requires the Mozilla Rhino JavaScript
interpreter and Apache XmlBeans xbean be installed into your Synapse
distribution.
-If you've built Synapse from the src distribution these two jars will be in
your local Maven repository, otherwise you can download them manualy by right
clicking on the following links and choosing 'save link as...':
-<a href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar">rhino</a>
and <a
href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar">xbean</a>.
-Once you've got the two jars copy them to the lib directory of your Synapse
installation.
-</p>
-<p>
-Start the Synapse configuration numbered 501: i.e. synapse -sample 501<br>
+<p>This sample uses JavaScript/E4X which requires the Mozilla Rhino
+JavaScript interpreter and Apache XmlBeans xbean be installed into your
+Synapse distribution. If you've built Synapse from the src distribution these
+two jars will be in your local Maven repository, otherwise you can download
+them manualy by right clicking on the following links and choosing 'save link
+as...': <a
+href="http://repo1.maven.org/maven2/rhino/js/1.6R3/js-1.6R3.jar">rhino</a>
+and <a
+href="http://repo1.maven.org/maven2/xmlbeans/xbean/2.2.0/xbean-2.2.0.jar">xbean</a>.
+Once you've got the two jars copy them to the lib directory of your Synapse
+installation.</p>
+
+<p>Start the Synapse configuration numbered 501: i.e. synapse -sample 501<br>
Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
-above)
-</p>
+above)</p>
<p>Execute the custom quote client as 'ant customquote' and check analyze the
the Synapse debug log output as shown below</p>
@@ -995,10 +1111,9 @@
<p>The incoming message is now transformed into a standard stock quote
request as expected by the SimpleStockQuoteService deployed on the local
-Axis2 instance by the JavaScript mediator. The JavaScript mediator uses E4X to
-perform the transformations. The response from the
-SimpleStockQuoteService is converted into the custom format as expected by
-the client during the out message processing.</p>
-
+Axis2 instance by the JavaScript mediator. The JavaScript mediator uses E4X
+to perform the transformations. The response from the SimpleStockQuoteService
+is converted into the custom format as expected by the client during the out
+message processing.</p>
</body>
</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]