You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2008/03/26 14:30:06 UTC

svn commit: r641297 - in /webservices/axis2/trunk/java/modules: jaxws-integration/ jaxws-integration/test-resources/wsdl/ jaxws-integration/test/org/apache/axis2/jaxws/swamtom/ jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/ jaxws-integra...

Author: scheu
Date: Wed Mar 26 06:29:58 2008
New Revision: 641297

URL: http://svn.apache.org/viewvc?rev=641297&view=rev
Log:
AXIS2-3660
Contributor:Rich Scheuerle
Test Contributor: Dan Sedov
Make sure JAXWS can handle the scenario where the input is a SWA and the output is an SWA.
In this scenario the soapenv:Body is empty.

Added:
    webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/MANIFEST.MF
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Wed Mar 26 06:29:58 2008
@@ -395,6 +395,12 @@
                                     <classpath location="${compiled.classes.dir}"/>
                                     <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/rpclitstringarray.wsdl"/>
                                 </java>
+                                <echo>Generating java from swamtomservice.wsdl</echo>
+                                <java classname="com.sun.tools.xjc.Driver" fork="true">
+                                    <classpath refid="maven.runtime.classpath"/>
+                                    <classpath location="${compiled.classes.dir}"/>
+                                    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/swamtomservice.wsdl"/>
+                                </java>
                             </tasks>
                         </configuration>
                         <goals>
@@ -621,6 +627,21 @@
                                         />
                                 <delete dir="target/test-classes/servicejars/SOAP12Service"/>
 
+
+                               <copy toDir="target/test-classes/servicejars/SWAMTOMService/">
+                                    <fileset dir="target/test-classes">
+                                        <include name="org/apache/axis2/jaxws/swamtom/server/**"/>
+                                        <exclude name="org/apache/axis2/jaxws/swamtom/server/META-INF/services.xml"/>
+                                    </fileset>
+                                    <fileset dir="test/org/apache/axis2/jaxws/swamtom/server">
+                                        <include name="META-INF/**"/>
+                                        <exclude name="META-INF/services.xml"/>
+                                    </fileset>
+                                </copy>
+
+                                <zip destfile="target/test-classes/servicejars/SWAMTOMService.jar"
+                                     basedir="${pom.basedir}/target/test-classes/servicejars/SWAMTOMService"/>
+                                <delete dir="target/test-classes/servicejars/SWAMTOMService"/>
                                 <!-- ================================================================ -->
                                 <!--- Proxy endpoint Service Samples -->
                                 <!-- ================================================================ -->
@@ -1187,7 +1208,6 @@
                     <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006</argLine>-->
                     <includes>
 
-                        <!-- Possibly non-server tests -->
                         <include>**/MultiRedirectionCatalogTest.java</include>
                         <include>**/DispatchSoapActionTest.java</include>
                         <include>**/ProxySoapActionTest.java</include>
@@ -1196,8 +1216,6 @@
                         <include>**/ProxyMTOMFeatureTest.java</include>
                         <include>**/SOAP12DispatchTest.java</include>
                         <include>**/JAXBContextTest.java</include>
-
-                        <!-- Possible server tests -->
                         <include>**/StringProviderTests.java</include>
                         <include>**/SOAPFaultProviderTests.java</include>
                         <include>**/StringMessageProviderTests.java</include>
@@ -1254,6 +1272,7 @@
                         <include>**/NonWrapTests.java</include>
                         <include>**/FaultyWebServiceTests.java</include> 
                         <include>**/ParallelAsyncTests.java</include>
