You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2006/10/05 11:56:40 UTC

svn commit: r453167 [4/6] - in /webservices/axis2/trunk/java/xdocs: ./ adb/ adb/images/ images/ images/archi-guide/ images/userguide/ jibx/ resources/ resources/schemas/

Added: webservices/axis2/trunk/java/xdocs/mail-transport.html
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/xdocs/mail-transport.html?view=auto&rev=453167
==============================================================================
--- webservices/axis2/trunk/java/xdocs/mail-transport.html (added)
+++ webservices/axis2/trunk/java/xdocs/mail-transport.html Thu Oct  5 02:56:34 2006
@@ -0,0 +1,212 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <meta http-equiv="content-type" content="">
+  <title>Invoking a service using a mail</title>
+</head>
+
+<body>
+<h1>Invoking a Service Using a Mail Transport</h1>
+
+<p>This document basically explains how to invoke a service through Mail
+transports. Content for this document has been listed as follows,</p>
+
+<p><i>Send your feedback or questions to: <a
+href="mailto:axis-dev@ws.apache.org">axis-dev@ws.apache.org</a></i>. Prefix
+subject with [Axis2]. To subscribe to mailing list see <a
+href="http://ws.apache.org/axis2/mail-lists.html">here.</a></p>
+
+<h2>Content</h2>
+<ul>
+  <li><a href="#prologue">Prologue</a></li>
+  <li><a href="#intro">Introduction</a></li>
+  <li><a href="#axis2">Using Simple Mail Server Included in Axis2</a></li>
+  <li><a href="#generic">Using a Generic Mail Server</a></li>
+  <!--li><a href="#mailet">Calling Axis Through a James Mailet</a></li-->
+</ul>
+<a name="prologue"></a>
+
+<h2>Prologue</h2>
+
+<p>Most of Web services that we interact with are synchronous and
+request-response in nature. However, we see that the synchronous
+request-response type of interaction is only a part of the messaging
+scenarios we encounter in real life. Asynchronous messaging is very important
+in constructing loosely coupled systems. Take for instance a chain of stores,
+at the end of the day all the stores all over can send a mail to the central
+system telling it what that days business activity was and in the morning
+when the store opens there will be a reply to that mail with new instructions
+and updates. It is a lot like the way the old business worked but with a
+modern touch. Similarly Axis2 mail transport can be used to implement
+asynchronous messaging through mail.</p>
+<a name="intro"></a>
+
+<h2>Introduction</h2>
+
+<p>To start you will first need to go through the <a
+href="mail-configuration.html" target="_blank">Mail Transport
+Configuration</a> document. It will provide the user with the first hand experience in setting up the mail transports to co-exists with Axis2.</p>
+
+<p>Broadly speaking there are 3 ways of calling a service through mail.</p>
+
+<blockquote>
+  1. Using the simple mail server included in Axis2.(not recommended in production)<br>
+  2. Using a generic mail server.<br>
+  3. Using mailets.<br>
+</blockquote>
+
+<p></p>
+
+<p>Option number 1 and 2 are fairly simple and easy to implement, whereas
+option 3 is somewhat harder.The mailet scenario however does provide a more
+robust and useful solution in a production environment.</p>
+
+<p>It is very easy to start learning the workings of mail transports with the aid of Simple Mail Server that provides with Axis2. Once you get the hang of the Axis2 related issues then you can move on to tackle the mail beast. Please do note that the Simple Mail Server that provides with Axis2 is not graded for production use.</p>
+<a name="axis2"></a>
+
+<h2>1. Using Simple Mail Server Included in Axis2</h2>
+
+<p>The SMTP/POP server that we have included has the ability to function as a
+standalone SMTP/POP server and also has the ability to work as a mailet. All
+this is done through a small filter that keeps watch for certain
+pre-configured email addresses. These pre-configured email addresses can be
+changed by doing a simple edit of the filter class
+org.apache.axis2.transport.mail.server.Sorter.</p>
+
+<p>Now that we have the environment set up, let us start pumping out some
+code to get the mail functionality off the ground. First we'll have a look at
+it from the mail server side. <br>
+</p>
+<source><pre>        // Start the mail server using the default configurations.
+        ConfigurationContext configContext = UtilsMailServer.start();
+
+        // Start the default mail listener. It will starting poling for mail
+        // using the configuration from the XML file.
+        SimpleMailListener ml = new SimpleMailListener();
+        ml.init(configContext,
+                configContext.getAxisConfiguration().getTransportIn(
+                        new QName(Constants.TRANSPORT_MAIL)));
+        ml.start();
+
+        private QName serviceName = new QName("EchoXMLService");
+        private QName operationName = new QName("echoOMElement");
+    
+        // Setup a service that will echo what we send to the server.
+        AxisService service = Utils.createSimpleService(serviceName, Echo.class
+                .getName(), operationName);
+        serverConfigContext.getAxisConfiguration().addService(service);</pre>
+</source>
+<p>This code sets up your Axis2 server working through mail, with a single
+service. If you need to have a look under the hood check out the MailServer
+and UtilsMailServer classes.</p>
+
+<p>Moving onto the client side have a look at the code listing below. It will
+call the axisService that was setup on the previous code listing.</p>
+<source><pre>        ConfigurationContext configContext = UtilsMailServer
+                .createClientConfigurationContext();
+        AxisService service = new AxisService(serviceName.getLocalPart());
+        AxisOperation axisOperation = new OutInAxisOperation();
+        axisOperation.setName(operationName);
+        axisOperation.setMessageReceiver(new MessageReceiver() {
+            public void receive(MessageContext messageCtx) {
+                envelope = messageCtx.getEnvelope();
+            }
+        });
+        service.addOperation(axisOperation);
+        configContext.getAxisConfiguration().addService(service);
+        ServiceContext serviceContext = new ServiceGroupContext(configContext,
+        		(AxisServiceGroup) service.getParent()).getServiceContext(service);
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setAction(operationName.getLocalPart());
+        options.setTransportInProtocol(Constants.TRANSPORT_MAIL);
+        options.setUseSeparateListener(true);
+
+        Callback callback = new Callback() {
+            public void onComplete(AsyncResult result) {
+                try {
+                    result.getResponseEnvelope().serializeAndConsume(
+                            XMLOutputFactory.newInstance()
+                                    .createXMLStreamWriter(System.out));
+                } catch (XMLStreamException e) {
+                    onError(e);
+                } finally {
+                    finish = true;
+                }
+            }
+
+            public void onError(Exception e) {
+                log.info(e.getMessage());
+                finish = true;
+            }
+        };
+
+        ServiceClient sender = new ServiceClient(configContext, service);
+        sender.setOptions(options);
+        //options.setTo(targetEPR);
+        sender.sendReceiveNonBlocking(operationName, createEnvelope(), callback);
+
+        int index = 0;
+        while (!finish) {
+            Thread.sleep(1000);
+            index++;
+            if (index > 10) {
+                throw new AxisFault(
+                        "Server was shutdown as the async response is taking too long to complete.");
+            }
+        }
+
+    }</pre>
+</source>
+<p>This will call the service that was setup on the server and will poll the
+mail server till the response is received.Please do note that serviceName and operationName need to be QNames.</p>
+
+<a name="generic"></a>
+
+<h2>2. Using a Generic Mail Server</h2>
+
+<p>First you need two email accounts that works with POP/SMTP. One will act
+as a server and the other will act as the client. For the time being we will
+use server@somewhere.org and client@somewhere.org as the server and the
+client email addresses. Now that we have the email addresses you will have to
+set up the client and the server with Mail Transport <a
+href="mail-configuration.html"
+target="_blank">configuration document</a>.</p>
+
+<p>When calling the generic mail server the client side code will remain the
+same and there will be some modification to the server-side code.</p>
+
+<p></p>
+<source><pre>        // Create a configuration context. This will also load the details about the mail
+        // address to listen to from the configuration file.
+        File file = new File(MAIL_TRANSPORT_SERVER_ENABLED_REPO_PATH);
+        ConfigurationContextFactory builder = new ConfigurationContextFactory();
+        ConfigurationContext configContext = configContextbuilder
+                .buildConfigurationContext(file.getAbsolutePath());
+
+        // Start the default mail listener. It will starting poling for mail
+        // using the configuration from the XML file.
+        SimpleMailListener ml = new SimpleMailListener();
+        ml.init(configContext,
+                configContext.getAxisConfiguration().getTransportIn(
+                        new QName(Constants.TRANSPORT_MAIL)));
+        ml.start();
+
+        private QName serviceName = new QName("EchoXMLService");
+        private QName operationName = new QName("echoOMElement");
+    
+        // Setup a service that will echo what we send to the server.
+        AxisService service = Utils.createSimpleService(serviceName, Echo.class
+                .getName(), operationName);
+        serverConfigContext.getAxisConfiguration().addService(service);</pre>
+</source>
+<p>Note that a separate ConfigurationContext needs to be created and used.</p>
+<!--a name="mailet"></a>
+
+<h3>3. Calling Axis2 Through a Mailet</h3-->
+
+
+<p></p>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/migration.html
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/xdocs/migration.html?view=auto&rev=453167
==============================================================================
--- webservices/axis2/trunk/java/xdocs/migration.html (added)
+++ webservices/axis2/trunk/java/xdocs/migration.html Thu Oct  5 02:56:34 2006
@@ -0,0 +1,677 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta content="">
+  <meta http-equiv="content-type" content="">
+  <title>Migrating from Axis 1.x</title>
+</head>
+
+<body lang="en">
+<h1>Migrating from Apache Axis 1.x to Axis 2</h1>
+
+<p>For all those users who are familiar with Axis2 1.x series will be
+assisted through this document to switch to Axis2 series. We begin by listing
+the improvements in Axis2 in comparison with Axis1. This is followed by
+guidelines for the migration.</p>
+
+<p><i>Send your feedback or questions to: <a
+href="mailto:axis-dev@ws.apache.org">axis-dev@ws.apache.org</a></i>. Prefix
+subject with [Axis2]. To subscribe to the mailing list see <a
+href="http://ws.apache.org/axis2/mail-lists.html">here.</a></p>
+
+<h2>Content</h2>
+<ul>
+  <li><a href="#comp">Compatibility</a></li>
+  <li><a href="#start">Getting Started</a></li>
+  <li><a href="#custom_deployment">Custom Deployment of Services, Handlers
+    and Modules</a></li>
+  <li><a href="#transports">Transports for HTTP Connection</a></li>
+  <li><a href="#data_binding">Data Binding Support</a></li>
+  <li><a href="#best">Best Usage</a></li>
+</ul>
+<a name="comp"></a>
+
+<h2>Compatibility</h2>
+
+<p>Axis1.x and Axis2 have been evolved from different architectures.</p>
+
+<p><strong>Speed</strong> - Axis2 is based on StAX API, which gives greater
+speed than SAX event based parsing that has been used in Axis1.x.</p>
+
+<p><strong>Stability</strong> - Axis2 has fixed phases and for extensions an
+area of user defined phases. This allows far more stability and flexibility
+than Axis1.x.</p>
+
+<p><strong>Transport framework</strong> - Simple abstraction in the designing
+of transports (i.e., senders and listeners for SOAP over various protocols
+such as SMTP, etc), allows far more flexibility and the core of the engine is
+completely transport-independent.</p>
+
+<p><strong>WSDL support</strong> - Axis2 supports version 1.1 and 2.0, which
+allows creating stubs and skeletons, to manipulate the web services arena.</p>
+
+<p><strong>Component - oriented architecture</strong> - This is merely
+through archives (.mar and .aar) . Easily reusable components such as
+handlers, modules allow patterns processing for your applications, or to
+distribution to partners. Axis2 is more concerned on the "Module" concept
+rather the "Handler" concept. Modules contain handlers that have been ordered
+through the phase rules. These are ordered to specific service(s).</p>
+<a name="start"></a>
+
+<h2>Getting Started</h2>
+
+<p>Lets look at a simple example of echoing at client API.</p>
+
+<p><b>Axis 1.x</b></p>
+<pre>import ...
+public class TestClient {
+        public static void main(String [] args) {
+                try {
+                        String endpoint = ... ;
+                        Service axisService = new Service();
+                        Call call = (Call) axisService.createCall();
+                        call.setTargetEndpointAddress( new java.net.URL(endpoint) );
+                        call.setOperationName(new QName("http://soapinterop.org/", echoString"));
+                        String ret = (String) call.invoke( new Object[] { "Hello!" } );
+                        System.out.println("Sent 'Hello!', got '" + ret + "'");
+                } catch (Exception e) {
+                        System.err.println(e.toString());
+                }
+        }
+}</pre>
+
+<p><b>Axis 2</b></p>
+<pre>import ...
+public class EchoBlockingClient {
+        private static EndpointReference targetEPR = new EndpointReference(
+        AddressingConstants.WSA_TO,
+                                "http://127.0.0.1:8080/axis2/services/MyService");
+        public static void main(String[] args) {
+                try {
+                        OMElement payload = ClientUtil.getEchoOMElement();
+                        Options options = new Options();
+                        ServiceClient client = new ServiceClient();
+                        options.setTo(targetEPR);
+                        //Blocking invocation
+                        OMElement result = client.sendReceive(payload);
+                        ...
+                } catch (AxisFault axisFault) {
+                        axisFault.printStackTrace();
+                } catch (XMLStreamException e) {
+                        e.printStackTrace();
+                }
+        }
+}</pre>
+
+<p>It has been clearly depicted that the invocation in Axis2 is dealt with
+SOAP body element itself. Here the invocation is synchronous but Axis2 can
+handle asynchronous invocations as well. The "payload" variable above
+contains the SOAP body element which should go in the soap envelope.</p>
+
+<p>Once the service is called through the stub in Axis2, "payload" is
+according to the data binding framework that will be used. So the extra work
+of "payload" will be vanished.</p>
+
+<p>Apart from synchronous invocation, Axis2 supports asynchronous invocation
+through sendReceiveNonblocking(). Synchronous/Asynchronous invocations can
+handle both single/double HTTP connections.</p>
+
+<p>With this advanced architecture, Axis2 is capable of handling megabytes of
+requests and responses, which is far from what Axis1.x was capable of.</p>
+<a name="custom_deployment"></a>
+
+<h2>Custom Deployment of Services, Handlers and Modules</h2>
+
+<p>In Axis 1.x, the deployment of services was via WSDD, which in my opinion
+was highly cumbersome. Service deployment in Axis2 is straight forward and
+dynamic. Dynamic behavior is from the "Administrator" facility given by the
+development in the server side. It's just a matter of creating the .aar file,
+and deploying it. More details regarding this is given in the Axis2 user
+guide.</p>
+
+<p>Axis2 is far from the "Handler concept" and is more into the "Module
+concept". Abstractly speaking, the module concept is a collection of handlers
+with rules of governing which modules are created as .mar files. It has
+module.xml, which is the brain behind manipulating the handlers.</p>
+
+<p>When a service is called through a handler, it is just a matter of giving
+a reference to the module that includes the handler in the services.xml
+(using &lt;module ref="foo/&gt;").</p>
+
+<p>Services are hot deployable in Axis2, but modules are not. This is one
+feature which is unique to Axis2.</p>
+
+<p>Lets take a detailed look at what it takes to migrate the Axis 1.x
+handlers to the Axis 2 modules via the "SOAP Monitor". The SOAP monitor is
+really a combination of three components: An applet which displays responses
+/ requests, a servlet which binds to a default port of 5001 and connects to
+the applet, and a handler chain used to intercept the soap messages. Here
+we'll focus on the handler.</p>
+
+<p><b>Axis 1.x required two WSDD's to use the SOAP Monitor. First, the SOAP
+Monitor Handler itself:</b></p>
+<pre>&lt;deployment xmlns="http://xml.apache.org/axis/wsdd/"
+    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"&gt;
+    
+  &lt;handler name="soapmonitor" 
+      type="java:org.apache.axis.handlers.SOAPMonitorHandler"&gt;
+    &lt;parameter name="wsdlURL" 
+      value="/wzs/SOAPMonitorService-impl.wsdl"/&gt;
+    &lt;parameter name="namespace" 
+      value="http://tempuri.org/wsdl/2001/12/SOAPMonitorService-impl.wsdl"/&gt;
+    &lt;parameter name="serviceName" value="SOAPMonitorService"/&gt;
+    &lt;parameter name="portName" value="Demo"/&gt;
+  &lt;/handler&gt;
+
+  &lt;service name="SOAPMonitorService" provider="java:RPC"&gt;
+    &lt;parameter name="allowedMethods" value="publishMessage"/&gt;
+    &lt;parameter name="className" 
+      value="org.apache.axis.monitor.SOAPMonitorService"/&gt;
+    &lt;parameter name="scope" value="Application"/&gt;
+  &lt;/service&gt;
+&lt;/deployment&gt;</pre>
+
+<p><b>Axis 1.x requires a reference to the handler in the user's WSDD that
+defines their Web Service:</b></p>
+<pre>&lt;deployment name="example" xmlns="http://xml.apache.org/axis/wsdd/" 
+    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"&gt;
+  
+  &lt;service name="urn:myService" provider="java:RPC"&gt;
+    &lt;parameter name="className" value="org.MyService"/&gt;
+    &lt;parameter name="allowedMethods" value="*"/&gt;
+
+    &lt;requestFlow&gt;
+      &lt;handler type="soapmonitor"/&gt;
+    &lt;/requestFlow&gt;
+    &lt;responseFlow&gt;
+      &lt;handler type="soapmonitor"/&gt;
+    &lt;/responseFlow&gt;
+
+  &lt;/service&gt;
+&lt;/deployment&gt;</pre>
+
+<p><b>Axis 2 requires a module.xml, placed inside a jar with a .mar extension
+under WEB-INF/modules, to define a Handler:</b></p>
+<pre>&lt;module name="soapmonitor" class="org.apache.axis2.handlers.soapmonitor.SOAPMonitorModule"&gt;
+    &lt;inflow&gt;
+        &lt;handler name="InFlowSOAPMonitorHandler" class="org.apache.axis2.handlers.soapmonitor.SOAPMonitorHandler"&gt;
+            &lt;order phase="soapmonitorPhase"/&gt;
+        &lt;/handler&gt;
+    &lt;/inflow&gt;
+
+    &lt;outflow&gt;
+        &lt;handler name="OutFlowSOAPMonitorHandler" class="org.apache.axis2.handlers.soapmonitor.SOAPMonitorHandler"&gt;
+            &lt;order phase="soapmonitorPhase"/&gt;
+        &lt;/handler&gt;
+    &lt;/outflow&gt;
+
+    &lt;Outfaultflow&gt;
+        &lt;handler name="FaultOutFlowSOAPMonitorHandler" class="org.apache.axis2.handlers.soapmonitor.SOAPMonitorHandler"&gt;
+            &lt;order phase="soapmonitorPhase"/&gt;
+        &lt;/handler&gt;
+    &lt;/Outfaultflow&gt;
+
+    &lt;INfaultflow&gt;
+        &lt;handler name="FaultInFlowSOAPMonitorHandler" class="org.apache.axis2.handlers.soapmonitor.SOAPMonitorHandler"&gt;
+            &lt;order phase="soapmonitorPhase"/&gt;
+        &lt;/handler&gt;
+    &lt;/INfaultflow&gt;
+&lt;/module&gt;</pre>
+
+<p>The SOAPMonitorModule referenced above simply implements
+org.apache.axis2.modules.Module and is used for any additional tasks needed
+to initialize the module and shutdown the module. In this case nothing is
+needed and the implemented interface methods have blank bodies. Furthermore,
+the 'soapmonitorPhase' will be used later below in the axis2.xml .</p>
+
+<p><b>Axis 1.x the SOAPMonitorHandler has the class signature as:</b></p>
+<pre>public class SOAPMonitorHandler extends BasicHandler</pre>
+
+<p><b>Axis 2 the SOAPMonitorHandler has the class signature as:</b></p>
+<pre>public class SOAPMonitorHandler extends AbstractHandler </pre>
+
+<p><b>In axis2, you need to reference the module that contains the handler
+chain that you want to use inside your services.xml:</b></p>
+<pre>&lt;service name="ExampleService"&gt;
+    &lt;module ref="soapmonitor"/&gt;
+    &lt;description&gt;
+       This service has the SOAP Monitor wired in 
+    &lt;/description&gt;
+    &lt;parameter name="ServiceClass" locked="false"&gt;org.ExampleService&lt;/parameter&gt;
+    &lt;operation name="myExecute"&gt;
+        &lt;messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
+    &lt;/operation&gt;
+&lt;/service&gt;</pre>
+
+<p><b>Finally, axis2 requires you to make some changes to axis2.xml. Start by
+adding a global module:</b></p>
+<pre>    &lt;module ref="soapmonitor"/&gt;</pre>
+
+<p><b>Then define your phase orders for 'soapmonitorPhase' referenced in the
+module.xml :</b></p>
+<pre>    &lt;phaseOrder type="inflow"&gt;
+        &lt;!--  Global Phases       --&gt;
+        &lt;phase name="TransportIn"/&gt;
+        &lt;phase name="PreDispatch"/&gt;
+        &lt;phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"&gt;
+            &lt;handler name="AddressingBasedDispatcher"
+                     class="org.apache.axis2.engine.AddressingBasedDispatcher"&gt;
+                &lt;order phase="Dispatch"/&gt;
+            &lt;/handler&gt;
+
+            &lt;handler name="RequestURIBasedDispatcher"
+                     class="org.apache.axis2.engine.RequestURIBasedDispatcher"&gt;
+                &lt;order phase="Dispatch"/&gt;
+            &lt;/handler&gt;
+
+            &lt;handler name="SOAPActionBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPActionBasedDispatcher"&gt;
+                &lt;order phase="Dispatch"/&gt;
+            &lt;/handler&gt;
+
+            &lt;handler name="SOAPMessageBodyBasedDispatcher"
+                     class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher"&gt;
+                &lt;order phase="Dispatch"/&gt;
+            &lt;/handler&gt;
+            &lt;handler name="InstanceDispatcher"
+                     class="org.apache.axis2.engine.InstanceDispatcher"&gt;
+                &lt;order phase="Dispatch"/&gt;
+            &lt;/handler&gt;
+        &lt;/phase&gt;
+        &lt;!--    Global Phases     --&gt;
+        &lt;!--   After Dispatch phase module author or service author can add any phase he wants      --&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+    &lt;/phaseOrder&gt;
+    &lt;phaseOrder type="outflow"&gt;
+        &lt;!--   user can add his own phases to this area  --&gt;
+        &lt;!--   Global phases   --&gt;
+        &lt;!--   these phases will run irrespective of the service   --&gt;
+        &lt;phase name="MessageOut"/&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+        &lt;phase name="PolicyDetermination"/&gt;
+        &lt;!--   Global phases   --&gt;
+    &lt;/phaseOrder&gt;
+    &lt;phaseOrder type="INfaultflow"&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+        &lt;!--   user can add his own phases to this area  --&gt;
+    &lt;/phaseOrder&gt;
+    &lt;phaseOrder type="Outfaultflow"&gt;
+        &lt;!--   user can add his own phases to this area  --&gt;
+        &lt;!--   Global phases   --&gt;
+        &lt;phase name="MessageOut"/&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+        &lt;phase name="PolicyDetermination"/&gt;
+        &lt;!--   Global phases   --&gt;
+    &lt;/phaseOrder&gt;</pre>
+
+<p>See the user guide for more info on axis2 modules.</p>
+<a name="transports"></a>
+
+<h2>Transports for HTTP Connection</h2>
+
+<p>Axis2 comes with two  CommonsHTTPTransportSender which is based on
+commons-httpclient.</p>
+
+<p>It should be noted that axis2.xml should be configured to call the commons
+transports, with the statement,</p>
+<pre>...
+&lt;transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"&gt; 
+   &lt;parameter name="PROTOCOL" locked="false"&gt;HTTP/1.1&lt;/parameter&gt; 
+   &lt;parameter name="Transfer-Encoding" locked="false"&gt;chunked&lt;/parameter&gt;
+&lt;/transportSender&gt;
+...</pre>
+<a name="data_binding"></a>
+
+<h2>Data Binding Support</h2>
+
+<p>ADB is used to provide data binding support. In Axis2, xml is manipulated
+via AXIOM, which is based on the StAX API. XML gives full schema support.
+Thus, serialization and de-serialization of XML is handled in Axis2 via the
+xml-data binding framework.</p>
+
+<p>Below is an example of migrating an WSDL based Axis 1.x Web Service to
+Axis2.</p>
+
+<p>First, lets take a look at a simple document / literal style WSDL used in
+an Axis 1.x Web Service. This example assumes the name simple.wsdl for the
+wsdl below:</p>
+<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+
+&lt;definitions name="SimpleService" targetNamespace="http://simpleNS" xmlns:tns="http://simpleNS" 
+xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://simpleNS/types"&gt;
+  &lt;types&gt;
+    &lt;schema targetNamespace="http://simpleNS/types" xmlns:tns="http://simpleNS/types" 
+xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" 
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+xmlns="http://www.w3.org/2001/XMLSchema"&gt;
+      &lt;import namespace="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
+      &lt;element name="simpleLogin"&gt;
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+            &lt;element name="user_name" type="xsd:string"/&gt;
+            &lt;element name="user_password" type="xsd:string"/&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+      &lt;element name="simpleLoginResponse"&gt;
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+            &lt;element name="soap_session_id" type="xsd:string"/&gt;
+            &lt;element name="web_user_name" type="xsd:string"/&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+&lt;/schema&gt;&lt;/types&gt;
+  &lt;message name="SimpleEndpoint_simpleLogin"&gt;
+     &lt;part name="parameters" element="ns2:simpleLogin"/&gt;
+  &lt;/message&gt;
+  &lt;message name="SimpleEndpoint_simpleLoginResponse"&gt;
+    &lt;part name="result" element="ns2:simpleLoginResponse"/&gt;
+  &lt;/message&gt;
+  &lt;portType name="SimpleEndpoint"&gt;
+    &lt;operation name="simpleLogin"&gt;
+      &lt;input message="tns:SimpleEndpoint_simpleLogin" name="SimpleEndpoint_simpleLogin"/&gt;
+      &lt;output message="tns:SimpleEndpoint_simpleLoginResponse" name="SimpleEndpoint_simpleLoginResponse"/&gt;
+    &lt;/operation&gt;
+  &lt;/portType&gt;
+  &lt;binding name="SimpleEndpointBinding" type="tns:SimpleEndpoint"&gt;
+    &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
+    &lt;operation name="simpleLogin"&gt;
+      &lt;soap:operation soapAction="simpleLogin"/&gt;
+      &lt;input name="SimpleEndpoint_simpleLogin"&gt;
+        &lt;soap:body use="literal"/&gt;
+      &lt;/input&gt;
+      &lt;output name="SimpleEndpoint_simpleLoginResponse"&gt;
+        &lt;soap:body use="literal"/&gt;
+      &lt;/output&gt;
+    &lt;/operation&gt;
+  &lt;/binding&gt;
+  &lt;service name="SimpleService"&gt;
+    &lt;port name="SimpleEndpointPort" binding="tns:SimpleEndpointBinding"&gt;
+      &lt;soap:address location="http://localhost:8080/axis/services/SimpleEndpointPort"/&gt;&lt;/port&gt;&lt;/service&gt;&lt;/definitions&gt;</pre>
+
+<p>The next step is to run WSDL2Java on the wsdl. For axis 1.x, this example
+uses the following ant task:</p>
+<pre>&lt;target name="wsdl2java" description="axis 1.x"&gt;
+       &lt;delete dir="output" /&gt;
+       &lt;mkdir dir="output" /&gt;
+       &lt;axis-wsdl2java
+         output="output"
+         verbose="true"
+         url="wsdl/simple.wsdl"
+         serverside="true"
+         skeletondeploy="true"
+         nowrapped="true"&gt;
+       &lt;/axis-wsdl2java&gt;
+   &lt;/target&gt;</pre>
+
+<p>The axis 1.x ant task above takes the simple.wsdl under the directory
+'wsdl' , and from that creates files under the directory 'output'. The files
+created are shown below:</p>
+<pre>output/
+output/simpleNS
+output/simpleNS/types
+output/simpleNS/types/SimpleLoginResponse.java
+output/simpleNS/types/SimpleLogin.java
+output/simpleNS/SimpleEndpoint.java
+output/simpleNS/SimpleEndpointBindingStub.java
+output/simpleNS/SimpleEndpointBindingSkeleton.java
+output/simpleNS/SimpleEndpointBindingImpl.java
+output/simpleNS/SimpleService.java
+output/simpleNS/SimpleServiceLocator.java
+output/simpleNS/deploy.wsdd
+output/simpleNS/undeploy.wsdd</pre>
+
+<p>Now lets run WSDL2Java with Axis2. In this example, the only change to
+simple.wsdl required for axis2 is that 'soap:address location' be changed
+to:</p>
+<pre>&lt;soap:address location="http://localhost:8080/axis2/services/SimpleEndpoint"/&gt;&lt;/port&gt;&lt;/service&gt;&lt;/definitions&gt;</pre>
+
+<p>In Axis2 the default databinding uses ADB. However, xmlbeans and jaxme are
+also supported. This example uses xmlbeans. For Axis2, our example uses the
+following ant task:</p>
+<pre>&lt;target name="wsdl2java"&gt;
+      &lt;delete dir="output" /&gt;
+      &lt;java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"&gt;
+          &lt;classpath refid="axis.classpath"/&gt; 
+          &lt;arg value="-d"/&gt;
+          &lt;arg value="xmlbeans"/&gt;
+          &lt;arg value="-uri"/&gt;
+          &lt;arg file="wsdl/simple.wsdl"/&gt;
+          &lt;arg value="-ss"/&gt;
+          &lt;arg value="-g"/&gt;
+          &lt;arg value="-sd"/&gt;
+          &lt;arg value="-o"/&gt;
+          &lt;arg file="output"/&gt;
+          &lt;arg value="-p"/&gt;
+          &lt;arg value="org.simple.endpoint"/&gt;
+      &lt;/java&gt;
+
+      &lt;!-- Move the schema folder to classpath--&gt;
+      &lt;move todir="${build.classes}"&gt;
+          &lt;fileset dir="output/resources"&gt;
+              &lt;include name="*schema*/**/*.class"/&gt;
+              &lt;include name="*schema*/**/*.xsb"/&gt;
+          &lt;/fileset&gt;
+      &lt;/move&gt;
+
+  &lt;/target&gt;</pre>
+
+<p>For an explanation of the Axis2 WSDL2Java ant task and its options, see
+the <a href="../tools/1_1/CodegenToolReference.html">CodegenToolReference
+Guide.</a></p>
+
+<p>A feature of xmlbeans is that there is one class file created with
+WSDL2java, and a series of xsb files. These must be referenced when
+compiling, and as the example shows these files are moved to a build
+directory.</p>
+
+<p>The Axis2 WSDL2Java example also takes the simple.wsdl which is under the
+directory 'wsdl' and from that creates files under the directory 'output'.
+The relevant non-xmlbean files created are shown below:</p>
+<pre>output/resources/services.xml
+output/src/org/simple
+output/src/org/simple/endpoint
+output/src/org/simple/endpoint/SimpleEndpointSkeleton.java
+output/src/org/simple/endpoint/SimpleEndpointMessageReceiverInOut.java
+output/src/org/simple/endpoint/SimpleEndpointCallbackHandler.java
+output/src/org/simple/endpoint/SimpleEndpointStub.java
+output/src/simplens
+output/src/simplens/types
+output/src/simplens/types/SimpleLoginDocument.java
+output/src/simplens/types/impl
+output/src/simplens/types/impl/SimpleLoginDocumentImpl.java
+output/src/simplens/types/impl/SimpleLoginResponseDocumentImpl.java
+output/src/simplens/types/SimpleLoginResponseDocument.java</pre>
+
+<p>The first important distinction is that while the Axis 1.x example
+generated deploy.wsdd and undeploy.wsdd, the Axis2 example created a
+services.xml. The files deploy.wsdd and services.xml are a breed apart,
+coming from different architectures. There is no direct parallel between
+them. See the Axis2 user guide for an explanation about services.xml</p>
+
+<p>Now we're ready to code. We'll start with Axis 1.x on the service side. To
+implement the business logic we'll change
+simpleNS/SimpleEndpointBindingImpl.java from:</p>
+<pre class="code">package simpleNS;
+
+public class SimpleEndpointBindingImpl implements simpleNS.SimpleEndpoint{
+    public simpleNS.types.SimpleLoginResponse simpleLogin(simpleNS.types.SimpleLogin parameters) 
+        throws java.rmi.RemoteException {
+        return null;
+    }
+
+}</pre>
+
+<p>To:</p>
+<pre class="code">package simpleNS;
+
+public class SimpleEndpointBindingImpl implements simpleNS.SimpleEndpoint{
+    public simpleNS.types.SimpleLoginResponse simpleLogin(simpleNS.types.SimpleLogin parameters) 
+        throws java.rmi.RemoteException {
+
+        String userName = parameters.getUser_name();
+        String password = parameters.getUser_password();
+        // do something with those vars...
+        return new simpleNS.types.SimpleLoginResponse("mySessionID", "username");
+    }
+
+}</pre>
+
+<p>In Axis 1.x, the next step is to compile the classes and put them in the
+Axis.war, and then run the admin client with the generated deploy.wsdd.
+You'll then look at the happy axis page to verify the service is installed
+correctly.</p>
+
+<p>Now lets code Axis2. In Axis 1.x, while the ant task shown in the example
+created a skeleton, a peek inside shows that the skeleton calls the binding
+implementation class. In Axis2 we work with the skeleton directly. To
+implement the business logic in the Axis2 generated classes we'll change
+org/simple/endpoint/SimpleEndpointSkeleton.java from:</p>
+<pre class="code">package org.simple.endpoint;
+    /**
+     *  SimpleEndpointSkeleton java skeleton for the axisService
+     */
+    public class SimpleEndpointSkeleton {
+
+        /**
+         * Auto generated method signature
+          * @param param0
+         */
+        public  simplens.types.SimpleLoginResponseDocument simpleLogin
+                  (simplens.types.SimpleLoginDocument param0 ) throws Exception {
+                //Todo fill this with the necessary business logic
+                throw new  java.lang.UnsupportedOperationException();
+        }
+}</pre>
+
+<p>To:</p>
+<pre class="code">package org.simple.endpoint;
+    
+    import simplens.types.*;
+    import simplens.types.SimpleLoginResponseDocument.*;
+    import simplens.types.SimpleLoginDocument.*;
+    /**
+     *  SimpleEndpointSkeleton java skeleton for the axisService
+     */
+    public class SimpleEndpointSkeleton {
+     
+        /**
+         * Modified 
+          * @param simpleLoginDocument
+         */
+        public SimpleLoginResponseDocument simpleLogin
+                  (simplens.types.SimpleLoginDocument simpleLoginDocument){
+                //Todo fill this with the necessary business logic
+
+                SimpleLoginResponseDocument retDoc =
+                    SimpleLoginResponseDocument.Factory.newInstance();
+                 
+                SimpleLoginResponse retElement =
+                    SimpleLoginResponse.Factory.newInstance();
+                // Get parameters passed in 
+                SimpleLogin simpleLogin = simpleLoginDocument.getSimpleLogin();
+                String userName = simpleLogin.getUserName();
+                String password = simpleLogin.getUserPassword();
+                // do something with those variables...
+
+                retElement.setWebUserName(userName);
+                retElement.setSoapSessionId("my random string");
+                retDoc.setSimpleLoginResponse(retElement);
+                return retDoc; 
+        }
+}</pre>
+
+<p>In Axis2, the next step is to compile the classes, put them along with the
+generated services.xml in an AAR, and then hot deploy the AAR by placing it
+in the Axis2.war under WEB-INF/services . Point a browser to
+http://localhost:8080/axis2/listServices , and you should see the service
+'SimpleService' ready for action. See the Axis2 user guide for more info.</p>
+
+<p>The last step is the client. Our Axis 1.x client for this example is:</p>
+<pre>package org;
+
+import simpleNS.*;
+import simpleNS.types.*;
+
+public class Tester {
+  public static void main(String [] args) throws Exception {
+    // Make a service
+    SimpleService service = new SimpleServiceLocator();
+
+    // Now use the service to get a stub which implements the SDI.
+    SimpleEndpoint port =  service.getSimpleEndpointPort();
+
+    // set the params
+    SimpleLogin parameters = new SimpleLogin("username","password");
+    // Make the actual call
+    SimpleLoginResponse simpleLoginResponse = port.simpleLogin(parameters);
+    String session = simpleLoginResponse.getSoap_session_id();
+    String user = simpleLoginResponse.getWeb_user_name();
+    System.out.println("simpleLoginResponse, session: " + session + ", user: " + user);
+  }
+}</pre>
+
+<p>Finally, our Axis2 client for this example is:</p>
+<pre>package org;
+import simplens.types.*;
+import simplens.types.SimpleLoginDocument.*;
+import simplens.types.SimpleLoginResponseDocument.*;
+import simplens.types.impl.*;
+import org.simple.endpoint.*;
+
+public class Tester {
+  public static void main(String [] args) throws Exception {
+
+    // you may not need to pass in the url to the constructor - try the default no arg one
+    SimpleEndpointStub stub =
+         new SimpleEndpointStub(null, "http://localhost:8080/axis2/services/SimpleService");
+
+    SimpleLogin simpleLogin = SimpleLogin.Factory.newInstance();
+    simpleLogin.setUserName("userName");
+    simpleLogin.setUserPassword("password");
+
+    SimpleLoginDocument simpleLoginDocument =
+        SimpleLoginDocument.Factory.newInstance();
+
+    simpleLoginDocument.setSimpleLogin(simpleLogin);
+
+    SimpleLoginResponseDocument simpleLoginResponseDocument
+        = stub.simpleLogin(simpleLoginDocument);
+
+    SimpleLoginResponse simpleLoginResponse =
+        simpleLoginResponseDocument.getSimpleLoginResponse();
+
+    String session = simpleLoginResponse.getSoapSessionId();
+    String user = simpleLoginResponse.getWebUserName();
+    System.out.println("simpleLoginResponse, session: " + session + ", user: " + user);
+
+  }
+}</pre>
+
+<p>Axis2 clients also have asynchronous options via a Callback and
+alternatively 'Fire and forget'. See the user guide for more details.</p>
+<a name="best"></a>
+
+<h2>Best Usage</h2>
+
+<p>Axis1.x and Axis2 have different ways of seeing the SOAP stack. So the
+best way to migrate is to follow the <a href="userguide.html">User's Guide</a> and the <a href="Axis2ArchitectureGuide.html">Architecture Guide</a> of
+Axis2 properly. Axis2 is very much straight forward and friendly to use than
+it's predecessor.</p>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/mtom-guide.html
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/xdocs/mtom-guide.html?view=auto&rev=453167
==============================================================================
--- webservices/axis2/trunk/java/xdocs/mtom-guide.html (added)
+++ webservices/axis2/trunk/java/xdocs/mtom-guide.html Thu Oct  5 02:56:34 2006
@@ -0,0 +1,790 @@
+<html>
+<head>
+  <meta http-equiv="content-type" content="">
+  <title>Handling Binary data with Axis2 (MTOM/SwA)</title>
+</head>
+
+<body>
+<h1>Handling Binary data with Axis2 (MTOM/SwA)</h1>
+
+<p>This document will describe how to use Axis2 functionality to send/receive binary data
+with SOAP.</p>
+
+<h2>Content</h2>
+<ul>
+  <li><a href="#1">Introduction</a>
+    <ul>
+      <li><a href="#11">Where Does MTOM Come In?</a></li>
+    </ul>
+  </li>
+  <li><a href="#2">MTOM with Axis2 </a>
+    <ul>
+      <li><a href="#21">Programming Model</a></li>
+      <li><a href="#22">Enabling MTOM Optimization at Client Side</a></li>
+      <li><a href="#23">Enabling MTOM Optimization at Server Side</a></li>
+      <li><a href="#24">Accessing Received Binary Data (Sample Code) </a>
+        <ul>
+          <li><a href="#241">Service</a></li>
+          <li><a href="#242">Client</a></li>
+        </ul>
+      </li>
+      <li><a href="#25">MTOM Databinding</a>
+    </ul>
+  </li>
+  <li><a href="#3">SOAP with Attachments with Axis2</a></li>
+  	<ul>
+       <li><a href="#31">Sending SwA type attachments</a></li>
+       <li><a href="#32">Receiving SwA type attachments</a></li>
+	    <li><a href="#33">MTOM Backward Compatibility with SwA</a></li>
+   </ul>
+  <li><a href="#4">Advanced Topics </a>
+    <ul>
+      <li><a href="#41">File Caching for Attachments</a></li>
+    </ul>
+  </li>
+</ul>
+<a name="1"></a>
+
+<h2>Introduction</h2>
+
+<p>Despite the flexibility, interoperability and global acceptance of XML,
+there are times when serializing data into XML does not make sense. Web
+services users may need to transmit binary attachments of various sorts like
+images, drawings, xml docs, etc together with SOAP message. Such data are
+often in a particular binary format.<br>
+</p>
+
+<p>Traditionally, two techniques have been used in dealing with opaque data
+in XML;</p>
+<ol>
+  <li><strong>"By value"</strong></li>
+
+  <blockquote>
+    <p>Sending binary data by value is achieved by embedding opaque data (of
+    course after some form of encoding) as element or attribute content of
+    the XML component of data. The main advantage of this technique is that
+    it gives applications the ability to process and describe data based and
+    looking only on XML component of the data.</p>
+
+    <p>XML supports opaque data as content through the use of either base64
+    or hexadecimal text encoding. Both these techniques bloat the size of the
+    data. For UTF-8 underlying text encoding, base64 encoding increases the
+    size of the binary data by a factor of 1.33x of the original size, while
+    hexadecimal encoding expands data by a factor of 2x. Above factors will
+    be doubled if UTF-16 text encoding is used. Also of concern is the
+    overhead in processing costs (both real and perceived) for these formats,
+    especially when decoding back into raw binary.</p>
+  </blockquote>
+  <li><strong>"By reference"</strong>
+
+    <blockquote>
+      <p>Sending binary data by reference is achieved by attaching pure
+      binary data as external unparsed general entities outside of the XML
+      document and then embedding  reference URI's to those entities as
+      elements or attribute values. This prevents the unnecessary bloating of
+      data and wasting of processing power. The primary obstacle for using
+      these unparsed entities is their heavy reliance on DTDs, which impedes
+      modularity as well as use of XML namespaces.</p>
+      <p>There were several specifications introduced in the Web services
+      world to deal with this binary attachment problem using the "by
+      reference" technique. <a
+      href="http://www.w3.org/TR/SOAP-attachments">SOAP with Attachments</a>
+      is one such example. Since SOAP prohibits document type declarations
+      (DTD) in messages, this leads to the  problem of not  representing data
+      as part of the message infoset, creating two data models. This scenario
+      is like sending attachments with an e-mail message. Even though those
+      attachments are related to the message content they are not inside the
+      message.  This causes the technologies for processing and description
+      of data based on XML component of the data, to malfunction. One example
+      is  WS-Security.</p>
+    </blockquote>
+  </li>
+</ol>
+<a name="11"></a>
+
+<h3>Where Does MTOM Come In?</h3>
+
+<p><a href="http://www.w3.org/TR/2004/PR-soap12-mtom-20041116/">MTOM (SOAP
+Message Transmission Optimization Mechanism)</a> is another specification
+which focuses on solving the "Attachments" problem. MTOM tries to leverage
+the advantages of above two techniques by trying to merge the two techniques.
+MTOM is actually a "by reference" method. Wire format of a MTOM optimized
+message is same as the Soap with Attachments message, which also makes it
+backward compatible with SwA endpoints. The most notable feature of MTOM is
+the use of XOP:Include element, which is defined in <a
+href="http://www.w3.org/TR/2004/PR-xop10-20041116/">XML Binary Optimized
+Packaging (XOP)</a> specification to reference  the binary attachments
+(external unparsed general entities) of the message. With the use of this
+exclusive element the attached binary content logically become inline (by
+value) with the SOAP document even though actually it is attached separately.
+This merges the two realms by making it possible to work only with one data
+model. This allows the applications to process and describe by only looking
+at XML part making reliance on DTDs obsolete. On a lighter note MTOM has
+standardized the referencing mechanism of SwA. Following is an extract from
+the <a href="http://www.w3.org/TR/2004/PR-xop10-20041116/">XOP</a>
+specification.</p>
+
+<p><em>At the conceptual level, this binary data can be thought of as being
+base64-encoded in the XML Document. As this conceptual form might be needed
+during some processing of the XML Document (e.g., for signing the XML
+document), it is necessary to have a one to one correspondence between XML
+Infosets and XOP Packages. Therefore, the conceptual representation of such
+binary data is as if it were base64-encoded, using the canonical lexical form
+of XML Schema base64Binary datatype (see <a href="#XMLSchemaP2">[XML Schema
+Part 2: Datatypes Second Edition] </a><a
+href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#base64Binary">3.2.16
+base64Binary</a>). In the reverse direction, XOP is capable of optimizing
+only base64-encoded Infoset data that is in the canonical lexical
+form.</em></p>
+
+<p>Apache Axis2 supports <strong>Base64 encoding</strong>, <strong>SOAP with
+Attachments</strong> &amp; <strong>MTOM (SOAP Message Transmission
+Optimization Mechanism).</strong></p>
+<a name="2"></a>
+
+<h2>MTOM with Axis2</h2>
+<a name="21"></a>
+
+<h3>Programming Model</h3>
+
+<p>AXIOM is (and may be the first) Object Model which has the ability to hold
+binary data. It has been given this ability by allowing OMText to hold raw
+binary content in the form of javax.activation.DataHandler. OMText has been
+chosen for this purpose with two reasons. One is that XOP (MTOM) is capable
+of optimizing only base64-encoded Infoset data that is in the canonical
+lexical form of XML Schema base64Binary datatype. Other one is to preserve
+the infoset in both sender and receiver (To store the binary content in the
+same kind of object regardless of whether it is optimized or not).</p>
+
+<p>MTOM allows to selectively encode portions of the message, which allows us
+to send base64encoded data as well as externally attached raw binary data
+referenced by "XOP" element (optimized content) to be send in a SOAP message.
+User can specify whether an OMText node which contains raw binary data or
+base64encoded binary data is qualified to be optimized or not at the
+construction time of that node or later. To take the optimum efficiency of
+MTOM a user is advised to send smaller binary attachments using
+base64encoding (None optimized) and larger attachments as optimized
+content.</p>
+<source><pre>        OMElement imageElement = fac.createOMElement("image", omNs);
+
+        // Creating the Data Handler for the image.
+        // User has the option to use a FileDataSource or a ImageDataSource 
+        // in this scenario...
+        Image image;
+        image = new ImageIO()
+                .loadImage(new FileInputStream(inputImageFileName));
+        ImageDataSource dataSource = new ImageDataSource("test.jpg",image);
+        DataHandler dataHandler = new DataHandler(dataSource);
+
+        //create an OMText node with the above DataHandler and set optimized to true
+        OMText textData = <strong>fac.createOMText(dataHandler, true);</strong>
+        imageElement.addChild(textData);
+
+        //User can set optimized to false by using the following
+        //textData.doOptimize(false);</pre>
+</source>
+<p>Also a user can create an optimizable binary content node  using a base64
+encoded string, which contains encoded binary content, given with the mime
+type of the actual binary representation.</p>
+<source><pre>        String base64String = "some_base64_encoded_string";
+        OMText binaryNode =<strong>fac.createOMText(base64String,"image/jpg",true);</strong></pre>
+</source>
+<p>Axis2 uses javax.activation.DataHandler to handle the binary data. All
+optimized binary content nodes will be serialized as Base64 Strings if "MTOM
+is not enabled". One can also create binary content nodes which will not be
+optimized at any case. They will be serialized and send as Base64 Strings.</p>
+<source><pre>        //create an OMText node with the above DataHandler and set "optimized" to false
+        //This data will be send as Base64 encoded string regardless of MTOM is enabled or not
+        javax.activation.DataHandler dataHandler = new javax.activation.DataHandler(new FileDataSource("someLocation"));
+        OMText textData = fac.createOMText(dataHandler, <strong>false</strong>); 
+        image.addChild(textData);</pre>
+</source><a name="22"></a>
+
+<h3>Enabling MTOM Optimization at Client Side</h3>
+
+<p>Set the "enableMTOM" property in the Options to true, when sending
+messages.</p>
+<source><pre>        ServiceClient serviceClient = new ServiceClient ();
+        Options options = new Options();
+        options.setTo(targetEPR);
+        <strong>options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);</strong>
+        serviceClient .setOptions(options);</pre>
+</source>
+<p>When this property is set to true any SOAP envelope, regardless whether it contains optimisable content or not,
+ will be serialized as a MTOM optimized MIME message. 
+
+<p>Axis2 serializes all binary content nodes as Base64 encoded strings
+regardless of they are qualified to be optimize or not, if,</p>
+<ul>
+  <li>"enableMTOM" property is set to false.</li>
+  <li>If envelope contains any element information items of name xop:Include
+    (see <a href="#XOP">[XML-binary Optimized Packaging] </a><a
+    href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_infosets">3. XOP
+    Infosets Constructs </a>).</li>
+</ul>
+
+<p>User do <strong>not</strong> have to specifiy anything inoder for Axis2 to receive MTOM optimised messages.
+Axis2 will automatically identify and de-serialize accordingly as and when a MTOM message arrives.</p>
+
+<p><a name="23"></a></p>
+
+<h3>Enabling MTOM Optimization at Server Side</h3>
+
+<p>Axis 2 server automatically identifies incoming MTOM optimized messages
+based on the content-type and de-serializes accordingly. User can enableMTOM
+in the server side for outgoing messages,</p>
+    <blockquote>
+      <p>To enableMTOM globally for all services users can set the "enableMTOM" parameter to true in the Axis2.xml.
+      When it is set, all outgoing messages will be serialized and send as MTOM optimized MIME messages. 
+      If it is not set all the binary data in binary content nodes will be
+      serialized as Base64 encoded strings. This configuration can be overriden in services.xml for per service and per operation
+      basis.</p>
+    </blockquote>
+
+<p><source></p>
+<pre>&lt;parameter name="enableMTOM" locked="false"&gt;true&lt;/parameter&gt;</pre>
+</source>
+    <p>User must restart the server after setting this parameter.</p>
+  
+<a name="24"></a>
+
+<h3>Accessing Received Binary Data (Sample Code)</h3>
+<ul>
+  <li><strong><a name="241"></a>Service</strong></li>
+</ul>
+<source><pre>public class MTOMService {
+    public void uploadFileUsingMTOM(OMElement element) throws Exception {
+
+        Iterator itr = element.getChildElements();
+        folder = (OMElement) itr.next();
+  			....
+
+        images = (OMElement) itr.next();
+        itr = images.getChildElements();
+
+        int i = 1;
+        String picName;
+        while (itr.hasNext()) {
+            picture = (OMElement) itr.next();
+            if (picture == null) throw new AxisFault("Picture " + i + " is null");
+            
+            <strong>OMText binaryNode = (OMText) picture.getFirstOMChild();
+            DataHandler actualDH;
+            actualDH = (DataHandler) binaryNode.getDataHandler();</strong>
+            
+            ... <em>Do whatever you need with the DataHandler</em> ...
+        }
+    }
+  }
+</pre>
+</source><ul>
+  <ul>
+    <li><a name="242"><strong>Client</strong></a></li>
+  </ul>
+</ul>
+<source><pre>
+        ServiceClient sender = new ServiceClient();        
+        Options options = new Options();
+        options.setTo(targetEPR); 
+        // enabling MTOM
+        <strong>options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);</strong>
+        ............
+
+        OMElement result = sender.sendReceive(payload);
+        OMElement ele = result.getFirstElement();
+        OMText binaryNode = (OMText) ele.getFirstOMChild();
+        
+        // Retrieving the DataHandler &amp; then do whatever the processing to the data
+        DataHandler actualDH;
+        actualDH = binaryNode.getDataHandler();
+        .............</pre>
+</source>
+
+<p><a name="25"></a></p>
+
+<h3>MTOM Databinding</h3>
+
+<p>When using MTOM, you simply define the binary file as part of your SOAP message as
+type="xsd:base64Binary" or type="xsd:hexBinary. You indicate the
+type of content in the element at runtime using an MTOM attribute extension,
+xmime:contentType. Furthermore, you can identify what type of data
+might be expected in the element using the xmime:expectedContentType. Putting it all
+together, our example element becomes: 
+</p>
+
+<source><pre>
+      &lt;element name="MyBinaryData" xmime:expectedContentTypes='image/jpeg' &gt;
+        &lt;complexType&gt;
+          &lt;simpleContent&gt;
+            &lt;extension base="base64Binary" &gt;
+              &lt;attribute ref="xmime:contentType" use="required"/&gt;
+            &lt;/extension&gt;
+          &lt;/simpleContent&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;</pre>
+</source>
+<p>Lets define a full, validated doc / lit style WSDL that imports the xmime schema, has a service that 
+       receives a jpeg and returns a pass / fail status to the client:</p>
+
+<source><pre>
+&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+
+&lt;definitions name="MyMTOMService" targetNamespace="http://myMtomNS" xmlns:tns="http://myMtomNS" xmlns="http://schemas.xmlsoap.org/wsdl/" 
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns2="http://myMtomNS/types"&gt;
+  &lt;types&gt;
+    &lt;schema targetNamespace="http://myMtomNS/types" elementFormDefault="qualified" xmlns:tns="http://myMtomNS/types" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema" 
+    xmlns:xmime="http://www.w3.org/2005/05/xmlmime"&gt;
+      &lt;import namespace="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
+       &lt;import namespace="http://www.w3.org/2005/05/xmlmime"
+                schemaLocation="http://www.w3.org/2005/05/xmlmime"/&gt;
+      &lt;complexType name="ReturnWebBase"&gt;
+        &lt;sequence&gt;
+          &lt;element name="errorMessage" type="xsd:string"/&gt;
+          &lt;element name="successErrorCode" type="xsd:int"/&gt;
+        &lt;/sequence&gt;
+      &lt;/complexType&gt;
+      &lt;element name="MyBinaryData" xmime:expectedContentTypes='image/jpeg' &gt;
+        &lt;complexType&gt;
+          &lt;simpleContent&gt;
+            &lt;extension base="base64Binary" &gt;
+              &lt;attribute ref="xmime:contentType" use="required"/&gt;
+            &lt;/extension&gt;
+          &lt;/simpleContent&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+      &lt;element name="sendData"&gt;
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+            &lt;element ref='tns:MyBinaryData' minOccurs="1" maxOccurs="1" /&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+      &lt;element name="sendDataResponse"&gt;
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+            &lt;element minOccurs="1" maxOccurs="1" name="sendDataResult" type="tns:ReturnWebBase" /&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+    &lt;/schema&gt;
+  &lt;/types&gt;
+  &lt;message name="MyMTOMEndpoint_sendData"&gt;
+     &lt;part name="parameters" element="ns2:sendData"/&gt;
+  &lt;/message&gt;
+  &lt;message name="MyMTOMEndpoint_sendDataResponse"&gt;
+    &lt;part name="result" element="ns2:sendDataResponse"/&gt;
+  &lt;/message&gt;
+  &lt;portType name="MyMTOMEndpoint"&gt;
+    &lt;operation name="sendData"&gt;
+      &lt;input message="tns:MyMTOMEndpoint_sendData" name="MyMTOMEndpoint_sendData"/&gt;
+      &lt;output message="tns:MyMTOMEndpoint_sendDataResponse" name="MyMTOMEndpoint_sendDataResponse"/&gt;
+    &lt;/operation&gt;
+  &lt;/portType&gt;
+  &lt;binding name="MyMTOMEndpointBinding" type="tns:MyMTOMEndpoint"&gt;
+    &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
+    &lt;operation name="sendData"&gt;
+      &lt;soap:operation soapAction="sendData"/&gt;
+      &lt;input name="MyMTOMEndpoint_sendData"&gt;
+        &lt;soap:body use="literal"/&gt;
+      &lt;/input&gt;
+      &lt;output name="MyMTOMEndpoint_sendDataResponse"&gt;
+        &lt;soap:body use="literal"/&gt;
+      &lt;/output&gt;
+    &lt;/operation&gt;
+  &lt;/binding&gt;
+  &lt;service name="MyMTOMService"&gt;
+    &lt;port name="MyMTOMEndpointPort" binding="tns:MyMTOMEndpointBinding"&gt;
+      &lt;soap:address location="http://localhost:8080/axis2/services/MyMTOMService"/&gt;&lt;/port&gt;&lt;/service&gt;&lt;/definitions&gt;
+  </pre>
+</source>
+<p>The important point here is we import http://www.w3.org/2005/05/xmlmime and define an element, 'MyBinaryData' , that utilizes MTOM. </p>
+
+<p>The next step is using the Axis2 tool 'WSDL2Java' to generate java source files from this WSDL. See the 'Code Generator Tool' guide for more 
+info.  Here, we define an ant task that chooses XMLBeans as the databinding implementation. We also choose to generate an interface which our 
+Skeleton will implement. The name we list for the WSDL above is mtomExample.wsdl, and we define our package name for our generated source files to be 
+'org.apache.axis2.samples.mtomDatabinding.endpoint' . Our ant task for this example is: 
+</p>
+
+<source><pre>&lt;target name="wsdl2java" depends="clean,prepare"&gt;
+      &lt;delete dir="output" /&gt;
+      &lt;java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"&gt;
+          &lt;classpath refid="axis.classpath"/&gt; 
+          &lt;arg value="-d"/&gt;
+          &lt;arg value="xmlbeans"/&gt;
+          &lt;arg value="-uri"/&gt;
+          &lt;arg file="wsdl/mtomExample.wsdl"/&gt;
+          &lt;arg value="-ss"/&gt;
+          &lt;arg value="-ssi"/&gt;
+          &lt;arg value="-g"/&gt;
+          &lt;arg value="-sd"/&gt;
+          &lt;arg value="-o"/&gt;
+          &lt;arg file="output"/&gt;
+          &lt;arg value="-p"/&gt;
+          &lt;arg value="org.apache.axis2.samples.mtomDatabinding.endpoint"/&gt;
+      &lt;/java&gt;
+
+      &lt;!-- Move the schema folder to classpath--&gt;
+      &lt;move todir="${build.classes}"&gt;
+          &lt;fileset dir="output/resources"&gt;
+              &lt;include name="*schema*/**/*.class"/&gt;
+              &lt;include name="*schema*/**/*.xsb"/&gt;
+          &lt;/fileset&gt;
+      &lt;/move&gt;
+
+  &lt;/target&gt;</pre>
+</source>
+<p>Now we are ready to code. Lets edit output/src/org/apache/axis2/samples/mtomDatabinding/endpoint/MyMTOMServiceSkeleton.java
+and fill in the business logic. The end result becomes: </p>
+
+<source><pre>/**
+ * MyMTOMServiceSkeleton.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis2 version: SNAPSHOT Jul 19, 2006 (03:46:19 BRT)
+ */
+package org.apache.axis2.samples.mtomDatabinding.endpoint;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import mymtomns.types.ReturnWebBase;
+import mymtomns.types.SendDataDocument;
+import mymtomns.types.SendDataResponseDocument;
+import mymtomns.types.MyBinaryDataDocument.MyBinaryData;
+import mymtomns.types.SendDataDocument.SendData;
+import mymtomns.types.SendDataResponseDocument.SendDataResponse;
+
+/**
+ *  MyMTOMServiceSkeleton java skeleton for the axisService
+ */
+public class MyMTOMServiceSkeleton implements MyMTOMServiceSkeletonInterface {
+     
+    /** commons logging declaration. * */
+    private static Log logger = LogFactory
+            .getLog(MyMTOMServiceSkeleton.class);
+    
+    /** Put file received here - change path for your system. */
+    private static final String MY_DIR = "/home/myuser/example_dir/output";
+    /** Success code. */
+    public static final Integer SUCCESS = new Integer(0);
+    /** Failure / Exception code. */
+    public static final Integer FAILURE = new Integer(-1);
+    
+    /**
+     * Auto generated method signature.
+     *
+     * @param sendDataDocument
+     *            input complex object
+     * @return SendDataResponseDocument complex object return values
+     */
+    public SendDataResponseDocument sendData (SendDataDocument sendDataDocument) {
+    
+        // prepare output
+        SendDataResponseDocument retDoc = SendDataResponseDocument.Factory
+                .newInstance();
+
+        SendDataResponse retElement = SendDataResponse.Factory
+                .newInstance();
+    
+        ReturnWebBase returnWebBase = ReturnWebBase.Factory
+                .newInstance();
+
+        try {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Reached mtomExample on the server side...");
+            }
+            SendData sendData = sendDataDocument.getSendData();
+            MyBinaryData myBinaryData = sendData.getMyBinaryData();
+            byte [] myJpegBytes = myBinaryData.getByteArrayValue();
+
+            File jpegFile = new File(MY_DIR+"myJpeg.jpg");
+            FileOutputStream fos = new FileOutputStream(jpegFile);
+            fos.write( myJpegBytes );
+            fos.flush();
+            fos.close();        
+
+            returnWebBase.setSuccessErrorCode(SUCCESS);
+            returnWebBase.setErrorMessage("SUCCESS");
+
+        } catch (Exception ex) {
+            logger.error("MyMTOMServiceSkeleton.sendData error:"
+                    + ex.getMessage(), ex);
+            returnWebBase.setErrorMessage(ex.getMessage());
+            returnWebBase.setSuccessErrorCode(FAILURE);
+        }
+        retElement.setSendDataResult(returnWebBase);
+        retDoc.setSendDataResponse(retElement);
+        return retDoc;
+    }
+     
+}</pre>
+</source>
+
+<p>The code above receives a jpeg file and writes it to disk. 
+It returns zero on success and in the case of an error, returns -1 along with a stacktrace. Now lets define the client:</p>
+
+<source><pre>package client;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+
+import mymtomns.types.ReturnWebBase;
+import mymtomns.types.SendDataDocument;
+import mymtomns.types.SendDataResponseDocument;
+import mymtomns.types.MyBinaryDataDocument.MyBinaryData;
+import mymtomns.types.SendDataDocument.SendData;
+import mymtomns.types.SendDataResponseDocument.SendDataResponse;
+import org.apache.axis2.samples.mtomDatabinding.endpoint.MyMTOMServiceStub;
+
+public class MTOMXMLBeansClient {
+
+    /** Read file from here - change path for your system. */
+    private static final String MY_DIR = "/home/myuser/example_dir/input/";
+
+    public static void main(String [] args) throws Exception {
+ 
+        try {
+            SendData sendData
+                  = SendData.Factory
+                      .newInstance();
+            SendDataDocument doc
+                  = SendDataDocument.Factory
+                      .newInstance();
+            MyBinaryData myBinaryData
+              = MyBinaryData.Factory
+                  .newInstance();
+            
+            File file=new File(MY_DIR + "axis.jpg");
+            FileInputStream stream=new FileInputStream(file);
+            int size=stream.available();
+            byte[] bytes=new byte[size];
+            stream.read(bytes);
+            
+            myBinaryData.setByteArrayValue(bytes);
+            sendData.setMyBinaryData(myBinaryData);
+            doc.setSendData(sendData);
+       
+            MyMTOMServiceStub stub = new MyMTOMServiceStub();
+            SendDataResponseDocument responseDoc = stub
+                      .sendData(doc);
+            SendDataResponse response = responseDoc
+                      .getSendDataResponse();
+            ReturnWebBase result = response.getSendDataResult();
+            // test for errors
+            if (result.getSuccessErrorCode() ==-1) {
+                System.out.println("ERROR: " + result.getErrorMessage());
+            }
+       
+        } catch (Exception e) {
+              e.printStackTrace();
+        }
+    }
+}</pre>
+</source>
+
+<p>The last step is to create an AAR with our Skeleton and the generated interface and services.xml, and then deploy the service. See the user guide for more info. </p>
+
+<a name="3"></a>
+<h2>SOAP with Attachments (SwA) with Axis2</h2>
+<a name="31"></a>
+<h3>Receiving SwA type attachments</h3>
+<p>Axis2 automatically identifies SwA messages based on the content type. Axis2 stores the references 
+to the received attachment parts (MIME parts) in the Message Context. Axis2 preserves the order of the received attachments
+ when storing them in the MessageContext. Users can access binary 
+attachments using the attachement API given in the Message Context using content-id of the mime part as the key. 
+Care needs be taken to rip off the "cid" prefix when content-id
+is taken from the "Href" attributes. Users can access the the message context from whithin a service 
+implementation class using the "setOperationContext()" method as shown in the following example.</p>
+
+<p>Note: Axis2 supports content-id based referencing only. Axis2 does not support
+Content Location based referencing of MIME parts.</p>
+<ul>
+  <li><strong>Sample service which accesses a received SwA type attachment</strong></li>
+</ul>
+<source><pre>
+public class SwA {
+    private OperationContext operationContext;
+
+    public SwA() {
+    }
+
+    public void setOperationContext(OperationContext oc) throws AxisFault {
+        operationContext = oc;
+    }
+
+    public void uploadAttachment(OMElement omEle) throws AxisFault {
+        OMElement child = (OMElement) omEle.getFirstOMChild();
+        OMAttribute attr = child.getAttribute(new QName("href"));
+        
+        //Content ID processing
+        String contentID = attr.getAttributeValue();
+        contentID = contentID.trim();
+        if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
+            contentID = contentID.substring(4);
+        }
+        
+        Attachments attachment = (Attachments) (operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
+        DataHandler dataHandler = attachment.getDataHandler(contentID);
+        ...........
+    }
+}
+</pre>
+</source>
+<a name="32"></a>
+<h3>Sending SwA type attachments</h3>

