ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cha...@apache.org
Subject svn commit: r388085 [4/6] - in /webservices/axis2/trunk/java/xdocs/latest: ./ adb/ adb/images/ images/ images/archi-guide/ images/tools/ images/tools/service/ images/tools/wsdl/ images/userguide/ resources/ resources/schemas/ sec-conf/
Date Thu, 23 Mar 2006 07:38:40 GMT
Added: webservices/axis2/trunk/java/xdocs/latest/installationguide.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/installationguide.html?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/installationguide.html (added)
+++ webservices/axis2/trunk/java/xdocs/latest/installationguide.html Wed Mar 22 23:38:30 2006
@@ -0,0 +1,336 @@
+<html>
+<head>
+  <meta http-equiv="content-type" content="">
+  <title>Axis2 Installation Guide</title>
+  <style type="text/css">
+  </style>
+</head>
+
+<body lang="en">
+<h1 align="center">Axis2 Installation Guide</h1>
+
+<p><i>Version 0.95</i></p>
+<i>Feedback: <a
+href="mailto:axis-dev@ws.apache.org">axis-dev@ws.apache.org</a></i>
+
+<h3>Contents</h3>
+<ul>
+  <li><a href="#Download_Axis2">Download Axis2</a></li>
+  <li><p><a href="#requirements">System Requirements</a></p>
+  </li>
+  <li><a href="#_Toc96698083">Setting up the Environment and tools</a>
+    <ul>
+      <li><p><a href="#maven">Maven</a></p>
+      </li>
+      <li><a href="#_Toc96698085">The Axis2 source distribution</a></li>
+    </ul>
+  </li>
+  <li><p><a href="#_Toc96698086">Installing Axis2 in a Servlet
+    container</a></p>
+    <ul>
+      <li><a href="#upload">Uploading services</a></li>
+    </ul>
+  </li>
+</ul>
+<a name="Download_Axis2"></a>
+<h3>Download Axis2</h3>
+
+<p>Axis2 is distributed in several convenient distribution packages and can
+be installed either as a standalone server or as part of a J2EE compliant
+servlet container. Axis2 is distributed under the Apache License, version
+2.0. You can download Axis2 <a
+href="http://ws.apache.org/axis2/download.cgi">here</a>. Latest release of
+Axis2 is version 0.95.</p>
+
+<table width="940" border="1" cellpadding="1">
+  <tbody>
+    <tr>
+      <th width="83" scope="col">Distribution Name</th>
+      <th width="633" scope="col">Description</th>
+      <th width="202" scope="col">Items</th>
+    </tr>
+    <tr>
+      <td>Minimal Distribution - Binary</td>
+      <td>This distribution is aimed at advanced users who will be embedding
+        Axis2. It will contain the minimal runtime required to act as a Web
+        Service client and/or a server (axis2-core-0.95.jar will contain
+        compiled versions of common, xml, wsdl and core modules.)</td>
+      <td><ul>
+          <li>axis2-core-0.95.jar, axis2-adb-0.95.jar</li>
+          <li>third party distributable libraries</li>
+          <li>README.TXT and release-notes.html</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>Minimal Distribution - Source</td>
+      <td background="#_Toc96698083"><p>This will contain the sources of
+        Axis2 minimal distribution. One can generate a binary distribution
+        from this by typing  <span class="style1">$maven dist-min-bin.
+        </span>(<a href="#_Toc96698083">Set up Axis2 environment</a> before
+        running this command)</p>
+      </td>
+      <td><ul>
+          <li>sources of Axis2 common, xml, wsdl, adb and core modules</li>
+          <li>README.TXT and release-notes.html</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>Standard Distribution - Binary</td>
+      <td>This is the complete version of Axis2 and will contain useful
+        samples as well. Useful for some one to get familiar with Axis2.
+        (Since WS-Addressing implementation module is engaged in to Axis2, by
+        default, this distribution will contain addressing.mar. But  the
+        other modules that are being developed within Axis2 will not be
+        included here and are available to be downloaded separately from <a
+        href="http://ws.apache.org/axis2/modules/index.html">here</a>.)</td>
+      <td><ul>
+          <li>all the content of minimal-binary distribution</li>
+          <li>Contents of codegen and DOOM modules</li>
+          <li>Samples</li>
+          <li>addressing.mar</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>Standard Distribution - Source</td>
+      <td>This will contain the sources of Axis2 standard distribution. One
+        can generate a binary distribution from this by typing <span
+        class="style1">$maven dist-standard-bin. </span>(<a
+        href="#_Toc96698083">Set up Axis2 environment</a> before running this
+        command)</td>
+      <td><ul>
+          <li>all the content of minimal-source distribution</li>
+          <li>Contents of codegen and DOOM modules</li>
+          <li>Samples</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>WAR (Web Archive) Distribution</td>
+      <td>This will be the web application of Axis2 which can be deployed in
+        most of the servlet containers.</td>
+      <td><ul>
+          <li>all the contents of the minimal distribution</li>
+          <li>Admin web app</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>Documents Distribution</td>
+      <td>This will contain all the documentation in one package.</td>
+      <td><ul>
+          <li>xdocs</li>
+          <li>javadocs</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td>Plugin Distribution</td>
+      <td>This will contain the plugins that are created for Eclipse and
+      IDEA.</td>
+      <td><ul>
+          <li>Intellij IDEA plugins</li>
+          <li>Eclipse plugins</li>
+        </ul>
+      </td>
+    </tr>
+  </tbody>
+</table>
+<a name="requirements"></a>
+<h3>System Requirements</h3>
+
+<table border="2">
+  <caption></caption>
+  <tbody>
+    <tr>
+      <td>Java Runtime
+
+        <p>Environment</p>
+      </td>
+      <td>1.4 (It has not been fully tested on the latest JRE 1.5)
+
+        <p>For instructions on setting up the JRE in different operating
+        systems, visit <a
+        href="http://java.sun.com/">http://java.sun.com</a></p>
+      </td>
+    </tr>
+    <tr>
+      <td>Maven</td>
+      <td>1.0.2 or higher in Maven 1.x series (<a
+        href="http://maven.apache.org/">download</a>). <strong>Please
+        download maven 1.x version. Axis2 is not compatible with maven2
+        yet.</strong>
+
+        <p>Required only for building Axis2 from source distribution</p>
+      </td>
+    </tr>
+    <tr>
+      <td>Memory</td>
+      <td>No minimum requirement</td>
+    </tr>
+    <tr>
+      <td>Disk</td>
+      <td>No minimum requirement.
+
+        <p>Approximately 20 MB will be used for war distribution</p>
+      </td>
+    </tr>
+    <tr>
+      <td>Operating system</td>
+      <td>Tested on Windows XP, Linux, Mac OS X, Fedora core, Ubuntu,
+      Gentoo</td>
+    </tr>
+  </tbody>
+</table>
+
+
+<p>All the required jars are shipped with the binary distribution.</p>
+
+<p>Running the Maven build will automatically download the required jars when
+using source distribution.</p>
+<a name="_Toc96698083"></a>
+<h3>Setting up the Environment and Tools</h3>
+<a name="maven"></a>
+<h4>Maven</h4>
+
+<p>The Axis2 build is based on</p>
+<a href="http://maven.apache.org/maven-1.x/">Maven </a>. Hence the only
+prerequisite to build Axis2 from source distribution is to have Maven
+installed. Extensive instruction guides are available at the Maven site.This
+guide however contains the easiest path for quick environment setting.
+Advanced users who wish to know more about Maven can visit <a
+href="http://maven.apache.org/start/index.html">here </a>.
+<ul>
+  <li>Windows</li>
+</ul>
+<ol>
+  <li>Download and run the Windows installer package</li>
+  <li>Set the 'Environment Variables' ( create system variable MAVEN_HOME and
+    edit path. eg: "C:\Program Files\Apache Software Foundation\maven-1.0.2";
+    path %MAVEN_HOME%\bin)</li>
+  <li>Make sure that system variable JAVA_HOME is set to the location of your
+    JDK, eg. C:\Program Files\Java\jdk1.5.0_02</li>
+  <li>Run maven --version to verify that it is correctly installed.</li>
+</ol>
+
+<p align="center"><img alt="clip_image002 (15K)"
+src="images/clip_image002.jpg" height="211" width="477"></p>
+<ul>
+  <li>Unix based OS (Linux etc)</li>
+</ul>
+
+<p>The tar ball or the zip archive is the best option. Once the archive is
+downloaded expand it to a directory of choice and set the environment
+variable MAVEN_HOME and add MAVEN_HOME/bin to the path as well. More
+instructions for installing Maven in Unix based operating systems can be
+found <a href="http://maven.apache.org/start/install.html">here </a>.</p>
+
+<p>Once maven is properly installed you can start building Axis2.</p>
+<a name="_Toc96698085"></a>
+
+<h4>The Axis2 source distribution</h4>
+
+<p>The <a href="http://ws.apache.org/axis2/download.cgi">source distribution
+</a> is available as a zipped archive. All the necessary build scripts are
+included with the source distribution. Once the source archive is expanded
+into a directory of choice, moving to the particular directory and running
+maven command will build the Axis2 jar file.</p>
+
+<p align="center"><img alt="clip_image004 (43K)" src="images/maven.jpg"
+height="248" width="668"></p>
+
+<p>Once the command completes, the binaries (jar files in this case) can be
+found at a newly created "target" directory.</p>
+
+<p><strong>Note: For the first Maven build (if the maven repository is not
+built first) it will take a while since required jars need to be downloaded.
+However this is a once only process and will not affect any successive
+builds.</strong></p>
+
+<p><strong></strong>The default maven build will however build only the Axis2
+jar file. To obtain a WAR (Web Archive), "maven war" command should be
+issued. This will create a complete WAR with the name axis2.war inside the
+target directory.</p>
+
+<p>Once this build step is complete, the binaries are ready to be
+deployed.</p>
+<a name="_Toc96698086"></a>
+
+<h3>Installing Axis2 in a Servlet container</h3>
+<ol>
+  <li><a href="http://ws.apache.org/axis2/download.cgi">Download</a> Axis2 war file</li>
+  <li>Drop the war in the webapps folder. Most servlet containers will
+    automatically install war. (some servlet containers may require a restart
+    in order to capture the new web application. Refer your servlet container
+    documentation for more information about this.)</li>
+  <li>Once the WAR is successfully installed, test it by pointing the web
+    browser to the <strong>http:// &lt;host :port&gt;/ axis2. </strong>It
+    should produce the following page which is the <strong>Axis2 Web
+    Application Home Page</strong>.</li>
+
+  <p align="center"><strong><img src="images/clip_image006.jpg"
+  alt=""></strong></p>
+
+  <p></p>
+  <li>Use validate link to ensure that everything is fine and smooth. If the
+    validation fails then the war has failed to install properly or some
+    essential jars are missing. At such a situation the documentation of the
+    particular servlet container should be consulted to find the problem. The
+    following page is a successful validation. Note the statement core Axis2
+    libraries are present.
+    <p></p>
+  </li>
+
+  <p align="center"><strong><img src="images/happyaxis.jpg"
+  alt=""></strong></p>
+</ol>
+<a name="upload"></a>
+<h4>Uploading services</h4>
+<ol>
+  <p>The Axis2 web application also provides an interface to upload services.
+  Once a service is created according to the service specification as
+  described in userguide that jar file can be uploaded using the upload
+  page.</p>
+
+  <p align="center"><strong><img src="images/clip_image010.jpg"
+  alt=""></strong></p>
+
+  <p>The uploaded jar files will be stored in the default service directory.
+  For Axis2 this will be the &lt;webapps&gt;/axis2/WEB-INF/services
+  directory. Once a service is uploaded it will be installed instantly.</p>
+
+  <p>Since Axis2 supports hot deployment one can drop the service jar
+  directly through the file system to the above mentioned services
+  directory.It will also cause the service to be automatically installed
+  without the container being restarted.</p>
+
+  <p>Use the 'Services' link on the Web Application home page to check the
+  successful installation of a service. The services and the operations of
+  successfully installed services will be displayed in the available services
+  page.</p>
+
+  <p align="center"><img src="images/clip_image012.jpg" alt=""></p>
+
+  <p></p>
+
+  <p>If the service has deployment time error it will list those services as
+  faulty services. If you click on the link you can see the your deployment
+  fault error message(s).</p>
+
+  <p align="center"><img src="images/faultservice.jpg" alt=""></p>
+
+  <p>Deployment time error message</p>
+
+  <p align="center"><strong><img src="images/faultmsg.jpg"
+  alt=""></strong></p>
+
+  <p></p>
+
+  <p>Axis2 Administration is all about configuring Axis2 at the run time and
+  the configuration will be transient. More descriptions are available in <a
+  href="webadminguide.html">Axis2 Web Administration Guide</a></p>
+</ol>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/latest/mail-configuration.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/mail-configuration.html?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/mail-configuration.html (added)
+++ webservices/axis2/trunk/java/xdocs/latest/mail-configuration.html Wed Mar 22 23:38:30 2006
@@ -0,0 +1,110 @@
+<!-- saved from url=(0022)http://internet.e-mail -->
+<html>
+<head>
+<title>Mail transport</title>
+
+</head>
+
+<body><h1>Mail transport</h1>
+<p>The inner workings of the mail transport has two parts, the transport sender and the transport listener. The transport listener is a basic email client which will be on a loop checking for new messages for a particular email address. When an email comes in it will be tunneled into the Axis engine.</p>
+<p>Mail transport can be used against a generic mail server or it can be used like a mailet. The simple mailet provided with Axis2 will direct any message that is coming to a particular address into the Axis engine. The engine will process the message and will use the Transport sender to send the reply.</p>
+<p></p>
+<p>To get started on the mail transport you need the following additional jar dependencies on the classpath.</p>
+  <ol>
+  <li>javamail</li>
+  <li>activation</li>
+  </ol>
+<p>We use the Geronimo version of these jars to compile but you will need the sun version to run the code. Specificaly we are using geronimo-spec-javamail-[version].jar and geronimo-spec-activation-[version].jar. These will be downloaded by maven when you run the maven build.</p>
+
+<h2>Transport Sender</h2>
+<p>You need to have a mail account to activate the mail functionality. This can either be a generic mail server or you can start up a james mail server. The Mail transport sender can be activated by adding following entry to the axis2.xml file.</p>
+  <source>
+  <pre>
+   &lt;transportSender name="mail" class="org.apache.axis2.transport.mail.MailTransportSender"&gt;
+        &lt;parameter name="transport.mail.smtp.host" locked="xsd:false"&gt;smtp server host&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.smtp.user" locked="xsd:false"&gt;user name&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.smtp.password" locked="xsd:false"&gt;password&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.smtp.port" locked="xsd:false"&gt;Port on the server for pop&lt;/parameter&gt;
+   &lt;/transportSender&gt;
+  </pre>
+  </source>
+
+  <h2>Transport Receiver</h2>
+
+  <p>The mail Listener can be activated by adding the following entry to the axis2.xml file.</p>
+
+  <source><pre>
+   &lt;transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener"&gt;
+        &lt;parameter name="transport.mail.pop3.host" locked="xsd:false"&gt;pop server host&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.pop3.user" locked="xsd:false"&gt;user name&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.pop3.password" locked="xsd:false"&gt;password&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.pop3.port" locked="xsd:false"&gt;Port on the server for smtp&lt;/parameter&gt;
+        &lt;parameter name="transport.mail.replyToAddress" locked="xsd:false"&gt;email address&lt;/parameter&gt;
+  &lt;/transportReceiver&gt;
+  </pre></source>
+
+  <p>At the Client side if the Mail Listener is needed it is automatically started by Axis2.</p>
+
+  <h2>Using Mail transport in the Server Side</h2>
+  <p> If the Mail Listener is need to be started as the server it can be done with following command with the all the axis2 jars and the mail dependency jars in the classpath.</p>
+  <source><pre>java org.apache.axis2.transport.mail.SimpleMailListener repository-directory</pre></source>
+
+  <h2>Using Mail transport in the Client Side</h2>
+  <p>Following code segment shows how to send a oneway SOAP message using the mail transport, this need the Transport Sender configured.</p>
+<source>
+<pre>
+OMElement payload = ....
+
+MessageSender sender = new MessageSender(serviceContext);
+sender.setTo(targetEPR);
+sender.setSenderTransport(Constants.TRANSPORT_MAIL);
+
+sender.send(operationName.getLocalPart(), payload);
+</pre>
+</source>
+  
+  <h2>Configure James as SMTP and POP server</h2>
+  <p>Download the <a href="http://james.apache.org/">Apache James</a> and start James, connect to the James via telnet for administrator James with the following code
+</p>
+
+<source>
+<pre>
+$telnet 127.0.0.1 4555
+Trying 127.0.0.1...
+Connected to localhost.localdomain (127.0.0.1).
+Escape character is '^]'.
+JAMES Remote Administration Tool 2.2.0
+Please enter your login and password
+Login id:
+root
+Password:
+root
+Welcome root. HELP for a list of commands
+</pre>
+</source>
+
+<p>Add users to James</p>
+<source>
+<pre>
+adduser axis2-server axis2
+User axis2-server added
+adduser axis2-client axis2
+User axis2-client added
+Connection closed by foreign host.
+</pre>
+</source>
+
+  <p>Now James is up and running with the accounts</p>
+
+  <h2>Using the included mail server</h2>
+
+  <p>The inbuilt mail server can be started from the command line using the following piece of code when all the needed jars are in the class path.</p>
+<source><pre>java org.apache.axis2.transport.mail.server.MailServer</pre></source>
+  <p>The server itself does not need any configuration or tinkering to work. A ConfigurationContext and the ports to operate on are the only details needed. The server will store the mails in memory against the recipient till the recipient pops it from the server. To facilitate the use in *nix environments as a non root user the pop and smtp ports used by default config/test cases are (1024 + 25) and (1024 + 110).</p>
+
+  <hr/>
+
+  <p>&nbsp;</p>
+
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/latest/mail-transport.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/mail-transport.html?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/mail-transport.html (added)
+++ webservices/axis2/trunk/java/xdocs/latest/mail-transport.html Wed Mar 22 23:38:30 2006
@@ -0,0 +1,279 @@
+<!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</h1>
+
+<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
+SETI@HOME through mail.</p>
+
+<h2>Introduction</h2>
+
+<p>To start you will first need to go through the Mail Transport <a
+href="mail-configuration.html">configuration document</a>. It will give you
+all the information you need on how to configure Axis2 to get mail transport
+working.</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.<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>If you are not a guru in mail related issues you should probably get
+started on the simple mail server that has been provided with Axis2. Once you
+get the hang of the Axis2 related issues then you can move on to tackle the
+mail beast. Please do keep in mind that the mail server we have implemented
+is ONLY FOR DEMONSTRATION/TESTING PURPOSES.</p>
+
+<h3>1. Using the simple mail server included in Axis2</h3>
+
+<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();
+
+        // Setup a service that will echo what we send to the server.
+        AxisService axisService = Utils.createSimpleService(serviceName,
+                Echo.class.getName(), new QName("echoOMElement"));
+        configContext.getAxisConfiguration().addService(axisService);
+        Utils.resolvePhases(configContext.getAxisConfiguration(), axisService);
+        ServiceContext serviceContext = configContext
+                .createServiceContext(new QName("EchoXMLService"));</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 axisService = new AxisService(serviceName);
+        AxisOperation axisOperation = new AxisOperation(operationName);
+        axisOperation.setMessageReceiver(new MessageReceiver() {
+                public void receive(MessageContext messgeCtx) throws AxisFault {
+                        envelope = messgeCtx.getEnvelope();
+                }
+        });
+        axisService.addOperation(axisOperation);
+        configContext.getAxisConfiguration().addService(axisService);
+        Utils.resolvePhases(configContext.getAxisConfiguration(), axisService);
+        ServiceContext serviceContext = configContext
+                .createServiceContext(serviceName);
+                
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_MAIL);
+        options.setUseSeparateListener(true);
+        // Create a callback to set to the axisService invocation.
+        Callback callback = new Callback() {
+                public void onComplete(AsyncResult result) {
+                        try {
+                                result.getResponseEnvelope().serialize(
+                                        XMLOutputFactory.newInstance()
+                                                .createXMLStreamWriter(System.out));
+                        } catch (XMLStreamException e) {
+                                reportError(e);
+                        } finally {
+                                finish = true;
+                        }
+                }
+                public void reportError(Exception e) {
+                        log.info(e.getMessage());
+                        finish = true;
+                }
+         };
+
+        ServiceClient sender = new ServiceClient(configContext, axisService);
+        sender.setOptions(options);
+        options.setTo(targetEPR);
+        // Call the service and start poling for the reply from the server.
+        sender.sendReceiveNonBlocking(operationName.getLocalPart(), createEnvelope(), callback);
+
+        int index = 0;
+        while (!finish) {
+                Thread.sleep(1000);
+                index++;
+                if (index &gt; 10) {
+                        throw new AxisFault(
+                                "Server is being shutdown as the Async response is taking too long.");
+                }
+        }
+</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.Thats all there is to it. Please do note that
+serviceName and operationName need to be QNames.
+</p>
+
+<p></p>
+
+<h3>2. Using a generic mail server</h3>
+
+<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="http://ws.apache.org/axis2/mail-transport.html">introduction
+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 configContextbuilder
+                .buildConfigurationContext(file.getAbsolutePath());
+
+        // Startup the default mail server and start listening to a 
+        // mail address.
+        SimpleMailListener ml = new SimpleMailListener();
+        ml.init(configContext, configContext.getAxisConfiguration()
+                .getTransportIn(new QName(Constants.TRANSPORT_MAIL)));
+        ml.start();
+
+        // Setup a simple service.
+        AxisService axisService = Utils.createSimpleService(serviceName,
+                Echo.class.getName(), operationName);
+        configContext.getAxisConfiguration().addService(axisService);
+        Utils.resolvePhases(configContext.getAxisConfiguration(), axisService);
+        ServiceContext serviceContext = configContext.createServiceContext(serviceName);</pre>
+</source>
+<p>Note that a separate ConfigurationContext needs to be created and used.</p>
+
+<h3>3. Calling Axis through a James mailet</h3>
+
+<p>This process will be a bit more challenging than the other two methods but
+will provide a really elegant way to use the mail transport. Before we get
+started you will have to go though the James documents <a
+href="http://james.apache.org/custom_matcher_2_1.html">Writing a Custom
+Matcher</a> and <a
+href="http://james.apache.org/custom_mailet_2_1.html">Writing a Custom
+Mailet</a>.</p>
+
+<p>Now that we know the James part of it lets dive into to the Axis2 part of
+the code. Once you have set up the James side of business we need to use the
+same functionality that is used in the above code. Have a look at the code
+listing below for more details</p>
+<source><pre>    public void processMail(ConfigurationContext confContext, MimeMessage mimeMessage) {
+        // create an Axis server
+        AxisEngine engine = new AxisEngine(confContext);
+        MessageContext msgContext = null;
+        // create and initialize a message context
+        try {
+            // Create a message context with mail as in and out transports.
+            msgContext =
+                    new MessageContext(confContext,
+                            confContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL)),
+                            confContext.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_MAIL)));
+            msgContext.setServerSide(true);
+
+            msgContext.setProperty(MailConstants.CONTENT_TYPE, mimeMessage.getContentType());
+            msgContext.setWSAAction(getMailHeader(MailConstants.HEADER_SOAP_ACTION, mimeMessage));
+
+            // The service path is in the subject of the mail.
+            String serviceURL = mimeMessage.getSubject();
+            if (serviceURL == null) {
+                serviceURL = "";
+            }
+
+            String replyTo = ((InternetAddress) mimeMessage.getReplyTo()[0]).getAddress();
+            if (replyTo != null) {
+                msgContext.setReplyTo(new EndpointReference(replyTo));
+            }
+
+            String recipients = ((InternetAddress) mimeMessage.getAllRecipients()[0]).getAddress();
+
+            if (recipients != null) {
+                msgContext.setTo(new EndpointReference(recipients + "/" + serviceURL));
+            }
+
+            // add the SOAPEnvelope
+            String message = mimeMessage.getContent().toString();
+            ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());
+            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
+
+            // This is just in place to work with SOAP 1.1 and 1.2.
+            String soapNamespaceURI = "";
+            if (mimeMessage.getContentType().indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) &gt; -1) {
+                soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            } else if (mimeMessage.getContentType().indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) &gt; -1) {
+                soapNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+            }
+            StAXBuilder builder = new StAXSOAPModelBuilder(reader, soapNamespaceURI);
+
+            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
+            msgContext.setEnvelope(envelope);
+            if (envelope.getBody().hasFault()) {
+                engine.receiveFault(msgContext);
+            } else {
+                engine.receive(msgContext);
+            }
+        } catch (Exception e) {
+            try {
+                if (msgContext != null) {
+                    MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);
+                    engine.sendFault(faultContext);
+                }
+            } catch (Exception e1) {
+                log.error(e);
+            }
+        }
+    }</pre>
+</source>
+<p>If you don't happen to have a ConfigurationContext lying around to call
+this method you can use the following bit of code to get one. Once you create
+one you can store that on the mailet and keep using it.</p>
+<source><pre>        File file = new File(MAIL_TRANSPORT_SERVER_ENABLED_REPO_PATH);
+        ConfigurationContextFactory builder = new ConfigurationContextFactory();
+        ConfigurationContext configContextbuilder
+                .buildConfigurationContext(file.getAbsolutePath());</pre>
+</source>
+<p></p>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/latest/migration.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/migration.html?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/migration.html (added)
+++ webservices/axis2/trunk/java/xdocs/latest/migration.html Wed Mar 22 23:38:30 2006
@@ -0,0 +1,641 @@
+<!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 Axis 1.x to Axis 2</h1>
+
+<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>
+
+<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>
+
+<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 detail 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;!--  System pre defined 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="PostDispatch"/&gt;
+            &lt;/handler&gt;
+        &lt;/phase&gt;
+        &lt;!--  System pre defined phases       --&gt;
+        &lt;!--   After Postdispatch phase module author or or service author can add any phase he want      --&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;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+        &lt;!--system predefined phase--&gt;
+        &lt;!--these phase will run irrespective of the service--&gt;
+        &lt;phase name="PolicyDetermination"/&gt;
+        &lt;phase name="MessageOut"/&gt;
+    &lt;/phaseOrder&gt;
+    &lt;phaseOrder type="INfaultflow"&gt;
+        &lt;!--      user can add his own phases to this area  --&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+    &lt;/phaseOrder&gt;
+    &lt;phaseOrder type="Outfaultflow"&gt;
+        &lt;!--      user can add his own phases to this area  --&gt;
+        &lt;phase name="userphase1"/&gt;
+        &lt;phase name="soapmonitorPhase"/&gt;
+        &lt;phase name="PolicyDetermination"/&gt;
+        &lt;phase name="MessageOut"/&gt;
+    &lt;/phaseOrder&gt;</pre>
+
+<p>See the user guide for more info on axis2 modules.</p>
+
+<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>
+
+<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 of 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 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 CodegenToolReference guide.</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 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, comming 
+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 vars...
+
+                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>
+
+<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 User guide and the Architecture
+guide of Axis2 properly. Axis2 is very much straight forward and friendly to use than it's successor.</p>
+</body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/latest/mtom-guide.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/mtom-guide.html?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/mtom-guide.html (added)
+++ webservices/axis2/trunk/java/xdocs/latest/mtom-guide.html Wed Mar 22 23:38:30 2006
@@ -0,0 +1,448 @@
+<html>
+<head>
+  <meta http-equiv="content-type" content="">
+  <title>Sending Binary data with SOAP</title>
+</head>
+
+<body>
+<h1>Sending Binary Data with SOAP</h1>
+<ul>
+  <li><a href="#1">Introduction</a></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>
+    </ul>
+  </li>
+  <li><a href="#3">SOAP with Attachments with Axis2</a></li>
+  <li><a href="#4">Advanced Topics </a>
+    <ul>
+      <li><a href="#41">File Caching for Attachments</a></li>
+    </ul>
+  </li>
+</ul>
+
+<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/>
+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>
+
+<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>
+
+<h1>MTOM with Axis2</h1>
+
+<h2>Programming Model</h2>
+
+<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 = fac.createText(dataHandler, true);
+        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_string";
+        OMText binaryNode =  fac.createText(base64String,"image/jpg",true);</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 FileDataHandler("someLocation"));
+        OMText textData = fac.createText(dataHandler, false); 
+        image.addChild(textData);</pre>
+</source>
+<h2>Enabling MTOM optimization at client side</h2>
+
+<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);
+        options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        serviceClient .setOptions(options);</pre>
+</source>
+<p>When this property is set to true any SOAP envelope which contains
+optimizable content (OMText nodes containing binary content with optimizable
+flag "true") will be serialized as a MTOM optimized message. Messages will
+not be packaged as MTOM if they did not contain any optimizable content even
+though MTOM is enabled. But due considering the policy assertions, there may
+be a policy saying, all the request should be optimized eventhough there are
+any optimized contents. To support this phenomenon there is an entry called
+"forced mime" which has to be set as</p>
+<source><pre>        ServiceClient serviceClient = new ServiceClient ();
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setProperty(Constants.Configuration.FORCE_MIME, Constants.VALUE_TRUE);
+        serviceClient.setOptions(options);</pre>
+</source>
+<p></p>
+
+<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>MTOM is *always enabled* in Axis2 when it comes to receiving messages.
+Axis2 will automatically identify and de-serialize any MTOM message it
+receives.</p>
+
+<p></p>
+
+<p><a name="23"></a></p>
+
+<h2>Enabling MTOM optimization in the Server side</h2>
+
+<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>
+<ul>
+  <li>Globally for all services
+
+    <blockquote>
+      <p>add and set the "enableMTOM" parameter to true in the Axis2.xml.
+      When it is set, *outgoing* messages *which contains optimizable
+      content* will be serialized and send as MTOM optimized messages. If it
+      is not set all the binary data in binary content nodes will be
+      serialized as Base64 encoded strings.</p>
+    </blockquote>
+  </li>
+</ul>
+
+<p><source>
+<pre>&lt;parameter name="enableMTOM" locked="false"&gt;true&lt;/parameter&gt;</pre>
+</source>
+</p>
+<ul>
+  <ul>
+    <p>User must restart the server after setting this parameter.</p>
+  </ul>
+</ul>
+
+<p><a name="24"></a></p>
+
+<h2>Accessing received Binary Data</h2>
+<ul>
+  <li><strong><a name="241"></a>Service</strong></li>
+</ul>
+<source><pre>public class MTOMService {
+    public OMElement mtomSample(OMElement element) throws Exception {
+        OMElement imageEle = element.getFirstElement();
+        OMElement imageName = (OMElement) imageEle.getNextSibling();
+        OMText binaryNode = (OMText) imageEle.getFirstChild();
+        String fileName = imageName.getText();
+
+        //Extracting the data and saving
+        DataHandler actualDH;
+        actualDH = binaryNode.getDataHandler();
+        Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
+                .getInputStream());
+        FileOutputStream imageOutStream = new FileOutputStream(fileName);
+        new JDK13IO().saveImage("image/jpeg", actualObject, imageOutStream);
+
+        //setting response
+        OMFactory fac = OMAbstractFactory.getOMFactory();
+        OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
+        OMElement ele = fac.createOMElement("response", ns);
+        ele.setText("Image Saved");
+        return ele;
+    }
+}</pre>
+</source><ul>
+    <a name="242"/>
+  <li><strong>Client</strong></li>
+</ul>
+<source><pre>        Options options = new Options();
+        options.setTo(targetEPR); 
+        // enabling MTOM
+        options.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+        options.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP, false);
+        options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+        OMElement result = (OMElement) call.invokeBlocking(operationName.
+                                getLocalPart(),payload);
+        OMElement ele = (OMElement) result.getFirstChild();
+        OMText binaryNode = (OMText) ele.getFirstChild();
+        
+        // Retrieving the DataHandler &amp; then do whatever the processing to the data
+        DataHandler actualDH;
+        actualDH = binaryNode.getDataHandler();
+        Image actualObject = new ImageIO().loadImage(actualDH.getDataSource()
+                .getInputStream());</pre>
+</source>
+<p><a name="3"></a></p>
+
+<h1>SOAP with Attachments (SwA) with Axis2</h1>
+
+<p>Axis2 Handles SwA messages at the inflow only. When Axis2 receives a SwA
+message it extracts the binary attachment parts and puts a reference to those
+parts in the Message Context. Users can access binary attachments using the
+content-id. Care should be taken to rip off the "cid" prefix when content-id
+is taken from the "Href" attributes. When accessing the message context from
+a service users need to use the message context injection mechanism by
+introducing an "init" method to the service class.(see the following service
+example)</p>
+
+<p>Note: Axis2 supports content-id referencing only. Axis2 does not support
+Content Location referencing of MIME parts.</p>
+<ul>
+  <li><strong>Sample service which accepts a SwA message</strong></li>
+</ul>
+<source><pre>public class EchoSwA {
+    private MessageContext msgcts;
+
+    public void init(MessageContext msgcts) {
+        this.msgcts = msgcts;
+    }
+
+    public OMElement echoAttachment(OMElement omEle) {
+        OMElement child  = (OMElement)omEle.getFirstChild();
+        //retreiving the Href attribute which contains the Content Id 
+        OMAttribute attr = (OMAttribute)child.getFirstAttribute(new QName("href"));
+        String contentID = attr.getValue();
+        //content-id processing to remove the "cid" prefix
+        contentID = contentID.trim();
+        if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
+            contentID = contentID.substring(4);
+        }
+                
+        // Retrieving the MIMEHelper instance (which contains reference to attachments)
+        // from the Message Context
+        MIMEHelper attachments = (MIMEHelper)msgcts.getProperty(MIMEHelper.ATTACHMENTS);
+        // Retrieving the respective DataHandler referenced by the content-id
+        DataHandler dataHandler = attachments.getDataHandler(contentID);
+
+        // Echoing back the attachment. Sends out MTOM message
+        OMText textNode = new OMTextImpl(dataHandler);
+        omEle.build();
+        child.detach();
+        omEle.addChild(textNode);
+        return omEle;
+    }
+}</pre>
+</source>
+<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. Because of that Axis2 does not define a separate programming
+model or serialization for SwA. Users can use the MTOM programming model and
+serialization to send messages to SwA endpoints.</p>
+
+<p>Note : Above is tested with 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.09BC7F4BE2E4D3EF1B@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.A91D6D2E3D7AC4D580@apache.org>
+
+<em>Binary Data.....</em>
+--MIMEBoundary4A7AE55984E7438034--</pre>
+</source>
+<h1>Advanced Topics</h1>
+
+<h2>File Caching For Attachments</h2>
+
+<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. 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>NOTE : It is a must to specify a directory to temporary store the
+attachments. Also care should be taken to *clean that directory* 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><em>&lt;axisconfig name="AxisJava2.0"&gt;
+    &lt;!-- ================================================= --&gt;
+    &lt;!-- Parameters --&gt;
+    &lt;!-- ================================================= --&gt;</em>
+    &lt;parameter name="cacheAttachments" locked="xsd:false"&gt;true&lt;/parameter&gt;
+    &lt;parameter name="attachmentDIR" locked="xsd:false"&gt;<em>temp directory</em>&lt;/parameter&gt;
+    &lt;parameter name="sizeThreshold" locked="xsd:false"&gt;4000&lt;/parameter&gt;
+    .........
+    .........
+&lt;/axisconfig&gt;</pre>
+</source></body>
+</html>

