axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thil...@apache.org
Subject svn commit: r442137 - in /webservices/axis2/trunk/java/modules: addressing/ integration/ integration/test/org/apache/axis2/engine/util/ integration/test/org/apache/axis2/mtom/ integration/test/org/apache/axis2/swa/ jibx/ kernel/src/org/apache/axis2/ ke...
Date Mon, 11 Sep 2006 09:33:12 GMT
Author: thilina
Date: Mon Sep 11 02:33:11 2006
New Revision: 442137

URL: http://svn.apache.org/viewvc?view=rev&rev=442137
Log:
Adding the SOAP with Attachments API to the message context
Adding SwA serialising logic to the transport senders
Adding the java mail dependency to the required modules
Adding SOAP with Attachments integration tests

Modified:
    webservices/axis2/trunk/java/modules/addressing/project.xml
    webservices/axis2/trunk/java/modules/integration/maven.xml
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFaultReportTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java
    webservices/axis2/trunk/java/modules/jibx/project.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
    webservices/axis2/trunk/java/modules/savan/project.xml
    webservices/axis2/trunk/java/modules/security/project.xml

Modified: webservices/axis2/trunk/java/modules/addressing/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/project.xml?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/project.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/project.xml Mon Sep 11 02:33:11 2006
@@ -107,6 +107,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>${javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
         <!--for java2wsdl generation we use JAM , so there should be a dependency on the
annogen jar or-->
         <!--XML Beans-->
         <dependency>

Modified: webservices/axis2/trunk/java/modules/integration/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/maven.xml?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/maven.xml Mon Sep 11 02:33:11 2006
@@ -479,6 +479,22 @@
         	<copy file="../addressing/target/addressing-${addressing_version}.mar"
         	        	      tofile="target/test-resources/MTOM-fileCache-enabledRepository/modules/addressing-${addressing_version}.mar"/>
 
+            <!-- SwA enabled Repository -->
+              <mkdir dir="target/test-resources/SwA-enabledRepository"/>
+              <mkdir dir="target/test-resources/SwA-enabledRepository/conf"/>
+              <copy file="test-resources/swa/SwA-enabled-axis2.xml"
+                    tofile="target/test-resources/SwA-enabledRepository/conf/axis2.xml"/>
+          	<copy file="../addressing/target/addressing-${addressing_version}.mar"
+          	      tofile="target/test-resources/SwA-enabledRepository/modules/addressing-${addressing_version}.mar"/>
+
+              <!-- SwA file cache enabled Repository -->
+              <mkdir dir="target/test-resources/SwA-fileCache-enabledRepository"/>
+              <mkdir dir="target/test-resources/SwA-fileCache-enabledRepository/conf"/>
+              <copy file="test-resources/swa/SwA-fileCache-enabled-axis2.xml"
+                    tofile="target/test-resources/SwA-fileCache-enabledRepository/conf/axis2.xml"/>
+          	<copy file="../addressing/target/addressing-${addressing_version}.mar"
+          	        	      tofile="target/test-resources/SwA-fileCache-enabledRepository/modules/addressing-${addressing_version}.mar"/>
+
             <!-- Groovy repository -->
             <mkdir dir="target/groovyRepo"/>
             <mkdir dir="target/groovyRepo/conf"/>

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/TestConstants.java
Mon Sep 11 02:33:11 2006
@@ -33,4 +33,6 @@
     public static final QName serviceName = new QName("EchoXMLService");
 
     public static final QName operationName = new QName("echoOMElement");
+    
+    public static final QName swaServiceName = new QName("EchoSwAService");
 }

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFaultReportTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFaultReportTest.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFaultReportTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFaultReportTest.java
Mon Sep 11 02:33:11 2006
@@ -26,7 +26,7 @@
 import org.apache.axis2.integration.UtilServer;
 import org.apache.axis2.integration.UtilServerBasedTestCase;
 import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
