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/04/16 02:29:44 UTC

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

Author: scheu
Date: Tue Apr 15 17:29:43 2008
New Revision: 648471

URL: http://svn.apache.org/viewvc?rev=648471&view=rev
Log:
AXIS2-3743
Contributor:Rich Scheuerle
Changed JAXWS code to ensure that SWA attachment CIDs are compliant with the WS-I Basic Profile.
If multiple SWA attachments are included in the message, the receiver uses the wsdl:partName to 
make sure the attachments are assigned to the correct part.
Added validation tests in the jaxws-integration module.

Modified:
    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/SWAMTOMTests.java
    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
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/Attachment.java
    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/MethodMarshallerUtils.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/Message.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java

Modified: 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=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test-resources/wsdl/swamtomservice.wsdl Tue Apr 15 17:29:43 2008
@@ -28,9 +28,9 @@
 	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">
+		  xmlns="http://www.w3.org/2001/XMLSchema"
+		  xmlns:tns="http://swamtomservice.types.test.org"
+		  targetNamespace="http://swamtomservice.types.test.org">
 
 		<element name="mtomAttachment" >
 			<complexType>
@@ -51,15 +51,25 @@
 	</wsdl:types>
 
 
-  <!-- attachment ...note no body part-->
+  <!-- attachment...note no body part -->
   <wsdl:message name="swaAttachmentRequest">
     <part name="jpegImageRequest" type="xsd:hexBinary"/>
   </wsdl:message>
-  <wsdl:message name="swAattachmentResponse">
+  <wsdl:message name="swaAttachmentResponse">
     <part name="jpegImageResponse" type="xsd:hexBinary"/>
   </wsdl:message>
 
   
+  <!-- two attachments...and no body part -->
+  <wsdl:message name="swaAttachment2Request">
+    <part name="jpegImage1Request" type="xsd:hexBinary"/>
+    <part name="jpegImage2Request" type="xsd:hexBinary"/>
+  </wsdl:message>
+  <wsdl:message name="swaAttachment2Response">
+    <part name="jpegImage1Response" type="xsd:hexBinary"/>
+    <part name="jpegImage2Response" type="xsd:hexBinary"/>
+  </wsdl:message>
+  
 
    <!-- mtom -->
 
@@ -77,6 +87,11 @@
          <wsdl:output message="tns:swaAttachmentResponse" />
       </wsdl:operation>
       
+      <wsdl:operation name="swaAttachment2">
+         <wsdl:input message="tns:swaAttachment2Request" />
+         <wsdl:output message="tns:swaAttachment2Response" />
+      </wsdl:operation>
+      
       <wsdl:operation name="mtomAttachment">
          <wsdl:input message="tns:mtomAttachmentRequest" />
 
@@ -107,6 +122,37 @@
             </mime:part>
             <mime:part>
               <mime:content part="jpegImageResponse" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:output>
+      </wsdl:operation>
+      
+      <wsdl:operation name="swaAttachment2">
+        <wsdlsoap:operation soapAction="swaAttachment2"/>
+        <wsdl:input >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+
+            <mime:part>
+              <mime:content part="jpegImage1Request" type="text/plain"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImage2Request" 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="jpegImage1Response" type="text/plain"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImage2Response" type="text/plain"/>
             </mime:part>
           </mime:multipartRelated>
         </wsdl:output>

Modified: 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=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/SWAMTOMTests.java Tue Apr 15 17:29:43 2008
@@ -80,9 +80,11 @@
      *     to SWA attachments.
      *   - ensures that the marshalling code can handle the case of an 
      *     empty soap body and all communication via SWA attachments.
+     *     
+     * This test ensures that the toleration of the attachments with legacy (pre WS-I 1.0) content ids.
      * @throws Exception
      */