+<p>User need to set the "enableSwA" property to true in order to be able to send SwA
+messages. Axis2 user is <strong>not</strong> expected to enable MTOM & SwA together. 
+In such a situation MTOM will get priority over SwA. </p>
+<p>This can be set using the axis2.xml as follows.</p>
+<source><pre>  
+        &lt;parameter name="enableSwA" locked="false"&gt;true&lt;/parameter&gt;
+</pre></source>
+
+<p>"enableSwA" can also be set using the client side Options as follows</p>
+<source><pre>  
+        options.setProperty(Constants.Configuration.ENABLE_SwA, Constants.VALUE_TRUE);
+</pre></source>
+
+<p> Users are expected to use the attachment API provided in the MessageContext to specify the 
+binary attachments needed to be attached to the outgoing message as SwA type attachments. Client side SwA capability 
+can be used only with the OperationClient api, since the user needs the ability to access the MessageContext.</p>
+<ul>
+  <li><strong>Sample client which sends a message with SwA type attachments</strong></li>
+</ul>
+<source><pre>
+   public void uploadFileUsingSwA(String fileName) throws Exception {
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+        options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        options.setTo(targetEPR);
+  
+        ServiceClient sender = new ServiceClient(null,null);
+        sender.setOptions(options);
+        OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);
+        
+        MessageContext mc = new MessageContext();   
+        mc.setEnvelope(createEnvelope());
+        FileDataSource fileDataSource = new FileDataSource("test-resources/mtom/test.jpg");
+        DataHandler dataHandler = new DataHandler(fileDataSource);
+        mc.addAttachment("FirstAttachment",dataHandler);
+       
+        mepClient.addMessageContext(mc);
+        mepClient.execute(true);
+    }
+</pre>
+</source>
+
+<a name="33"></a>
+<h3>MTOM Backward Compatibility with SwA</h3>
+<p>MTOM specification is designed to be backward compatible with the SOAP
+with Attachments specification. Even though the representation is different,
+both technologies have the same wire format. We can safely assume that any
+SOAP with Attachments endpoint can accept a MTOM optimized messages and treat
+them as SOAP with Attachment messages - Any MTOM optimized message is a valid
+SwA message.</p>
+
+<p>Note : Above backword compatibility was succesfully tested against Axis 1.x</p>
+<ul>
+  <li><strong>A sample SwA message from Axis 1.x</strong></li>
+</ul>
+<source><pre>Content-Type: multipart/related; type="text/xml"; 
+          start="&lt;9D645C8EBB837CE54ABD027A3659535D&gt;";
+                boundary="----=_Part_0_1977511.1123163571138"
+
+------=_Part_0_1977511.1123163571138
+Content-Type: text/xml; charset=UTF-8
+Content-Transfer-Encoding: binary
+Content-Id: &lt;9D645C8EBB837CE54ABD027A3659535D&gt;
+
+&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;soapenv:Envelope xmlns:soapenv="...."....&gt;
+    ........
+                &lt;source href="cid:3936AE19FBED55AE4620B81C73BDD76E" xmlns="/&gt;
+    ........
+&lt;/soapenv:Envelope&gt;
+------=_Part_0_1977511.1123163571138
+Content-Type: text/plain
+Content-Transfer-Encoding: binary
+Content-Id: &lt;3936AE19FBED55AE4620B81C73BDD76E&gt;
+
+<em>Binary Data.....</em>
+------=_Part_0_1977511.1123163571138--</pre>
+</source><ul>
+  <li><strong>Corresponding MTOM message from Axis2</strong></li>
+</ul>
+<source><pre>Content-Type: multipart/related; boundary=MIMEBoundary4A7AE55984E7438034;
+                         type="application/xop+xml"; start="<0....@apache.org>";
+                         start-info="text/xml; charset=utf-8"
+
+--MIMEBoundary4A7AE55984E7438034
+content-type: application/xop+xml; charset=utf-8; type="application/soap+xml;"
+content-transfer-encoding: binary
+content-id: &lt;0.09BC7F4BE2E4D3EF1B@apache.org&gt;
+
+&lt;?xml version='1.0' encoding='utf-8'?&gt;
+&lt;soapenv:Envelope xmlns:soapenv="...."....&gt;
+  ........
+         &lt;xop:Include href="cid:1.A91D6D2E3D7AC4D580@apache.org" 
+                        xmlns:xop="http://www.w3.org/2004/08/xop/include"&gt;
+         &lt;/xop:Include&gt;
+  ........
+&lt;/soapenv:Envelope&gt;
+--MIMEBoundary4A7AE55984E7438034
+content-type: application/octet-stream
+content-transfer-encoding: binary
+content-id: <1....@apache.org>
+
+<em>Binary Data.....</em>
+--MIMEBoundary4A7AE55984E7438034--</pre>
+</source><a name="4"></a>
+
+<h2>Advanced Topics</h2>
+<a name="41"></a>
+
+<h3>File Caching for Attachments</h3>
+
+<p>Axis2 comes handy with a file caching mechanism for incoming attachments,
+which gives Axis2 the ability to handle very large attachments without
+buffering them in memory at any time. Axis2 file caching streams the incoming
+MIME parts directly in to files, after reading the MIME part headers.</p>
+
+<p>Also a user can specify a size threshold for the File caching (in bytes). When this
+threshold value is specified, only the attachments whose size is bigger than
+the threshold value will get cached in files. Smaller attachments will remain
+in Memory.</p>
+
+<p><em>NOTE</em> : It is a must to specify a directory to temporary store the
+attachments. Also care should be taken to <strong>clean that directory</strong> from time to
+time.</p>
+
+<p>The following parameters need to be set in Axis2.xml in order to enable
+file caching.</p>
+<source><pre>&lt;axisconfig name="AxisJava2.0"&gt;
+    &lt;!-- ================================================= --&gt;
+    &lt;!-- Parameters --&gt;
+    &lt;!-- ================================================= --&gt;
+    &lt;parameter name="cacheAttachments" locked="false"&gt;true&lt;/parameter&gt;
+    &lt;parameter name="attachmentDIR" locked="false"&gt;<em>temp directory</em>&lt;/parameter&gt;
+    &lt;parameter name="sizeThreshold" locked="false"&gt;<em>4000</em>&lt;/parameter&gt;
+    .........
+    .........
+&lt;/axisconfig&gt;</pre>
+</source>
+<p>Enabling file caching for client side receiving can be done for the by setting the Options as follows.</p>
+<source><pre>
+	options.setProperty(Constants.Configuration.CACHE_ATTACHMENTS,Constants.VALUE_TRUE);
+	options.setProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR,<em>TempDir</em>);
+	options.setProperty(Constants.Configuration.FILE_SIZE_THRESHOLD, <em>"4000"</em>);
+		
+</pre>
+</source>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/resources/schemas/module.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/xdocs/resources/schemas/module.xsd?view=auto&rev=453167
==============================================================================
--- webservices/axis2/trunk/java/xdocs/resources/schemas/module.xsd (added)
+++ webservices/axis2/trunk/java/xdocs/resources/schemas/module.xsd Thu Oct  5 02:56:34 2006
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Created by Eran Chinthaka -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+	<xs:element name="module">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="Description" minOccurs="0"/>
+				<xs:element name="inflow" minOccurs="0">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element name="handler"  type="handlerType"  minOccurs="0" maxOccurs="unbounded"/>
+						</xs:sequence>
+					</xs:complexType>
+				</xs:element>
+				<xs:element name="outflow" minOccurs="0">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element name="handler"  type="handlerType" minOccurs="0" maxOccurs="unbounded"/>
+						</xs:sequence>
+					</xs:complexType>
+				</xs:element>
+				<xs:element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element ref="operation" minOccurs="0"/>
+				<xs:element name="Outfaultflow" minOccurs="0">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element  name="handler"  type="handlerType" minOccurs="0" maxOccurs="unbounded"/>
+						</xs:sequence>
+					</xs:complexType>
+				</xs:element>
+				<xs:element name="INfaultflow" minOccurs="0">
+					<xs:complexType>
+						<xs:sequence>
+							<xs:element  name="handler"  type="handlerType"  minOccurs="0" maxOccurs="unbounded"/>
+						</xs:sequence>
+					</xs:complexType>
+				</xs:element>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="optional"/>
+			<xs:attribute name="class" type="xs:string" use="optional"/>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="order">
+		<xs:complexType>
+			<xs:attribute name="phase" type="xs:string" use="required"/>
+			<xs:attribute name="after" type="xs:string" use="optional"/>
+			<xs:attribute name="before" type="xs:string" use="optional"/>
+			<xs:attribute name="phaseFirst" type="xs:string" use="optional"/>
+			<xs:attribute name="phaseLast" type="xs:string" use="optional"/>
+		</xs:complexType>
+	</xs:element>
+
+		<xs:complexType name="handlerType">
+			<xs:sequence>
+				<xs:element ref="order"/>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="class" type="xs:string" use="required"/>
+		</xs:complexType>
+
+	<xs:element name="parameter">
+		<xs:complexType>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="locked" type="xs:boolean" use="optional" default="false"/>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="operation">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="messageReceiver" minOccurs="0">
+					<xs:complexType>
+						<xs:attribute name="class"/>
+					</xs:complexType>
+				</xs:element>
+				<xs:element ref="parameter"/>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="mep" type="xs:anyURI" use="required"/>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>