Added: webservices/axis2/trunk/java/xdocs/latest/resources/schemas/module.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/resources/schemas/module.xsd?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/resources/schemas/module.xsd (added)
+++ webservices/axis2/trunk/java/xdocs/latest/resources/schemas/module.xsd Wed Mar 22 23:38:30 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="required"/>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="order">
+		<xs:complexType>
+			<xs:attribute name="phase" type="xs:string" use="optional"/>
+			<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" minOccurs="0"/>
+			</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/latest/resources/schemas/services.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/latest/resources/schemas/services.xsd?rev=388085&view=auto
==============================================================================
--- webservices/axis2/trunk/java/xdocs/latest/resources/schemas/services.xsd (added)
+++ webservices/axis2/trunk/java/xdocs/latest/resources/schemas/services.xsd Wed Mar 22 23:38:30 2006
@@ -0,0 +1,39 @@
+<?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="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" minOccurs="0"/>
+				<xs:element name="module" minOccurs="0">
+					<xs:complexType>
+						<xs:attribute name="ref"/>
+					</xs:complexType>
+				</xs:element>
+			</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:element name="parameter">
+		<xs:complexType>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="locked" type="xs:boolean" use="optional"/>
+		</xs:complexType>
+	</xs:element>
+	<xs:element name="service">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element name="Description" minOccurs="0"/>
+				<xs:element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
+				<xs:element ref="operation" minOccurs="0" maxOccurs="unbounded"/>
+			</xs:sequence>
+			<xs:attribute name="name" type="xs:string" use="required"/>
+		</xs:complexType>
+	</xs:element>
+</xs:schema>



Mime
View raw message