-    public void testSWAAttachments() throws Exception {
+    public void testSWAAttachments_LegacyContentID() throws Exception {
         String soapAction = "swaAttachment";
         Dispatch<SOAPMessage> dispatch = getDispatch(soapAction);
 
@@ -103,6 +105,8 @@
 
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         AttachmentPart attachment = request.createAttachmentPart();
+        // Per WSI Spect, the swa content id must start with the part name
+        //http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html#Value-space_of_Content-Id_Header
         attachment.setContentId("SWAMTOMTestSOAPMessage");
         attachment.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
         attachment.setRawContent(bais, "text/plain");
@@ -119,6 +123,7 @@
         if ((ap = (AttachmentPart) it.next()) == null){
             fail("Attachment is null");
         }
+        
 
         // verify that the attachment is not null or empty
         if (it.hasNext()){
@@ -141,5 +146,276 @@
         }
     }
     
+    /**
+     * 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.
+     *     
+     * This test ensures that the endpoint can receive and return compliant (pre WS-I 1.0) content ids.
+     * @throws Exception
+     */
+    public void testSWAAttachments_WSI() 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();
+        // Per WSI Spect, the swa content id must start with the part name
+        //http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html#Value-space_of_Content-Id_Header
+        attachment.setContentId("jpegImageRequest=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");
+        }
+        
+        // Make sure the content id starts with the appropriate SWA name
+        if (!ap.getContentId().startsWith("jpegImageResponse=")) {
+            fail("Expected content id to start with jpegImageResponse");
+        }
+
+        // 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"); 
+        }
+    }
+    
+    /**
+     * Now invoke the message the a receives and returns 2 attachments
+     * 
+     * @throws Exception
+     */
+    public void testSWAAttachments2_WSI() throws Exception {
+        String soapAction = "swaAttachment2";
+        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();
+
+        // create attachments 1 and 2
+        byte[] bytes1 = new byte[1];
+        bytes1[0] = '1';
+        byte[] bytes2 = new byte[1];
+        bytes2[0] = '2';
+
+        // The attachments are sent out of order.
+        // The receiver should be smart enough to use the content id
+        // to establish the correct order
+        ByteArrayInputStream bais2 = new ByteArrayInputStream(bytes2);
+        AttachmentPart attachment2 = request.createAttachmentPart();
+        attachment2.setContentId("jpegImage2Request=SWAMTOMTestSOAPMessage");
+        attachment2.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
+        attachment2.setRawContent(bais2, "text/plain");
+        request.addAttachmentPart(attachment2);
+        
+        ByteArrayInputStream bais1 = new ByteArrayInputStream(bytes1);
+        AttachmentPart attachment1 = request.createAttachmentPart();
+        attachment1.setContentId("jpegImage1Request=SWAMTOMTestSOAPMessage");
+        attachment1.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
+        attachment1.setRawContent(bais1, "text/plain");
+        request.addAttachmentPart(attachment1);
+
+        // invoke
+        SOAPMessage reply = dispatch.invoke(request);
+
+        // iterate over the attachments, there should only be one
+        Iterator it = reply.getAttachments();
+        AttachmentPart ap3 = null;
+
+        // verify that the attachment is not null or empty
+        if ((ap3 = (AttachmentPart) it.next()) == null){
+            fail("Attachment is null");
+        }
+        
+        // Make sure the content id starts with the appropriate SWA name
+        if (!ap3.getContentId().startsWith("jpegImage1Response=")) {
+            fail("Expected content id to start with jpegImage1Response");
+        }
+        
+        AttachmentPart ap4 = null;
+        // verify that the second attachment is not null or empty
+        if ((ap4 = (AttachmentPart) it.next()) == null){
+            fail("Attachment is null");
+        }
+        
+        // Make sure the content id starts with the appropriate SWA name
+        if (!ap4.getContentId().startsWith("jpegImage2Response=")) {
+            fail("Expected content id to start with jpegImage2Response");
+        }
+
+        if (it.hasNext()){
+            fail("Detected more then 2 attachment");
+        }
+
+        SOAPBody sb = reply.getSOAPBody();
+        if (sb.getChildElements().hasNext()) {
+            fail("Message contains soap:body payload");
+        }
+
+        byte[] bytes3 = ap3.getRawContentBytes();
+        if (bytes3.length == 0) { 
+            fail("Attachment is empty"); 
+        }
+        if (bytes3[0] != '3') { 
+            fail("The response attachment is not correct"); 
+        }
+        
+        byte[] bytes4 = ap4.getRawContentBytes();
+        if (bytes4.length == 0) { 
+            fail("Attachment is empty"); 
+        }
+        if (bytes4[0] != '4') { 
+            fail("The response attachment is not correct"); 
+        }
+    }
+    
+    /**
+     * Now invoke the message the a receives and returns 2 attachments,
+     * but the request attachments don't comply with wsi
+     * 
+     * @throws Exception
+     */
+    public void testSWAAttachments2_Legacy() throws Exception {
+        String soapAction = "swaAttachment2";
+        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();
+
+        // create attachments 1 and 2
+        byte[] bytes1 = new byte[1];
+        bytes1[0] = '1';
+        byte[] bytes2 = new byte[1];
+        bytes2[0] = '2';
+
+        
+        
+        
+        ByteArrayInputStream bais1 = new ByteArrayInputStream(bytes1);
+        AttachmentPart attachment1 = request.createAttachmentPart();
+        attachment1.setContentId("notCompliant1SWAMTOMTestSOAPMessage");
+        attachment1.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
+        attachment1.setRawContent(bais1, "text/plain");
+        request.addAttachmentPart(attachment1);
+        
+        ByteArrayInputStream bais2 = new ByteArrayInputStream(bytes2);
+        AttachmentPart attachment2 = request.createAttachmentPart();
+        attachment2.setContentId("notCompliant2SWAMTOMTestSOAPMessage");
+        attachment2.addMimeHeader("FVT-source", "STR_BODY_ELEMENT_1");
+        attachment2.setRawContent(bais2, "text/plain");
+        request.addAttachmentPart(attachment2);
+
+        // invoke
+        SOAPMessage reply = dispatch.invoke(request);
+
+        // iterate over the attachments, there should only be one
+        Iterator it = reply.getAttachments();
+        AttachmentPart ap3 = null;
+
+        // verify that the attachment is not null or empty
+        if ((ap3 = (AttachmentPart) it.next()) == null){
+            fail("Attachment is null");
+        }
+        
+        // Make sure the content id starts with the appropriate SWA name
+        if (!ap3.getContentId().startsWith("jpegImage1Response=")) {
+            fail("Expected content id to start with jpegImage1Response");
+        }
+        
+        AttachmentPart ap4 = null;
+        // verify that the second attachment is not null or empty
+        if ((ap4 = (AttachmentPart) it.next()) == null){
+            fail("Attachment is null");
+        }
+        
+        // Make sure the content id starts with the appropriate SWA name
+        if (!ap4.getContentId().startsWith("jpegImage2Response=")) {
+            fail("Expected content id to start with jpegImage2Response");
+        }
+
+        if (it.hasNext()){
+            fail("Detected more then 2 attachment");
+        }
+
+        SOAPBody sb = reply.getSOAPBody();
+        if (sb.getChildElements().hasNext()) {
+            fail("Message contains soap:body payload");
+        }
+
+        byte[] bytes3 = ap3.getRawContentBytes();
+        if (bytes3.length == 0) { 
+            fail("Attachment is empty"); 
+        }
+        if (bytes3[0] != '3') { 
+            fail("The response attachment is not correct"); 
+        }
+        
+        byte[] bytes4 = ap4.getRawContentBytes();
+        if (bytes4.length == 0) { 
+            fail("Attachment is empty"); 
+        }
+        if (bytes4[0] != '4') { 
+            fail("The response attachment is not correct"); 
+        }
+    }
     // TODO:  Add similar code to invoke the mtom enabled operation
 }