-import org.apache.axis2.swa.EchoRawSwATest;
+import org.apache.axis2.swa.EchoRawSwAFileInputTest;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.httpclient.*;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
@@ -48,7 +48,7 @@
     private QName operationName = new QName("mtomSample");
 
     public EchoRawMTOMFaultReportTest() {
-        super(EchoRawSwATest.class.getName());
+        super(EchoRawMTOMFaultReportTest.class.getName());
     }
 
     public EchoRawMTOMFaultReportTest(String testName) {

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
Mon Sep 11 02:33:11 2006
@@ -16,31 +16,44 @@
 
 package org.apache.axis2.swa;
 
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.llom.OMTextImpl;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.Constants;
-import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.util.TestConstants;
 import org.apache.axis2.integration.UtilServer;
 import org.apache.axis2.integration.UtilServerBasedTestCase;
-import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
+import org.apache.axis2.util.Utils;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class EchoRawSwATest extends UtilServerBasedTestCase implements TestConstants {
 
-import javax.xml.namespace.QName;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketException;
 
-public class EchoRawSwATest extends UtilServerBasedTestCase {
+	private static final Log log = LogFactory.getLog(EchoRawSwATest.class);
 
-    private QName serviceName = new QName("EchoSwAService");
+    private AxisService service;
 
-    private QName operationName = new QName("echoAttachment");
+    private boolean finish = false;
 
     public EchoRawSwATest() {
         super(EchoRawSwATest.class.getName());
@@ -51,61 +64,71 @@
     }
 
     public static Test suite() {
-        return getTestSetup2(new TestSuite(EchoRawSwATest.class),
-                Constants.TESTING_PATH + "MTOM-enabledRepository");
+        return getTestSetup2(new TestSuite(EchoRawSwATest.class),Constants.TESTING_PATH +
"SwA-enabledRepository");
     }
 
     protected void setUp() throws Exception {
-        AxisService service = new AxisService(serviceName.getLocalPart());
-        service.setClassLoader(Thread.currentThread().getContextClassLoader());
-        service.addParameter(new Parameter(
-                Constants.SERVICE_CLASS, EchoSwA.class
-                .getName()));
-        AxisOperation axisOp = new InOutAxisOperation(operationName);
-        axisOp.setMessageReceiver(new RawXMLINOutMessageReceiver());
-        axisOp.setStyle(WSDLConstants.STYLE_DOC);
-        service.addOperation(axisOp);
+        service = Utils.createSimpleService(serviceName, EchoSwA.class.getName(),
+                operationName);
         UtilServer.deployService(service);
-
     }
 
     protected void tearDown() throws Exception {
         UtilServer.unDeployService(serviceName);
+        UtilServer.unDeployClientService();
     }
 
-    public void testEchoXMLSync() throws Exception {
-        Socket socket = new Socket("127.0.0.1", 5555);
-        OutputStream outStream = socket.getOutputStream();
-        socket.getInputStream();
-        InputStream requestMsgInStream = getResourceAsStream("/org/apache/axis2/swa/swainput.bin");
-        int data;
-        while ((data = requestMsgInStream.read()) != -1) {
-            outStream.write(data);
-        }
-        outStream.flush();
-        socket.shutdownOutput();
-        BufferedReader reader = new BufferedReader(new InputStreamReader(socket
-                .getInputStream()));
-        StringBuffer sb = new StringBuffer();
-
-        String response = reader.readLine();
-        while (null != response) {
-            try {
-                sb.append(response.trim());
-                response = reader.readLine();
-            } catch (SocketException e) {
-                break;
-            }
-        }
-
-        assertTrue(sb.toString().indexOf(
-                "Apache Axis2 - The NExt Generation Web Services Engine") > 0);
-        assertTrue(sb.toString().indexOf("multipart/related") > 0);
-    }
-
-    private InputStream getResourceAsStream(String path) {
-        return this.getClass().getResourceAsStream(path);
+    protected SOAPEnvelope createEnvelope() throws Exception {
+    	SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+        SOAPEnvelope env = fac.getDefaultEnvelope();
+        
+        OMNamespace omNs = fac.createOMNamespace("htp://localhost/my", "my");
+        OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
+        OMElement data = fac.createOMElement("data", omNs);
+        OMText textData = fac.createOMText("Apache Axis2 Rocks !!!");
+        data.addChild(textData);
+        rpcWrapEle.addChild(data);
+        
+        env.getBody().addChild(rpcWrapEle);
+        return env;
     }
 
 
-}
+    public void testEchoXMLSync() throws Exception {
+        OMElement payload = createEnvelope();
+        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.setTimeOutInMilliSeconds(100000);
+        options.setAction(Constants.AXIS2_NAMESPACE_URI+"/"+operationName.getLocalPart());
+        options.setTo(targetEPR);
+        
+        ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+        
+        ServiceClient sender = new ServiceClient(configContext,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);
+        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        DataHandler dataHandler2 = response.getAttachment("FirstAttachment");
+        assertNotNull(dataHandler);
+        compareDataHandlers(dataHandler,dataHandler2);
+    }
+
+    protected void compareDataHandlers(DataHandler dataHandler, DataHandler dataHandler2)
{
+        String originalTextValue = new OMTextImpl(dataHandler,true,null).getText();
+        String returnedTextValue = new OMTextImpl(dataHandler2,true,null).getText();
+        assertEquals(returnedTextValue, originalTextValue);
+    }
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java
Mon Sep 11 02:33:11 2006
@@ -35,20 +35,20 @@
  */
 
 public class EchoSwA {
-    private MessageContext msgcts;
+    private OperationContext opcts;
 
     public EchoSwA() {
     }
 
     public void setOperationContext(OperationContext oc) throws AxisFault {
-        msgcts = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+        opcts = oc;
     }
 
-    public OMElement echoAttachment(OMElement omEle) {
+    public OMElement echoAttachment(OMElement omEle) throws AxisFault {
         OMElement child = (OMElement) omEle.getFirstOMChild();
         OMAttribute attr = child.getAttribute(new QName("href"));
         String contentID = attr.getAttributeValue();
-        Attachments attachment = (Attachments) msgcts.getProperty(MTOMConstants.ATTACHMENTS);
+        Attachments attachment = (Attachments) (opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
         contentID = contentID.trim();
 
         if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
@@ -59,6 +59,15 @@
         omEle.build();
         child.detach();
         omEle.addChild(textNode);
+        return omEle;
+    }
+    
+    public OMElement echoOMElement(OMElement omEle) throws AxisFault {
+        OMElement child = (OMElement) omEle.getFirstOMChild();
+        Attachments attachment = (Attachments) (opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
+        opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setAttachmentMap(attachment);
+        
+        omEle.build();
         return omEle;
     }
 }

Modified: webservices/axis2/trunk/java/modules/jibx/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jibx/project.xml?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/jibx/project.xml (original)
+++ webservices/axis2/trunk/java/modules/jibx/project.xml Mon Sep 11 02:33:11 2006
@@ -147,6 +147,14 @@
             <properties>
                 <module>true</module>
             </properties>
+        </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>${javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
         </dependency>
         <dependency>
             <groupId>jibx</groupId>

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Mon Sep
11 02:33:11 2006
@@ -225,6 +225,8 @@
         public static final String HTTP_METHOD_GET = "GET";
         public static final String HTTP_METHOD = "HTTP_METHOD";
         public static final String HTTP_METHOD_POST = "POST";
+        
+        public static final String ENABLE_SWA = "enableSwA";
 
         public static final String CONTENT_TYPE = "ContentType";
         public static final String IS_USING_SEPARATE_LISTENER = "IsUsingSeparateListener";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
Mon Sep 11 02:33:11 2006
@@ -16,7 +16,9 @@
 
 package org.apache.axis2.context;
 
+import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPConstants;
@@ -29,6 +31,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.ws.policy.Policy;
 
+import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -52,7 +55,7 @@
 
     public static final String TRANSPORT_HEADERS = "TRANSPORT_HEADERS";
     
-    public Map attachmentsMap = new HashMap();
+    public Attachments attachments = new Attachments();
 
     /**
      * Field TRANSPORT_OUT
@@ -129,6 +132,9 @@
 
     // Are we doing MTOM now?
     private boolean doingMTOM;
+    
+    // Are we doing SwA now?
+    private boolean doingSwA;
 
     private transient AxisMessage axisMessage;
 
@@ -621,6 +627,13 @@
     public boolean isDoingREST() {
         return doingREST;
     }
+    
+    /**
+     * @return Returns boolean.
+     */
+    public boolean isDoingSwA() {
+        return doingSwA;
+    }
 
     /**
      * @return Returns boolean.
@@ -723,6 +736,13 @@
     public void setDoingREST(boolean b) {
         doingREST = b;
     }
+    
+    /**
+     * @param b
+     */
+    public void setDoingSwA(boolean b) {
+        doingSwA = b;
+    }
 
     /**
      * @param envelope
@@ -1029,13 +1049,32 @@
         return true;
     }
     
-    public void setAttachment(String contentID, Object dataHandler)
-    {
-    	attachmentsMap.put(contentID,dataHandler);
-    }
+    /**
+	 * Setting of the attachments map should be performed at the receipt of a
+	 * message only. This method is only meant to be used by the Axis2
+	 * internals.
+	 * 
+	 * @param attachments
+	 */
+    public void setAttachmentMap(Attachments attachments) {
+		this.attachments = attachments;
+	}
     
-    public Object getAttachment(String contentID)
-    {
-    	return attachmentsMap.get(contentID);
+    public Attachments getAttachmentMap(){
+    	return attachments;
     }
+
+	public void addAttachment(String contentID, DataHandler dataHandler) {
+		attachments.addDataHandler(contentID, dataHandler);
+	}
+
+	public String addAttachment(DataHandler dataHandler) {
+		String contentID = UUIDGenerator.getUUID();
+		addAttachment(contentID, dataHandler);
+		return contentID;
+	}
+
+	public DataHandler getAttachment(String contentID) {
+		return attachments.getDataHandler(contentID);
+	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/AbstractTransportSender.java
Mon Sep 11 02:33:11 2006
@@ -76,6 +76,7 @@
         // Check for the REST behaviour, if you desire rest beahaviour
         // put a <parameter name="doREST" value="true"/> at the axis2.xml
         msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+        msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
 
         OutputStream out;
         EndpointReference epr = null;
@@ -147,6 +148,7 @@
                         (String) msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
 
                 format.setDoOptimize(msgContext.isDoingMTOM());
+                format.setDoingSWA(msgContext.isDoingSwA());
                 format.setCharSetEncoding(charSetEnc);
                 outputMessage.serializeAndConsume(out, format);
                 out.flush();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
Mon Sep 11 02:33:11 2006
@@ -240,8 +240,14 @@
 
         /*
         * put a reference to Attachments in to the message context
+        * Leaving this out for backword compatibility with 1.0
         */
         msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
+        
+        /*
+         * Setting the Attachments map to new SwA API
+         */
+        msgContext.setAttachmentMap(attachments);
 
         String soapEnvelopeNamespaceURI=null;
         if (contentTypeString.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Mon Sep 11 02:33:11 2006
@@ -19,6 +19,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.impl.MIMEOutputUtils;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.util.JavaUtils;
@@ -41,6 +42,7 @@
 import javax.xml.stream.XMLStreamException;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.net.URL;
 
@@ -160,9 +162,11 @@
             }
 
             msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
+            msgContext.setDoingSwA(HTTPTransportUtils.doWriteSwA(msgContext));
             msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
             format.setSOAP11(msgContext.isSOAP11());
             format.setDoOptimize(msgContext.isDoingMTOM());
+            format.setDoingSWA(msgContext.isDoingSwA());
             format.setCharSetEncoding(charSetEnc);
 
             // Trasnport URL can be different from the WSA-To. So processing
@@ -265,7 +269,16 @@
         }
 
         format.setDoOptimize(msgContext.isDoingMTOM());
-        dataOut.serializeAndConsume(out, format);
+		format.setDoingSWA(msgContext.isDoingSwA());
+		if (!(msgContext.isDoingMTOM()) & (msgContext.isDoingSwA())
+				& !(msgContext.isDoingREST())) {
+			StringWriter bufferedSOAPBody = new StringWriter();
+			dataOut.serializeAndConsume(bufferedSOAPBody, format);
+			MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,
+					out, msgContext.getAttachmentMap(), format);
+		} else {
+			dataOut.serializeAndConsume(out, format);
+		}
     }
 
     public void writeMessageWithCommons(MessageContext msgContext,

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
Mon Sep 11 02:33:11 2006
@@ -114,6 +114,21 @@
         }
         return enableMTOM;
     }
+    
+    public static boolean doWriteSwA(MessageContext msgContext) {
+        boolean enableSwA = false;
+
+        if (msgContext.getParameter(Constants.Configuration.ENABLE_SWA) != null) {
+            enableSwA = JavaUtils.isTrueExplicitly(
+                    msgContext.getParameter(Constants.Configuration.ENABLE_SWA).getValue());
+        }
+
+        if (msgContext.getProperty(Constants.Configuration.ENABLE_SWA) != null) {
+            enableSwA = JavaUtils.isTrueExplicitly(
+                    msgContext.getProperty(Constants.Configuration.ENABLE_SWA));
+        }
+        return enableSwA;
+    }
 
     public static boolean processHTTPGetRequest(MessageContext msgContext,
                                                 OutputStream out, String soapAction, String
requestURI,
@@ -179,7 +194,7 @@
             if (contentType != null) {
                 if (contentType.indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) >
-1) {
 
-                    // It is MTOM
+                    // It is MIME (MTOM or SwA)
                     builder = TransportUtils.selectBuilderForMIME(msgContext, in, contentType);
                     envelope = (SOAPEnvelope) builder.getDocumentElement();
                 } else {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
Mon Sep 11 02:33:11 2006
@@ -16,6 +16,17 @@
 
 package org.apache.axis2.transport.http;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.zip.GZIPOutputStream;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.MIMEOutputUtils;
@@ -23,9 +34,9 @@
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpStatus;
@@ -33,17 +44,6 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.zip.GZIPOutputStream;
-
 public class SOAPOverHTTPSender extends AbstractHTTPSender {
 
 
@@ -159,6 +159,7 @@
             this.chunked = chunked;
             this.msgCtxt = msgCtxt;
             this.doingMTOM = msgCtxt.isDoingMTOM();
+            this.doingSWA =  msgCtxt.isDoingSwA();
             this.charSetEnc = charSetEncoding;
             this.soapActionString = soapActionString;
         }
@@ -166,13 +167,27 @@
         private void handleOMOutput(OutputStream out, boolean doingMTOM)
                 throws XMLStreamException {
             format.setDoOptimize(doingMTOM);
-            // To support NTLM Authentication the following check has been done.
-            if (msgCtxt.getProperty(HTTPConstants.NTLM_AUTHENTICATION) != null)
-            {
-                element.serialize(out, format);
-            } else {
-                element.serializeAndConsume(out, format);
-            }
+			format.setDoingSWA(doingSWA);
+
+			if (!doingMTOM & doingSWA) {
+				 StringWriter bufferedSOAPBody = new StringWriter();
+				//To support NTLM Authentication the following check has been
+				// done.
+				if (msgCtxt.getProperty(HTTPConstants.NTLM_AUTHENTICATION) != null) {
+					element.serialize(bufferedSOAPBody, format);
+				} else {
+					element.serializeAndConsume(bufferedSOAPBody, format);
+				}
+				MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,out,msgCtxt.getAttachmentMap(),
format);
+			} else {
+				// To support NTLM Authentication the following check has been
+				// done.
+				if (msgCtxt.getProperty(HTTPConstants.NTLM_AUTHENTICATION) != null) {
+					element.serialize(out, format);
+				} else {
+					element.serializeAndConsume(out, format);
+				}
+			}
         }
 
         public byte[] writeBytes() throws AxisFault {
@@ -186,7 +201,7 @@
 					if (doingSWA) {
 			            StringWriter bufferedSOAPBody = new StringWriter();
 			            element.serializeAndConsume(bufferedSOAPBody,format2);
-						MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,bytesOut,new HashMap(),
format2);
+						MIMEOutputUtils.writeSOAPWithAttachmentsMessage(bufferedSOAPBody,bytesOut,msgCtxt.getAttachmentMap(),
format2);
 					} else {
 						element.serializeAndConsume(bytesOut, format2);
 					}

Modified: webservices/axis2/trunk/java/modules/savan/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/project.xml?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/project.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/project.xml Mon Sep 11 02:33:11 2006
@@ -111,6 +111,14 @@
             <properties>
                 <module>true</module>
             </properties>
+        </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>${javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
         </dependency>
         <dependency>
             <groupId>commons-httpclient</groupId>

Modified: webservices/axis2/trunk/java/modules/security/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/project.xml?view=diff&rev=442137&r1=442136&r2=442137
==============================================================================
--- webservices/axis2/trunk/java/modules/security/project.xml (original)
+++ webservices/axis2/trunk/java/modules/security/project.xml Mon Sep 11 02:33:11 2006
@@ -233,6 +233,14 @@
             <artifactId>XmlSchema</artifactId>
             <version>${XmlSchema.version}</version>
         </dependency>
+        <dependency>
+            <groupId>javax.mail</groupId>
+            <artifactId>mail</artifactId>
+            <version>${javamail.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
 	<!-- For WS-Policy support -->
 	<dependency>
 		<groupId>ws-commons</groupId>



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


Mime
View raw message