+                        <include>**/SWAMTOMTests.java</include>
                     </includes>
                     <systemProperties>
                         <property>

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl?rev=641297&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl Wed Mar 26 06:29:58 2008
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsdl:definitions
+	targetNamespace="http://swamtomservice.test.org"
+	xmlns="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+	xmlns:tns="http://swamtomservice.test.org"
+	xmlns:typens="http://swamtomservice.types.test.org"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	 <wsdl:types>
+		<xsd:schema
+			xmlns="http://www.w3.org/2001/XMLSchema"
+			xmlns:tns="http://swamtomservice.types.test.org"
+			targetNamespace="http://swamtomservice.types.test.org">
+
+		<element name="mtomAttachment" >
+			<complexType>
+				<sequence>
+					<element name="message" type="xsd:base64Binary" />
+				</sequence>
+			</complexType>
+		</element>
+
+		<element name="mtomAttachmentResponse" >
+			<complexType>
+				<sequence>
+					<element name="message" type="xsd:base64Binary" />
+				</sequence>
+			</complexType>
+		</element>
+		</xsd:schema>
+	</wsdl:types>
+
+
+  <!-- attachment ...note no body part-->
+  <wsdl:message name="swaAttachmentRequest">
+    <part name="jpegImageRequest" type="xsd:hexBinary"/>
+  </wsdl:message>
+  <wsdl:message name="swAattachmentResponse">
+    <part name="jpegImageResponse" type="xsd:hexBinary"/>
+  </wsdl:message>
+
+  
+
+   <!-- mtom -->
+
+  <wsdl:message name="mtomAttachmentRequest">
+    <part name="mtom_in" element="typens:mtom"/>
+  </wsdl:message>
+  <wsdl:message name="mtomAttachmentResponse">
+    <part name="mtom_out" element="typens:mtomResponse"/>
+  </wsdl:message>
+
+   <wsdl:portType name="SWAMTOMPortType">
+      
+      <wsdl:operation name="swaAttachment">
+         <wsdl:input message="tns:swaAttachmentRequest" />
+         <wsdl:output message="tns:swaAttachmentResponse" />
+      </wsdl:operation>
+      
+      <wsdl:operation name="mtomAttachment">
+         <wsdl:input message="tns:mtomAttachmentRequest" />
+
+         <wsdl:output message="tns:mtomAttachmentResponse" />
+
+      </wsdl:operation>
+   </wsdl:portType>
+
+   <wsdl:binding name="SWAMTOMBinding" type="tns:SWAMTOMPortType">
+      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+      <wsdl:operation name="swaAttachment">
+        <wsdlsoap:operation soapAction="swaAttachment"/>
+        <wsdl:input >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+
+            <mime:part>
+              <mime:content part="jpegImageRequest" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:input>
+        <wsdl:output >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImageResponse" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:output>
+      </wsdl:operation>
+
+      <wsdl:operation name="mtomAttachment">
+         <wsdlsoap:operation soapAction="mtomAttachment"/>
+         <wsdl:input>
+            <wsdlsoap:body use="literal"/>
+         </wsdl:input>
+         <wsdl:output >
+            <wsdlsoap:body use="literal"/>
+         </wsdl:output>
+      </wsdl:operation>
+   </wsdl:binding>
+
+   <wsdl:service name="SWAMTOMService">
+     <wsdl:port name="SWAMTOMPortTypePort" binding="tns:SWAMTOMBinding">
+        <wsdlsoap:address location="http://@HOST@:@PORT@/jaxws.swamtom/services/SWAMTOMService" />
+     </wsdl:port>
+   </wsdl:service>
+          
+</wsdl:definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java?rev=641297&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java Wed Mar 26 06:29:58 2008
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */package org.apache.axis2.jaxws.swamtom;
+
+import org.apache.axis2.jaxws.framework.AbstractTestCase;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import java.io.ByteArrayInputStream;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests calling an endpoint that has one operation that
+ * uses an MTOM attachment and another operation that uses a SWA
+ * attachment.
+ */
+public class SWAMTOMTests extends AbstractTestCase {
+    private static final QName QNAME_SERVICE = new QName("http://swamtomservice.test.org", 
+                                                         "SWAMTOMService");
+    private static final QName QNAME_PORT    = new QName("http://swamtomservice.test.org", 
+                                                         "SWAMTOMPortTypePort");
+    private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/SWAMTOMService.SWAMTOMPortTypePort";
+    
+    public static Test suite() {
+        return getTestSetup(new TestSuite(SWAMTOMTests.class));
+    }
+    
+    public Dispatch<SOAPMessage> getDispatch(String soapAction) {
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+        Dispatch<SOAPMessage> dispatch = service.createDispatch(QNAME_PORT,
+                                                                SOAPMessage.class,
+                                                                Service.Mode.MESSAGE);
+        BindingProvider p = (BindingProvider) dispatch;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, URL_ENDPOINT);
+        p.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+        p.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction);
+        
+        return dispatch;
+    }
+    
+    /**
+     * Tests calling an endpoint that understands SOAP 1.1 MTOM
+     * However we are calling an operation on the endpoint that 
+     * pass a single SWA attachment as a request and expects a 
+     * single SWA attachment as a response.  (The body contents are empty.)
+     * 
+     * This test accomplishes the following:
+     *   - ensures that a SWA attachment (not an MTOM attachment) is sent.
+     *   - ensures that a SWA attachment can be sent and returned from 
+     *     an endpoint that has MTOM enabled.
+     *   - ensures that the DBC correctly marks the operation and parameters
+     *     such that all of the parameters to this operation are mapped
+     *     to SWA attachments.
+     *   - ensures that the marshalling code can handle the case of an 
+     *     empty soap body and all communication via SWA attachments.
+     * @throws Exception
+     */
+    public void testSWAAttachments() throws Exception {
+        String soapAction = "swaAttachment";
+        Dispatch<SOAPMessage> dispatch = getDispatch(soapAction);
+
+        // Obtain a preconfigured SAAJ MessageFactory
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage request = factory.createMessage();
+
+        // soap:body should be empty
+        SOAPBody body = request.getSOAPBody();
+
+        // add attachment
+        int attachmentSize = 100;
+        byte[] bytes = new byte[attachmentSize];
+
+        for (int i = 0; i < bytes.length; i++) {
+            bytes[i] = (byte) ('a' + ('z' - 'a') * Math.random());
+        }
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        AttachmentPart attachment = request.createAttachmentPart();
+        attachment.setContentId("SWAMTOMTestSOAPMessage");
+        attachment.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
+        attachment.setRawContent(bais, "text/plain");
+        request.addAttachmentPart(attachment);
+
+        // invoke
+        SOAPMessage reply = dispatch.invoke(request);
+
+        // iterate over the attachments, there should only be one
+        Iterator it = reply.getAttachments();
+        AttachmentPart ap = null;
+
+        // verify that the attachment is not null or empty
+        if ((ap = (AttachmentPart) it.next()) == null){
+            fail("Attachment is null");
+        }
+
+        // verify that the attachment is not null or empty
+        if (it.hasNext()){
+            fail("Detected more then 1 attachment");
+        }
+
+        SOAPBody sb = reply.getSOAPBody();
+        if (sb.getChildElements().hasNext()) {
+            fail("Message contains soap:body payload");
+        }
+
+        bytes = ap.getRawContentBytes();
+        if (bytes.length == 0) { 
+            fail("Attachment is empty"); 
+        }
+
+        // verify that endpoint has been able to modify the attachment
+        if (bytes[0] != 'S' || bytes[1] != 'W' || bytes[2] != 'A') { 
+            fail("Did not receive a modified attachment"); 
+        }
+    }
+    
+    // TODO:  Add similar code to invoke the mtom enabled operation
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/MANIFEST.MF?rev=641297&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/MANIFEST.MF (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/MANIFEST.MF Wed Mar 26 06:29:58 2008
@@ -0,0 +1 @@
+Manifest-Version: 1.0

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl?rev=641297&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl Wed Mar 26 06:29:58 2008
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsdl:definitions
+	targetNamespace="http://swamtomservice.test.org"
+	xmlns="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+	xmlns:tns="http://swamtomservice.test.org"
+	xmlns:typens="http://swamtomservice.types.test.org"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	 <wsdl:types>
+		<xsd:schema
+		  xmlns="http://www.w3.org/2001/XMLSchema"
+		  xmlns:tns="http://swamtomservice.types.test.org"
+		  targetNamespace="http://swamtomservice.types.test.org">
+
+		<element name="mtomAttachment" >
+			<complexType>
+				<sequence>
+					<element name="message" type="xsd:base64Binary" />
+				</sequence>
+			</complexType>
+		</element>
+
+		<element name="mtomAttachmentResponse" >
+			<complexType>
+				<sequence>
+					<element name="message" type="xsd:base64Binary" />
+				</sequence>
+			</complexType>
+		</element>
+		</xsd:schema>
+	</wsdl:types>
+
+
+  <!-- attachment...note no body part -->
+  <wsdl:message name="swaAttachmentRequest">
+    <part name="jpegImageRequest" type="xsd:hexBinary"/>
+  </wsdl:message>
+  <wsdl:message name="swAattachmentResponse">
+    <part name="jpegImageResponse" type="xsd:hexBinary"/>
+  </wsdl:message>
+
+  
+
+   <!-- mtom -->
+
+  <wsdl:message name="mtomAttachmentRequest">
+    <part name="mtom_in" element="typens:mtom"/>
+  </wsdl:message>
+  <wsdl:message name="mtomAttachmentResponse">
+    <part name="mtom_out" element="typens:mtomResponse"/>
+  </wsdl:message>
+
+   <wsdl:portType name="SWAMTOMPortType">
+      
+      <wsdl:operation name="swaAttachment">
+         <wsdl:input message="tns:swaAttachmentRequest" />
+         <wsdl:output message="tns:swaAttachmentResponse" />
+      </wsdl:operation>
+      
+      <wsdl:operation name="mtomAttachment">
+         <wsdl:input message="tns:mtomAttachmentRequest" />
+
+         <wsdl:output message="tns:mtomAttachmentResponse" />
+
+      </wsdl:operation>
+   </wsdl:portType>
+
+   <wsdl:binding name="SWAMTOMBinding" type="tns:SWAMTOMPortType">
+      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+      <wsdl:operation name="swaAttachment">
+        <wsdlsoap:operation soapAction="swaAttachment"/>
+        <wsdl:input >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+
+            <mime:part>
+              <mime:content part="jpegImageRequest" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:input>
+        <wsdl:output >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImageResponse" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:output>
+      </wsdl:operation>
+
+      <wsdl:operation name="mtomAttachment">
+         <wsdlsoap:operation soapAction="mtomAttachment"/>
+         <wsdl:input>
+            <wsdlsoap:body use="literal"/>
+         </wsdl:input>
+         <wsdl:output >
+            <wsdlsoap:body use="literal"/>
+         </wsdl:output>
+      </wsdl:operation>
+   </wsdl:binding>
+
+   <wsdl:service name="SWAMTOMService">
+     <wsdl:port name="SWAMTOMPortTypePort" binding="tns:SWAMTOMBinding">
+        <wsdlsoap:address location="http://@HOST@:@PORT@/jaxws.swamtom/services/SWAMTOMService" />
+     </wsdl:port>
+   </wsdl:service>
+          
+</wsdl:definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java?rev=641297&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java Wed Mar 26 06:29:58 2008
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.swamtom.server;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Holder;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+
+/**
+ * Endpont that is a SOAP 1.1 MTOM Binding 
+ * but has an operation (swaAttachment) that passes
+ * SWA attachments
+ *
+ */
+@WebService(name="SWAMTOMPortType",
+            serviceName="SWAMTOMService", 
+            wsdlLocation="META-INF/swamtomservice.wsdl", 
+            targetNamespace="http://swamtomservice.test.org")
+@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+public class SWAMTOMPortTypeImpl {
+
+    /**
+     * This method passes an SWA attachment as a request
+     * and expects an SWA attachment as a response.
+     * Note that the body content in both cases is empty.
+     * (See the wsdl)
+     * @param attachment (swa)
+     * @return attachment (swa)
+     */
+    @WebMethod(operationName="swaAttachment", action="swaAttachment")
+    @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+    @WebResult(name = "jpegImageResponse", targetNamespace = "", partName = "jpegImageResponse")
+    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+    public byte[] swaAttachment(
+          @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+          @WebParam(name = "jpegImageRequest", targetNamespace = "", partName = "jpegImageRequest")
+          byte[] attachment) {
+        if (attachment == null || attachment.length == 0){
+            throw new RuntimeException("Received empty attachment");
+        } else {
+            // Change the first three characters and return the attachment
+            attachment[0] = 'S';
+            attachment[1] = 'W';
+            attachment[2] = 'A';
+        }
+        return attachment;
+    }
+    
+    @WebMethod(operationName="mtomAttachment", action="mtomAttachment")
+    @SOAPBinding(parameterStyle=ParameterStyle.BARE)
+    public void mtomAttachment(Holder<byte[]> message) {
+
+        byte[] attachment = message.value;
+
+        if (attachment == null || attachment.length == 0){
+            throw new RuntimeException("Received empty mtom attachment");
+        } else {
+            // Change the first characters
+            attachment[0] = 'X';
+            attachment[1] = 'O';
+            attachment[2] = 'P';
+        }
+
+        message.value = attachment;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java Wed Mar 26 06:29:58 2008
@@ -20,10 +20,13 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.description.AttachmentDescription;
+import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.description.ParameterDescription;
+import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
@@ -83,26 +86,38 @@
             Object returnValue = null;
             boolean hasReturnInBody = false;
             if (returnType != void.class) {
-                // If the webresult is in the header, we need the name of the header so that we can find it.
-                Element returnElement = null;
-                if (operationDesc.isResultHeader()) {
-                    returnElement =
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                       String cid = message.getAttachmentID(0);
+                       returnValue = message.getDataHandler(cid);
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
+                } else {
+                    // If the webresult is in the header, we need the name of the header so that we can find it.
+                    Element returnElement = null;
+                    if (operationDesc.isResultHeader()) {
+                        returnElement =
                             MethodMarshallerUtils.getReturnElement(packages, message, null, false, true,
                                                                    operationDesc.getResultTargetNamespace(),
                                                                    operationDesc.getResultName(),
                                                                    MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
 
-                } else {
-                    returnElement = MethodMarshallerUtils
-                            .getReturnElement(packages, message, null, false, false, null, null,
-                                    MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
-                    hasReturnInBody = true;
+                    } else {
+                        returnElement = MethodMarshallerUtils
+                        .getReturnElement(packages, message, null, false, false, null, null,
+                                          MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
+                        hasReturnInBody = true;
+                    }
+                    returnValue = returnElement.getTypeValue();
+                    
                 }
-                returnValue = returnElement.getTypeValue();
                 if (ConvertUtils.isConvertable(returnValue, returnType)) {
-                	returnValue = ConvertUtils.convert(returnValue, returnType);
-                }
-                
+                    returnValue = ConvertUtils.convert(returnValue, returnType);
+                }              
             }
 
             // Unmarshall the ParamValues from the Message
@@ -209,36 +224,53 @@
             // Put the return object onto the message
             Class returnType = operationDesc.getResultActualType();
             if (returnType != void.class) {
-                Element returnElement = null;
-                QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
-                                              operationDesc.getResultName());
-                if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
-                    returnElement = new Element(returnObject, returnQName);
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                        // Create an Attachment object with the signature value
+                        Attachment attachment = new Attachment(returnObject, 
+                                                               returnType, 
+                                                               attachmentDesc);  
+                        m.addDataHandler(attachment.getDataHandler(), 
+                                         attachment.getContentID());
+                        m.setDoingSWA(true);
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
                 } else {
-                    /* when a schema defines a SimpleType with xsd list jaxws tooling generates art-effects with array rather than a java.util.List
-                     * However the ObjectFactory definition uses a List and thus marshalling fails. Lets convert the Arrays to List.
-                     */
-                    if(operationDesc.isListType()){
-                       List list= new ArrayList();
-                       if(returnType.isArray()){
-                            for(int count = 0; count < Array.getLength(returnObject); count++){
-                                Object obj = Array.get(returnObject, count);
-                                list.add(obj);
+                    Element returnElement = null;
+                    QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
+                                                  operationDesc.getResultName());
+                    if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
+                        returnElement = new Element(returnObject, returnQName);
+                    } else {
+                        /* when a schema defines a SimpleType with xsd list jaxws tooling generates art-effects with array rather than a java.util.List
+                         * However the ObjectFactory definition uses a List and thus marshalling fails. Lets convert the Arrays to List.
+                         */
+                        if(operationDesc.isListType()){
+                            List list= new ArrayList();
+                            if(returnType.isArray()){
+                                for(int count = 0; count < Array.getLength(returnObject); count++){
+                                    Object obj = Array.get(returnObject, count);
+                                    list.add(obj);
+                                }
+                                returnElement = new Element(list, returnQName, List.class);
                             }
-                            returnElement = new Element(list, returnQName, List.class);
                         }
-                      }
-                    else{
-                        returnElement = new Element(returnObject, returnQName, returnType);
+                        else{
+                            returnElement = new Element(returnObject, returnQName, returnType);
+                        }
                     }
+                    MethodMarshallerUtils.toMessage(returnElement, 
+                                                    returnType,
+                                                    operationDesc.isListType(),
+                                                    marshalDesc, 
+                                                    m,
+                                                    null, // always marshal using "by element" mode
+                                                    operationDesc.isResultHeader());
                 }
-                MethodMarshallerUtils.toMessage(returnElement, 
-                								returnType,
-                								operationDesc.isListType(),
-                                                marshalDesc, 
-                                                m,
-                                                null, // always marshal using "by element" mode
-                                                operationDesc.isResultHeader());
             }
 
             // Convert the holder objects into a list of JAXB objects for marshalling

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMinimalMethodMarshaller.java Wed Mar 26 06:29:58 2008
@@ -20,10 +20,13 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.description.AttachmentDescription;
+import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.description.ParameterDescription;
+import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
@@ -86,33 +89,45 @@
             Object returnValue = null;
             boolean hasReturnInBody = false;
             if (returnType != void.class) {
-                // Use "byJavaType" unmarshalling if necessary
-                Class byJavaType = null;
-                if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
-                    byJavaType = returnType;
-                }
-                // If the webresult is in the header, we need the name of the header so that we can find it.
-                Element returnElement = null;
-                if (operationDesc.isResultHeader()) {
-                    returnElement = MethodMarshallerUtils
-                            .getReturnElement(packages, message, byJavaType, operationDesc.isListType(), true,
-                                              operationDesc.getResultTargetNamespace(),
-                                              operationDesc.getResultName(),
-                                              MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
-
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                       String cid = message.getAttachmentID(0);
+                       returnValue = message.getDataHandler(cid);
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
                 } else {
-                    returnElement = MethodMarshallerUtils
-                            .getReturnElement(packages, message, byJavaType, operationDesc.isListType(), false, null, null,
-                                    MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
-                    hasReturnInBody = true;
+                    // Use "byJavaType" unmarshalling if necessary
+                    Class byJavaType = null;
+                    if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
+                        byJavaType = returnType;
+                    }
+                    // If the webresult is in the header, we need the name of the header so that we can find it.
+                    Element returnElement = null;
+                    if (operationDesc.isResultHeader()) {
+                        returnElement = MethodMarshallerUtils
+                        .getReturnElement(packages, message, byJavaType, operationDesc.isListType(), true,
+                                          operationDesc.getResultTargetNamespace(),
+                                          operationDesc.getResultName(),
+                                          MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
+
+                    } else {
+                        returnElement = MethodMarshallerUtils
+                        .getReturnElement(packages, message, byJavaType, operationDesc.isListType(), false, null, null,
+                                          MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
+                        hasReturnInBody = true;
+                    }
+                    //TODO should we allow null if the return is a header?
+                    //Validate input parameters for operation and make sure no input parameters are null.
+                    //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
+                    //to a method then an implementation MUST throw WebServiceException.
+                    returnValue = returnElement.getTypeValue();
                 }
-                //TODO should we allow null if the return is a header?
-                //Validate input parameters for operation and make sure no input parameters are null.
-                //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
-                //to a method then an implementation MUST throw WebServiceException.
-                returnValue = returnElement.getTypeValue();
                 if (ConvertUtils.isConvertable(returnValue, returnType)) {
-                	returnValue = ConvertUtils.convert(returnValue, returnType);
+                    returnValue = ConvertUtils.convert(returnValue, returnType);
                 }               
             }
 
@@ -242,25 +257,43 @@
             // Put the return object onto the message
             Class returnType = operationDesc.getResultActualType();
             if (returnType != void.class) {
-
-                // Use byJavaType marshalling if necessary
-                Class byJavaType = null;
-                if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
-                    byJavaType = returnType;
-                }
-
-                Element returnElement = null;
-                QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
-                                              operationDesc.getResultName());
-                if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
-                    returnElement = new Element(returnObject, returnQName);
+                
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                        // Create an Attachment object with the signature value
+                        Attachment attachment = new Attachment(returnObject, 
+                                                               returnType, 
+                                                               attachmentDesc);  
+                        m.addDataHandler(attachment.getDataHandler(), 
+                                         attachment.getContentID());
+                        m.setDoingSWA(true);
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
                 } else {
-                    returnElement = new Element(returnObject, returnQName, returnType);
+
+                    // Use byJavaType marshalling if necessary
+                    Class byJavaType = null;
+                    if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
+                        byJavaType = returnType;
+                    }
+
+                    Element returnElement = null;
+                    QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
+                                                  operationDesc.getResultName());
+                    if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
+                        returnElement = new Element(returnObject, returnQName);
+                    } else {
+                        returnElement = new Element(returnObject, returnQName, returnType);
+                    }
+                    MethodMarshallerUtils.toMessage(returnElement, returnType, operationDesc.isListType(),
+                                                    marshalDesc, m,
+                                                    byJavaType,
+                                                    operationDesc.isResultHeader());
                 }
-                MethodMarshallerUtils.toMessage(returnElement, returnType, operationDesc.isListType(),
-                                                marshalDesc, m,
-                                                byJavaType,
-                                                operationDesc.isResultHeader());
             }
 
             // Convert the holder objects into a list of JAXB objects for marshalling

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java Wed Mar 26 06:29:58 2008
@@ -20,6 +20,8 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.description.AttachmentDescription;
+import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
@@ -31,6 +33,7 @@
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.runtime.description.marshal.MarshalServiceRuntimeDescription;
+import org.apache.axis2.jaxws.utility.ConvertUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -299,36 +302,53 @@
 
             if (returnType != void.class) {
 
-                // TODO should we allow null if the return is a header?
-                //Validate input parameters for operation and make sure no input parameters are null.
-                //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
-                //to a method then an implementation MUST throw WebServiceException.
-                if (returnObject == null) {
-                	throw ExceptionFactory.makeWebServiceException(
-                    		Messages.getMessage("NullParamErr3",operationDesc.getJavaMethodName()));
-
-                }
-                Element returnElement = null;
-                QName returnQName = new QName(returnNS, returnLocalPart);
-                if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
-                    returnElement = new Element(returnObject, returnQName);
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                        // Create an Attachment object with the signature value
+                        Attachment attachment = new Attachment(returnObject, 
+                                                               returnType, 
+                                                               attachmentDesc);  
+                        m.addDataHandler(attachment.getDataHandler(), 
+                                         attachment.getContentID());
+                        m.setDoingSWA(true);
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
                 } else {
-                    returnElement = new Element(returnObject, returnQName, returnType);
-                }
+                    // TODO should we allow null if the return is a header?
+                    //Validate input parameters for operation and make sure no input parameters are null.
+                    //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
+                    //to a method then an implementation MUST throw WebServiceException.
+                    if (returnObject == null) {
+                        throw ExceptionFactory.makeWebServiceException(
+                                                                       Messages.getMessage("NullParamErr3",operationDesc.getJavaMethodName()));
 
-                // Use marshalling by java type if necessary
-                Class byJavaType = null;
-                if (!operationDesc.isResultHeader() ||
-                        MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
-                    byJavaType = returnType;
+                    }
+                    Element returnElement = null;
+                    QName returnQName = new QName(returnNS, returnLocalPart);
+                    if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
+                        returnElement = new Element(returnObject, returnQName);
+                    } else {
+                        returnElement = new Element(returnObject, returnQName, returnType);
+                    }
+
+                    // Use marshalling by java type if necessary
+                    Class byJavaType = null;
+                    if (!operationDesc.isResultHeader() ||
+                            MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
+                        byJavaType = returnType;
+                    }
+                    MethodMarshallerUtils.toMessage(returnElement,
+                                                    returnType,
+                                                    operationDesc.isListType(),
+                                                    marshalDesc,
+                                                    m,
+                                                    byJavaType,
+                                                    operationDesc.isResultHeader());
                 }