Modified: 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=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/META-INF/swamtomservice.wsdl Tue Apr 15 17:29:43 2008
@@ -55,11 +55,21 @@
   <wsdl:message name="swaAttachmentRequest">
     <part name="jpegImageRequest" type="xsd:hexBinary"/>
   </wsdl:message>
-  <wsdl:message name="swAattachmentResponse">
+  <wsdl:message name="swaAttachmentResponse">
     <part name="jpegImageResponse" type="xsd:hexBinary"/>
   </wsdl:message>
 
   
+  <!-- two attachments...and no body part -->
+  <wsdl:message name="swaAttachment2Request">
+    <part name="jpegImage1Request" type="xsd:hexBinary"/>
+    <part name="jpegImage2Request" type="xsd:hexBinary"/>
+  </wsdl:message>
+  <wsdl:message name="swaAttachment2Response">
+    <part name="jpegImage1Response" type="xsd:hexBinary"/>
+    <part name="jpegImage2Response" type="xsd:hexBinary"/>
+  </wsdl:message>
+  
 
    <!-- mtom -->
 
@@ -77,6 +87,11 @@
          <wsdl:output message="tns:swaAttachmentResponse" />
       </wsdl:operation>
       
+      <wsdl:operation name="swaAttachment2">
+         <wsdl:input message="tns:swaAttachment2Request" />
+         <wsdl:output message="tns:swaAttachment2Response" />
+      </wsdl:operation>
+      
       <wsdl:operation name="mtomAttachment">
          <wsdl:input message="tns:mtomAttachmentRequest" />
 