Added: webservices/axis2/trunk/java/xdocs/resources/schemas/services.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/xdocs/resources/schemas/services.xsd?view=auto&rev=453167
==============================================================================
--- webservices/axis2/trunk/java/xdocs/resources/schemas/services.xsd (added)
+++ webservices/axis2/trunk/java/xdocs/resources/schemas/services.xsd Thu Oct  5 02:56:34 2006
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
+	<xs:complexType name="operationType">
+		<xs:sequence>
+			<xs:element name="actionMapping" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element name="outputActionMapping" type="xs:string" minOccurs="0" maxOccurs="1"/>
+			<xs:element name="faultActionMapping" type="xs:string" minOccurs="0" maxOccurs="unbounded">
+				<xs:complexType>
+					<xs:attribute name="faultName" use="required"/>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="messageReceiver" minOccurs="0">
+				<xs:complexType>
+					<xs:attribute name="class" use="required"/>
+				</xs:complexType>
+			</xs:element>
+			<xs:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+			<xs:element name="module" minOccurs="0" maxOccurs="unbounded">
+				<xs:complexType>
+					<xs:attribute name="ref" use="required"/>
+				</xs:complexType>
+			</xs:element>
+		</xs:sequence>
+		<xs:attribute name="name" type="xs:string" use="required"/>
+		<xs:attribute name="mep" type="xs:anyURI" use="optional"/>
+	</xs:complexType>
+	<xs:complexType name="parameterType">
+		<xs:annotation>
+			<xs:documentation>Type describing a parameter. This element contains two attributes
+         and may contain any element or simply a string</xs:documentation>
+		</xs:annotation>
+		<xs:complexContent>
+			<xs:extension base="xs:anyType">
+				<xs:attribute name="name" type="xs:string" use="required"/>
+				<xs:attribute name="locked" type="xs:boolean" use="optional"/>
+			</xs:extension>
+		</xs:complexContent>
+	</xs:complexType>
+	<xs:element name="service">
+		<xs:annotation>
+			<xs:documentation>
+			Service element description. This has a number of
+             parameter and operation elements nested
+     </xs:documentation>
+		</xs:annotation>
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="description" type="xs:string" minOccurs="0"/>
+				<xs:element name="parameter" type="parameterType" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element name="operation" type="operationType" minOccurs="0" maxOccurs="unbounded"/>
+                        <xs:element name="module" minOccurs="0" maxOccurs="unbounded">
+				    <xs:complexType>
+					<xs:attribute name="ref" use="required"/>
+				    </xs:complexType>
+			      </xs:element>
+                        <xs:element name="transports" minOccurs="0" maxOccurs="unbounded">
+                            <xs:sequence>
+				        <xs:element name="transport" type="xs:string" minOccurs="1"/>
+                            </xs:sequence>
+			      </xs:element>
+                        <xs:element name="messageReceivers" minOccurs="0" maxOccurs="unbounded">
+                            <xs:sequence>
+				        <xs:element name="messageReceiver" maxOccurs="unbounded">
+				            <xs:complexType>
+					        <xs:attribute name="mep" type="xs:string"  use="required"/>
+                                       <xs:attribute name="class" type="xs:string"  use="required"/>
+				            </xs:complexType>
+			               </xs:element>
+                            </xs:sequence>
+			      </xs:element>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+                  <xs:attribute name="scope" type="xs:string" use="optional"/>
+                  <xs:attribute name="targetNamespace" type="xs:string" use="optional"/>
+			<xs:attribute name="wsaddressing" type="xs:string" />
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="serviceGroup">
+		<xs:annotation>
+			<xs:documentation>
+			 holder for multiple service elements. 
+     </xs:documentation>
+		</xs:annotation>
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="service" maxOccurs="unbounded"/>
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org