-                MethodMarshallerUtils.toMessage(returnElement,
-                                                returnType,
-                                                operationDesc.isListType(),
-                                                marshalDesc,
-                                                m,
-                                                byJavaType,
-                                                operationDesc.isResultHeader());
             }
 
             // Convert the holder objects into a list of JAXB objects for marshalling
@@ -408,36 +428,51 @@
             Object returnValue = null;
             boolean hasReturnInBody = false;
             if (returnType != void.class) {
-                // If the webresult is in the header, we need the name of the header so that we can find it.
-                Element returnElement = null;
-                // Use "byJavaType" unmarshalling if necessary
-                Class byJavaType = null;
-                if (!operationDesc.isResultHeader() ||
-                        MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
-                    byJavaType = returnType;
-                }
-                if (operationDesc.isResultHeader()) {
-                    returnElement = MethodMarshallerUtils
-                            .getReturnElement(packages, message, byJavaType,  operationDesc.isListType(), true,
-                                              operationDesc.getResultTargetNamespace(),
-                                              operationDesc.getResultPartName(),
-                                              MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
-
+                AttachmentDescription attachmentDesc = 
+                    operationDesc.getResultAttachmentDescription();
+                if (attachmentDesc != null) {
+                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
+                       String cid = message.getAttachmentID(0);
+                       returnValue = message.getDataHandler(cid);
+                       if (ConvertUtils.isConvertable(returnValue, returnType)) {
+                           returnValue = ConvertUtils.convert(returnValue, returnType);
+                       } 
+                    } else {
+                        throw ExceptionFactory.
+                          makeWebServiceException(Messages.getMessage("pdElementErr"));
+                    }
                 } else {
-                    returnElement = MethodMarshallerUtils
-                            .getReturnElement(packages, message, byJavaType,  operationDesc.isListType(), false, null, null,
-                                    MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
-                    hasReturnInBody = true;
-                }
-                returnValue = returnElement.getTypeValue();
-                // TODO should we allow null if the return is a header?
-                //Validate input parameters for operation and make sure no input parameters are null.
-                //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
-                //to a method then an implementation MUST throw WebServiceException.
-                if (returnValue == null) {
-                	throw ExceptionFactory.makeWebServiceException(
-                    		Messages.getMessage("NullParamErr3",operationDesc.getJavaMethodName()));
-                }
+                    // If the webresult is in the header, we need the name of the header so that we can find it.
+                    Element returnElement = null;
+                    // Use "byJavaType" unmarshalling if necessary
+                    Class byJavaType = null;
+                    if (!operationDesc.isResultHeader() ||
+                            MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
+                        byJavaType = returnType;
+                    }
+                    if (operationDesc.isResultHeader()) {
+                        returnElement = MethodMarshallerUtils
+                        .getReturnElement(packages, message, byJavaType,  operationDesc.isListType(), true,
+                                          operationDesc.getResultTargetNamespace(),
+                                          operationDesc.getResultPartName(),
+                                          MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
+
+                    } else {
+                        returnElement = MethodMarshallerUtils
+                        .getReturnElement(packages, message, byJavaType,  operationDesc.isListType(), false, null, null,
+                                          MethodMarshallerUtils.numOutputBodyParams(pds) > 0);
+                        hasReturnInBody = true;
+                    }
+                    returnValue = returnElement.getTypeValue();
+                    // TODO should we allow null if the return is a header?
+                    //Validate input parameters for operation and make sure no input parameters are null.
+                    //As per JAXWS Specification section 3.6.2.3 if a null value is passes as an argument 
+                    //to a method then an implementation MUST throw WebServiceException.
+                    if (returnValue == null) {
+                        throw ExceptionFactory.makeWebServiceException(
+                                                                       Messages.getMessage("NullParamErr3",operationDesc.getJavaMethodName()));
+                    }
+                }  
             }
 
             // We want to use "by Java Type" unmarshalling for 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java Wed Mar 26 06:29:58 2008
@@ -498,7 +498,8 @@
      * @return true if the binding for this message indicates mtom
      */
     public boolean isMTOMEnabled() {
-        return mtomEnabled;
+        // If the message has SWA attachments, this "wins" over the mtom setting.
+        return mtomEnabled && !doingSWA;
     }
     
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java?rev=641297&r1=641296&r2=641297&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java Wed Mar 26 06:29:58 2008
@@ -308,15 +308,19 @@
         response.setMessage(m);
         
         // Enable MTOM for the response if necessary.
-        EndpointDescription epDesc = request.getEndpointDescription();
+        // (MTOM is not enabled it this operation has SWA parameters
+        
+        if (m.isDoingSWA()) {
+            EndpointDescription epDesc = request.getEndpointDescription();
 
-        String bindingType = epDesc.getBindingType();
-        if (bindingType != null) {
-            if (BindingUtils.isMTOMBinding(bindingType)) {
-                if (log.isDebugEnabled()) {
-                    log.debug("MTOM enabled for the response message.");
+            String bindingType = epDesc.getBindingType();
+            if (bindingType != null) {
+                if (BindingUtils.isMTOMBinding(bindingType)) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("MTOM enabled for the response message.");
+                    }
+                    m.setMTOMEnabled(true);
                 }
-                m.setMTOMEnabled(true);
             }
         }
         



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