@@ -107,6 +122,37 @@
             </mime:part>
             <mime:part>
               <mime:content part="jpegImageResponse" type="text/plain"/>
+            </mime:part>
+          </mime:multipartRelated>
+        </wsdl:output>
+      </wsdl:operation>
+      
+      <wsdl:operation name="swaAttachment2">
+        <wsdlsoap:operation soapAction="swaAttachment2"/>
+        <wsdl:input >
+          <mime:multipartRelated>
+            <mime:part>
+              <wsdlsoap:body parts="" use="literal"/>
+            </mime:part>
+
+            <mime:part>
+              <mime:content part="jpegImage1Request" type="text/plain"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImage2Request" 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="jpegImage1Response" type="text/plain"/>
+            </mime:part>
+            <mime:part>
+              <mime:content part="jpegImage2Response" type="text/plain"/>
             </mime:part>
           </mime:multipartRelated>
         </wsdl:output>

Modified: 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=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/swamtom/server/SWAMTOMPortTypeImpl.java Tue Apr 15 17:29:43 2008
@@ -26,6 +26,7 @@
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.Holder;
+import javax.jws.WebParam.Mode;
 import javax.jws.soap.SOAPBinding;
 import javax.jws.soap.SOAPBinding.ParameterStyle;
 
@@ -67,6 +68,56 @@
             attachment[2] = 'A';
         }
         return attachment;
+    }
+    
+    /**
+     * This method passes two SWA attachments as a request
+     * and expects two SWA attachments as a response.
+     * Note that the body content in both cases is empty.
+     * (See the wsdl)
+     * @param attachment (swa)
+     * @return attachment (swa)
+     */
+    @WebMethod(operationName="swaAttachment2", action="swaAttachment2")
+    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+    public void swaAttachment2(
+          @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+          @WebParam(name = "jpegImage1Request", targetNamespace = "", partName = "jpegImage1Request")
+          byte[] attachment,
+          
+          @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+          @WebParam(name = "jpegImage2Request", targetNamespace = "", partName = "jpegImage2Request")
+          byte[] attachment2,
+          
+          @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+          @WebParam(name = "jpegImage1Response", 
+                    targetNamespace = "", 
+                    partName = "jpegImage1Response",
+                    mode= Mode.OUT)
+          Holder<byte[]> attachmentOut1,
+          
+          @XmlJavaTypeAdapter(HexBinaryAdapter.class)
+          @WebParam(name = "jpegImage2Response", 
+                    targetNamespace = "", 
+                    partName = "jpegImage2Response",
+                    mode= Mode.OUT)
+          Holder<byte[]> attachmentOut2) {
+          
+        if (attachment == null || attachment.length == 0){
+            throw new RuntimeException("Received empty first attachment");
+        } else if (attachment2 == null || attachment2.length == 0){
+            throw new RuntimeException("Received empty second attachment");
+        } else if (attachment[0] != '1') {
+            throw new RuntimeException("First attachment is not '1'");
+        } else if (attachment2[0] != '2') {
+            throw new RuntimeException("Second attachment is not '2'");
+        } else {
+            attachmentOut1.value = new byte[1];
+            attachmentOut1.value[0] = '3';
+            attachmentOut2.value = new byte[1];
+            attachmentOut2.value[0] = '4';
+        }
+        
     }
     
     @WebMethod(operationName="mtomAttachment", action="mtomAttachment")

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/Attachment.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/Attachment.java?rev=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/Attachment.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/Attachment.java Tue Apr 15 17:29:43 2008
@@ -62,6 +62,7 @@
     AttachmentDescription aDesc = null;
     Object sigValue = null;
     Class sigClass = null;
+    String partName = null;
 
     /**
      * Constructor used to set Attachment from wire unmarshalling
@@ -81,10 +82,11 @@
      * @param sigValue
      * @param sigClass
      */
-    public Attachment(Object sigValue, Class sigClass, AttachmentDescription aDesc) {
+    public Attachment(Object sigValue, Class sigClass, AttachmentDescription aDesc, String partName) {
         this.sigValue = sigValue;
         this.sigClass = sigClass;
         this.aDesc = aDesc;
+        this.partName = partName;
     }
 
 
@@ -104,6 +106,11 @@
     public String getContentID() {
         if (cid == null) {
             cid = UUIDGenerator.getUUID();
+            // Per spec, use the partName in the content-id
+            // http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html#Value-space_of_Content-Id_Header
+            if (partName != null) {
+                cid = partName + "=" + cid;
+            }
         }
         return cid;
     }

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=648471&r1=648470&r2=648471&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 Tue Apr 15 17:29:43 2008
@@ -231,7 +231,8 @@
                         // Create an Attachment object with the signature value
                         Attachment attachment = new Attachment(returnObject, 
                                                                returnType, 
-                                                               attachmentDesc);  
+                                                               attachmentDesc, 
+                                                               operationDesc.getResultPartName());
                         m.addDataHandler(attachment.getDataHandler(), 
                                          attachment.getContentID());
                         m.setDoingSWA(true);

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=648471&r1=648470&r2=648471&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 Tue Apr 15 17:29:43 2008
@@ -265,7 +265,8 @@
                         // Create an Attachment object with the signature value
                         Attachment attachment = new Attachment(returnObject, 
                                                                returnType, 
-                                                               attachmentDesc);  
+                                                               attachmentDesc,
+                                                               operationDesc.getResultPartName());
                         m.addDataHandler(attachment.getDataHandler(), 
                                          attachment.getContentID());
                         m.setDoingSWA(true);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?rev=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Tue Apr 15 17:29:43 2008
@@ -223,7 +223,8 @@
             // Create an Attachment object with the signature value
             Attachment attachment = new Attachment(value, 
                                                    formalType, 
-                                                   attachmentDesc);  
+                                                   attachmentDesc,
+                                                   pd.getPartName());
             pde = new PDElement(pd, 
                     null, // For SWA Attachments, there is no element reference to the attachment
                     null, 
@@ -338,7 +339,22 @@
                 } else {
                     // Attachment Processing
                     if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
-                        String cid = message.getAttachmentID(swaIndex);
+                        String partName = pd.getPartName();
+                        String cid = null;
+                        if (log.isDebugEnabled()) {
+                            log.debug("Getting the attachment dataHandler for partName=" + partName);
+                        }
+                        if (partName != null && partName.length() > 0) {
+                            // Compliant WS-I behavior
+                            cid = message.getAttachmentID(partName);
+                        }
+                        if (cid == null) {
+                            if (log.isDebugEnabled()) {
+                                log.debug("Attachment dataHandler was not found.  Fallback to use attachment " + swaIndex);
+                            }
+                            // Toleration mode for non-compliant attachment names
+                            cid = message.getAttachmentID(swaIndex);
+                        }
                         DataHandler dh = message.getDataHandler(cid);
                         Attachment attachment = new Attachment(dh, cid);
                         PDElement pde = new PDElement(pd, null, null, attachment);

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=648471&r1=648470&r2=648471&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 Tue Apr 15 17:29:43 2008
@@ -309,7 +309,8 @@
                         // Create an Attachment object with the signature value
                         Attachment attachment = new Attachment(returnObject, 
                                                                returnType, 
-                                                               attachmentDesc);  
+                                                               attachmentDesc,
+                                                               operationDesc.getResultPartName());
                         m.addDataHandler(attachment.getDataHandler(), 
                                          attachment.getContentID());
                         m.setDoingSWA(true);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java?rev=648471&r1=648470&r2=648471&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/Message.java Tue Apr 15 17:29:43 2008
@@ -77,6 +77,14 @@
     public String getAttachmentID(int index);
     
     /**
+     * Get the indicated (non-soap part) attachment id
+     * @param partName (WS-I indicates that SWA attachments have a partName prefix)
+     * @return CID or null if not present
+     */
+    public String getAttachmentID(String partName);
+    
+    
+    /**
      * Get the attachment identified by the contentID 
      * @param cid
      * @return

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=648471&r1=648470&r2=648471&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 Tue Apr 15 17:29:43 2008
@@ -289,6 +289,21 @@
         return resultCID;
     }
     
+
+    public String getAttachmentID(String partName) {
+        // Find the prefix that starts with the 
+        // partName=
+        String prefix = partName + "=";
+        List<String> cids = getAttachmentIDs();
+        for (String cid: cids) {
+            if (cid.startsWith(prefix)) {
+                return cid;
+            }
+        }
+        return null;
+    }
+
+    
     private String getSOAPPartContentID() {
         String contentID = null;
         if (messageContext == null) {



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