cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r449668 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/io/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/databinding/jaxb/src/main/java/or...
Date Mon, 25 Sep 2006 12:42:57 GMT
Author: tli
Date: Mon Sep 25 05:42:56 2006
New Revision: 449668

URL: http://svn.apache.org/viewvc?view=rev&rev=449668
Log:
add xop test case for mtom, fix bug of byte[] holder in checkHolder method

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/AbstractCachedOutputStream.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientServerMtomXopTest.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/HelloImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/AbstractCachedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/AbstractCachedOutputStream.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/AbstractCachedOutputStream.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/AbstractCachedOutputStream.java
Mon Sep 25 05:42:56 2006
@@ -94,7 +94,7 @@
      *            the real output stream
      * @throws IOException
      */
-    public void resetOut(OutputStream out, boolean copyOldContent) throws IOException { 
      
+    public void resetOut(OutputStream out, boolean copyOldContent) throws IOException {
         if (currentStream instanceof AbstractCachedOutputStream) {
             AbstractCachedOutputStream ac = (AbstractCachedOutputStream) currentStream;
             InputStream in = ac.getInputStream();
@@ -126,33 +126,29 @@
 
     public static void copyStream(InputStream in, OutputStream out, int bufferSize) throws
IOException {
         byte[] buffer = new byte[bufferSize];
-        int len = 0;
-        int pos = 0;
-        while (true) {
-            len = in.read(buffer, 0, bufferSize);
-            if (len != -1) {
-                out.write(buffer, 0, len);
-                pos += len;
-            } else {
-                break;
+        try {
+            int n = in.read(buffer);
+            while (n > 0) {
+                out.write(buffer, 0, n);
+                n = in.read(buffer);
             }
+        } finally {
+            in.close();
         }
     }
 
-    public static void copyStreamWithBase64Encoding(InputStream in, OutputStream out, 
-                    int bufferSize) throws Exception {
+    public static void copyStreamWithBase64Encoding(InputStream in, OutputStream out, int
bufferSize)
+        throws Exception {
         OutputStreamWriter osw = new OutputStreamWriter(out);
         byte[] buffer = new byte[bufferSize];
-        int len = 0;
-        int pos = 0;
-        while (true) {
-            len = in.read(buffer, 0, bufferSize);
-            if (len != -1) {
-                Base64Utility.encode(buffer, pos, len, osw);
-                pos += len;
-            } else {
-                break;
+        try {
+            int n = in.read(buffer, 0, bufferSize);
+            while (n > 0) {
+                Base64Utility.encode(buffer, 0, n, osw);
+                n = in.read(buffer, 0, bufferSize);
             }
+        } finally {
+            in.close();
         }
     }
 

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
Mon Sep 25 05:42:56 2006
@@ -30,6 +30,9 @@
 
 public class SoapBinding extends AbstractBasicInterceptorProvider implements Binding {
 
+    // default to support mtom, left to config to turn off this feature.
+    private boolean mtomEnabled = true;
+    
     private List<Interceptor> in;
     private List<Interceptor> out;
     private List<Interceptor> fault;
@@ -59,4 +62,13 @@
     public List<Interceptor> getOutInterceptors() {
         return out;
     }
+
+    public boolean isMtomEnabled() {
+        return mtomEnabled;
+    }
+
+    public void setMtomEnabled(boolean enabled) {
+        mtomEnabled = enabled;
+    }
+
 }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Mon Sep 25 05:42:56 2006
@@ -121,7 +121,7 @@
                 if (boi.getUnwrappedOperation() == null) {
                     parameterStyle = SoapConstants.PARAMETER_STYLE_BARE;
                 }
-            }
+            }            
         }
 
         sb.getInInterceptors().add(new MultipartMessageInterceptor());
@@ -130,8 +130,13 @@
         sb.getInInterceptors().add(new StaxInInterceptor());
 
         sb.getInFaultInterceptors().add(new Soap11FaultInInterceptor());
-
-        sb.getOutInterceptors().add(new AttachmentOutInterceptor());
+        
+        // TODO: We shouldn't be running this interceptor if MTOM isn't enabled
+        // as caching everything is going to slow us down, should set according to config

+        if (sb.isMtomEnabled()) {
+            sb.getOutInterceptors().add(new AttachmentOutInterceptor());
+        }
+        
         sb.getOutInterceptors().add(new StaxOutInterceptor());
         sb.getOutInterceptors().add(new SoapPreProtocolOutInterceptor());
         sb.getOutInterceptors().add(new SoapOutInterceptor());

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
Mon Sep 25 05:42:56 2006
@@ -44,8 +44,6 @@
     }
 
     public void handleMessage(SoapMessage message) throws Fault {
-        // TODO: We shouldn't be running this interceptor if MTOM isn't enabled
-        // as caching everything is going to slow us down
         
         OutputStream os = message.getContent(OutputStream.class);
         CachedStream cs = new CachedStream();
@@ -57,7 +55,7 @@
         message.setContent(OutputStream.class, os);        
         try {
             Collection<Attachment> attachments = message.getAttachments();
-            cs.flush();
+            cs.flush();            
             if (attachments.size() > 0) {
                 AttachmentSerializer as = new AttachmentSerializer(message, cs.getInputStream(),
os);
                 as.serializeMultipartMessage();

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Mon Sep 25 05:42:56 2006
@@ -35,7 +35,6 @@
 import org.apache.cxf.binding.soap.SoapVersionFactory;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
-//import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -49,9 +48,8 @@
     }
 
     public void handleMessage(SoapMessage message) {
-        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
-     
         
+        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
         
         if (xmlReader == null) {
             InputStream in = (InputStream)message.getContent(InputStream.class);
@@ -62,8 +60,8 @@
         }
 
         try {
-            /*System.out.println("the xml fragment is ");
-            System.out.println(XMLUtils.toString(StaxUtils.read(xmlReader)));*/
+//            System.out.println("the xml fragment is ");
+//            System.out.println(XMLUtils.toString(StaxUtils.read(xmlReader)));
             if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 String ns = xmlReader.getNamespaceURI();
                 SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
Mon Sep 25 05:42:56 2006
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.io.PushbackInputStream;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -38,6 +37,7 @@
 import org.apache.cxf.binding.attachment.AttachmentDataSource;
 import org.apache.cxf.binding.attachment.AttachmentImpl;
 import org.apache.cxf.binding.attachment.CachedOutputStream;
+import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 
@@ -168,7 +168,8 @@
         Attachment att = readMimePart();
         while (att != null && att.getId() != null) {
             attachments.add(att);
-            if (att.getId().equals(cid)) {
+            String convertId = cid.substring(0, 4).equals("cid:") ? cid.substring(4) : cid;
+            if (att.getId().equals(convertId)) {
                 return att;
             }
             att = readMimePart();
@@ -225,7 +226,8 @@
         MimeBodyPartInputStream partStream = new MimeBodyPartInputStream(stream, boundary.getBytes());
         final CachedOutputStream cos = new CachedOutputStream();
         cos.setThreshold(THRESHHOLD);
-        copy(partStream, cos);
+        AbstractCachedOutputStream.copyStream(partStream, cos, THRESHHOLD);
+        cos.close();
         final String ct = headers.getHeader("Content-Type", null);
         cache.add(cos);
         DataSource source = new AttachmentDataSource(ct, cos);
@@ -244,20 +246,6 @@
             att.setHeader(header.getName(), header.getValue());
         }
         return att;
-    }
-
-    private static void copy(InputStream input, OutputStream output) throws IOException {
-        try {
-            final byte[] buffer = new byte[8096];
-            int n = input.read(buffer);
-            while (n > 0) {
-                output.write(buffer, 0, n);
-                n = input.read(buffer);
-            }
-        } finally {
-            input.close();
-            output.close();
-        }
     }
 
     private class MimeBodyPartInputStream extends InputStream {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
Mon Sep 25 05:42:56 2006
@@ -35,6 +35,7 @@
 
 public class JAXBAttachmentMarshaller extends AttachmentMarshaller {
 
+    private static final int THRESH_HOLD = 64 * 1024;
     private Message message;
     private Collection<Attachment> atts;
     private boolean isXop;
@@ -47,8 +48,16 @@
 
     public String addMtomAttachment(byte[] data, int offset, int length, String mimeType,
String elementNS,
                                     String elementLocalName) {
+        
+        if (!isXop && length < THRESH_HOLD) {
+            return null;
+        }        
         ByteDataSource source = new ByteDataSource(data, offset, length);
-        source.setContentType(mimeType);
+        if (mimeType == null) {
+            source.setContentType(mimeType);
+        } else {
+            source.setContentType("application/octet-stream");
+        }
         DataHandler handler = new DataHandler(source);
 
         String id;
@@ -66,6 +75,9 @@
 
     public String addMtomAttachment(DataHandler handler, String elementNS, String elementLocalName)
{
 
+        if (!isXop) {
+            return null;
+        }        
         String id;
         try {
             id = AttachmentUtil.createContentID(elementNS);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JAXWSMethodInvoker.java
Mon Sep 25 05:42:56 2006
@@ -17,10 +17,10 @@
  * under the License.
  */
 
-
-
 package org.apache.cxf.jaxws;
 
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -41,21 +41,21 @@
 public class JAXWSMethodInvoker implements Invoker {
 
     private Object bean;
-    
+
     public JAXWSMethodInvoker(Object bean) {
         super();
         this.bean = bean;
     }
-    
+
     @SuppressWarnings("unchecked")
     public Object invoke(Exchange exchange, Object o) {
         BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
-        
-        MethodDispatcher md = (MethodDispatcher) 
-            exchange.get(Service.class).get(MethodDispatcher.class.getName());
+
+        MethodDispatcher md = (MethodDispatcher) exchange.get(Service.class).get(
+                        MethodDispatcher.class.getName());
         Method m = md.getMethod(bop);
         List<Object> params = (List<Object>) o;
-                
+
         checkHolder(m, params, exchange);
         Object res;
         try {
@@ -65,12 +65,12 @@
                 return null;
             }
             List<Object> retList = new ArrayList<Object>();
-            if (!((Class)m.getReturnType()).getName().equals("void")) {
+            if (!((Class) m.getReturnType()).getName().equals("void")) {
                 retList.add(res);
             }
             for (int i = 0; i < paramArray.length; i++) {
                 if (paramArray[i] instanceof Holder) {
-                    retList.add(((Holder)paramArray[i]).value);
+                    retList.add(((Holder) paramArray[i]).value);
                 }
             }
             return Arrays.asList(retList.toArray());
@@ -90,38 +90,34 @@
     @SuppressWarnings("unchecked")
     private void checkHolder(Method method, List<Object> params, Exchange exchange)
{
         if (method != null) {
-           
+
             Type[] para = method.getGenericParameterTypes();
             for (int i = 0; i < para.length; i++) {
                 if (para[i] instanceof ParameterizedType) {
                     Object param = null;
-                    ParameterizedType paramType = (ParameterizedType)para[i];
-                    if (((Class)paramType.getRawType()).getName().equals("javax.xml.ws.Holder"))
{
-                        
-                        try {
-                            param = new Holder(
-                                ((Class)paramType.getActualTypeArguments()[0]).newInstance());
-                        } catch (InstantiationException e) {
-                            throw new Fault(e);
-                        } catch (IllegalAccessException e) {
-                            throw new Fault(e);
+                    ParameterizedType paramType = (ParameterizedType) para[i];
+                    if (((Class) paramType.getRawType()).getName().equals("javax.xml.ws.Holder"))
{
+                        Object rawType = paramType.getActualTypeArguments()[0];
+                        Class rawClass;
+                        if (rawType instanceof GenericArrayType) {
+                            rawClass = (Class) ((GenericArrayType) rawType).getGenericComponentType();
+                            rawClass = Array.newInstance(rawClass, 0).getClass();
+                        } else {
+                            rawClass = (Class) rawType;
                         }
+                        param = new Holder((Class) rawClass);
                         if (i >= params.size()) {
                             params.add(param);
                         } else {
                             params.set(i, new Holder(params.get(i)));
                         }
-                        
                     }
-                                       
-                    
+
                 }
             }
-            
+
         }
-        
-    }
 
-    
+    }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
Mon Sep 25 05:42:56 2006
@@ -32,10 +32,11 @@
 
 public class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
 
+    private SoapBinding soapBinding;
     // private SoapBinding soapBinding;
 
     public SOAPBindingImpl(SoapBinding sb) {
-        // soapBinding = sb;
+        soapBinding = sb;
     }
     
     public Set<String> getRoles() {
@@ -47,7 +48,7 @@
     }
 
     public boolean isMTOMEnabled() {
-        return false;
+        return soapBinding.isMtomEnabled();
     }
 
     public void setMTOMEnabled(boolean flag) {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerRPCLitTest.java
Mon Sep 25 05:42:56 2006
@@ -79,7 +79,7 @@
         String response2 = new String("Bonjour");
         try {
             GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
-            for (int idx = 0; idx < 5; idx++) {
+            for (int idx = 0; idx < 1; idx++) {
                 String greeting = greeter.greetMe("Milestone-" + idx);
                 assertNotNull("no response received from service", greeting);
                 String exResponse = response1 + idx;

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientServerMtomXopTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientServerMtomXopTest.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientServerMtomXopTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientServerMtomXopTest.java
Mon Sep 25 05:42:56 2006
@@ -25,6 +25,7 @@
 import javax.activation.DataSource;
 import javax.mail.util.ByteArrayDataSource;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.Holder;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -68,7 +69,7 @@
         };
     }
 
-    public void testMtomBasic() throws Exception {
+    public void testMtomSWA() throws Exception {
         HelloService hs = new HelloService();
         Hello hello = hs.getPort(Hello.class);
         try {
@@ -77,7 +78,7 @@
             for (int i = pre.read(); i != -1; i = pre.read()) {
                 fileSize++;
             }
-            
+
             ByteArrayDataSource bads = new ByteArrayDataSource(this.getClass().getResourceAsStream(
                             "/wsdl/mtom_xop.wsdl"), "application/oct-stream");
             DataHandler dh = new DataHandler(bads);
@@ -89,6 +90,28 @@
                 count++;
             }
             assertEquals("attachemnt length different", fileSize, count);
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception) ex.getCause();
+        }
+    }
+
+    public void testMtomXop() throws Exception {
+        HelloService hs = new HelloService();
+        Hello hello = hs.getPort(Hello.class);
+        try {
+            InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
+            long fileSize = 0;
+            for (int i = pre.read(); i != -1; i = pre.read()) {
+                fileSize++;
+            }
+            Holder<byte[]> param = new Holder<byte[]>();
+            param.value = new byte[(int) fileSize];
+            this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(param.value);
+            String target = new String(param.value);
+            Holder<String> name = new Holder<String>("call echoDataWithEnableMIMEContent");
+            hello.detail(name, param);
+            assertEquals("name unchanged", "return detail + call echoDataWithEnableMIMEContent",
name.value);
+            assertEquals("attachinfo changed", target, new String(param.value));
         } catch (UndeclaredThrowableException ex) {
             throw (Exception) ex.getCause();
         }

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/HelloImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/HelloImpl.java?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/HelloImpl.java (original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/mtom_xop/HelloImpl.java Mon
Sep 25 05:42:56 2006
@@ -36,13 +36,15 @@
         return data;
     }
 
-    public void detail(Holder<String> name, Holder<String> address) {
+    public void detail(Holder<String> name, Holder<byte[]> attachinfo) {
+        name.value = "return detail + " + name.value;        
     }
 
     public void echoData(String body, Holder<byte[]> data) {
     }
 
     public void echoDataWithEnableMIMEContent(String body, Holder<byte[]> data) {
+        System.out.println(body);
     }
 
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl?view=diff&rev=449668&r1=449667&r2=449668
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/mtom_xop.wsdl Mon Sep 25 05:42:56
2006
@@ -1,183 +1,175 @@
 <?xml version="1.0" encoding="utf-8"?>
-<wsdl:definitions name="SOAPBuilders-mime-cr-test"
-	xmlns:types="http://cxf.apache.org/mime/types"
-	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
-	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
-	xmlns:tns="http://cxf.apache.org/mime"
-	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
-	targetNamespace="http://cxf.apache.org/mime">
-
-	<wsdl:types>
-		<schema xmlns="http://www.w3.org/2001/XMLSchema"
-			targetNamespace="http://cxf.apache.org/mime/types"
-			xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
-			elementFormDefault="qualified"
-			xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
-			<import namespace="http://ws-i.org/profiles/basic/1.1/xsd"
-				schemaLocation="wsi-swa.xsd" />
-			<complexType name="DetailType">
-				<sequence>
-					<element name="name" type="string" />
-					<element name="address" type="string" />
-				</sequence>
-			</complexType>
-			<element name="claimForm" type="ref:swaRef" />
-			<element name="claimFormResponse" type="ref:swaRef" />
-			<element name="Detail" type="types:DetailType" />
-			<element name="DetailResponse" type="types:DetailType" />
-			<element name="body" type="string" />
-			<element name="mimeBody" type="string" />
-		</schema>
-
-	</wsdl:types>
-
-	<wsdl:message name="echoDataIn">
-		<wsdl:part name="body" element="types:body" />
-		<wsdl:part name="data" type="xsd:base64Binary" />
-	</wsdl:message>
-
-	<wsdl:message name="echoDataOut">
-		<wsdl:part name="data" type="xsd:base64Binary" />
-	</wsdl:message>
-
-	<wsdl:message name="echoDataMimeIn">
-		<wsdl:part name="body" element="types:mimeBody" />
-		<wsdl:part name="data" type="xsd:base64Binary" />
-	</wsdl:message>
-
-	<wsdl:message name="echoDataMimeOut">
-		<wsdl:part name="data" type="xsd:base64Binary" />
-	</wsdl:message>
-
-	<wsdl:message name="HelloIn">
-		<wsdl:part name="data" element="types:Detail" />
-	</wsdl:message>
-
-	<wsdl:message name="HelloOut">
-		<wsdl:part name="data" element="types:DetailResponse" />
-	</wsdl:message>
-
-	<wsdl:message name="claimFormIn">
-		<wsdl:part name="data" element="types:claimForm" />
-	</wsdl:message>
-
-	<wsdl:message name="claimFormOut">
-		<wsdl:part name="data" element="types:claimFormResponse" />
-	</wsdl:message>
-
-	<wsdl:portType name="Hello">
-		<!-- wsdl mime test with enableMTOMContent disabled(default) -->
-		<wsdl:operation name="echoData">
-			<wsdl:input message="tns:echoDataIn" />
-			<wsdl:output message="tns:echoDataOut" />
-		</wsdl:operation>
-
-		<!-- wsdl mime test with enableMIMEContent enabled -->
-		<wsdl:operation name="echoDataWithEnableMIMEContent">
-			<wsdl:input message="tns:echoDataMimeIn" />
-			<wsdl:output message="tns:echoDataMimeOut" />
-		</wsdl:operation>
-
-		<!-- wsdl mime test with enableMIMEContent enabled -->
-		<wsdl:operation name="Detail">
-			<wsdl:input message="tns:HelloIn" />
-			<wsdl:output message="tns:HelloOut" />
-		</wsdl:operation>
-
-		<!-- swaref test -->
-		<wsdl:operation name="claimForm">
-			<wsdl:input message="tns:claimFormIn" />
-			<wsdl:output message="tns:claimFormOut" />
-		</wsdl:operation>
-
-	</wsdl:portType>
-
-	<wsdl:binding name="HelloBinding" type="tns:Hello">
-		<soap:binding style="document"
-			transport="http://schemas.xmlsoap.org/soap/http" />
-
-		<wsdl:operation name="echoData">
-			<soap:operation soapAction="" />
-			<wsdl:input>
-				<mime:multipartRelated>
-					<mime:part>
-						<soap:body parts="body" use="literal" />
-					</mime:part>
-					<mime:part>
-						<mime:content part="data" type="image/jpeg" />
-					</mime:part>
-				</mime:multipartRelated>
-			</wsdl:input>
-			<wsdl:output>
-				<mime:multipartRelated>
-					<mime:part>
-						<soap:body parts="" use="literal" />
-					</mime:part>
-					<mime:part>
-						<mime:content part="data" type="image/jpeg" />
-					</mime:part>
-				</mime:multipartRelated>
-			</wsdl:output>
-		</wsdl:operation>
-
-		<wsdl:operation name="echoDataWithEnableMIMEContent">
-			<soap:operation soapAction="" />
-			<wsdl:input>
-				<mime:multipartRelated>
-					<mime:part>
-						<soap:body parts="body" use="literal" />
-					</mime:part>
-					<mime:part>
-						<mime:content part="data" type="image/jpeg" />
-					</mime:part>
-				</mime:multipartRelated>
-			</wsdl:input>
-			<wsdl:output>
-				<mime:multipartRelated>
-					<mime:part>
-						<soap:body parts="" use="literal" />
-					</mime:part>
-					<mime:part>
-						<mime:content part="data" type="image/jpeg" />
-					</mime:part>
-				</mime:multipartRelated>
-			</wsdl:output>
-		</wsdl:operation>
-
-		<wsdl:operation name="Detail">
-			<soap:operation soapAction="" />
-			<wsdl:input>
-				<soap:body use="literal" />
-			</wsdl:input>
-			<wsdl:output>
-				<mime:multipartRelated>
-					<mime:part>
-						<soap:body parts="" use="literal" />
-					</mime:part>
-					<mime:part>
-						<mime:content part="data" type="text/xml" />
-					</mime:part>
-				</mime:multipartRelated>
-			</wsdl:output>
-		</wsdl:operation>
-
-		<wsdl:operation name="claimForm">
-			<soap:operation soapAction="" />
-			<wsdl:input>
-				<soap:body use="literal" />
-			</wsdl:input>
-			<wsdl:output>
-				<soap:body use="literal" />
-			</wsdl:output>
-		</wsdl:operation>
-
-	</wsdl:binding>
-
-	<wsdl:service name="HelloService">
-		<wsdl:port name="HelloPort" binding="tns:HelloBinding">
-			<soap:address location="http://localhost:9036/mime-test" />
-		</wsdl:port>
-	</wsdl:service>
+<wsdl:definitions name="SOAPBuilders-mime-cr-test" xmlns:types="http://cxf.apache.org/mime/types"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://cxf.apache.org/mime"
+    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://cxf.apache.org/mime">
+
+    <wsdl:types>
+        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://cxf.apache.org/mime/types"
+            xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified"
+            xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
+            <import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="wsi-swa.xsd"
/>
+            <complexType name="DetailType">
+                <sequence>
+                    <element name="name" type="xsd:string" />
+                    <element name="attachinfo" type="xsd:base64Binary" />
+                </sequence>
+            </complexType>
+            <element name="claimForm" type="ref:swaRef" />
+            <element name="claimFormResponse" type="ref:swaRef" />
+            <element name="Detail" type="types:DetailType" />
+            <element name="DetailResponse" type="types:DetailType" />
+            <element name="body" type="string" />
+            <element name="mimeBody" type="string" />
+        </schema>
+
+    </wsdl:types>
+
+    <wsdl:message name="echoDataIn">
+        <wsdl:part name="body" element="types:body" />
+        <wsdl:part name="data" type="xsd:base64Binary" />
+    </wsdl:message>
+
+    <wsdl:message name="echoDataOut">
+        <wsdl:part name="data" type="xsd:base64Binary" />
+    </wsdl:message>
+
+    <wsdl:message name="echoDataMimeIn">
+        <wsdl:part name="body" element="types:mimeBody" />
+        <wsdl:part name="data" type="xsd:base64Binary" />
+    </wsdl:message>
+
+    <wsdl:message name="echoDataMimeOut">
+        <wsdl:part name="data" type="xsd:base64Binary" />
+    </wsdl:message>
+
+    <wsdl:message name="HelloIn">
+        <wsdl:part name="data" element="types:Detail" />
+    </wsdl:message>
+
+    <wsdl:message name="HelloOut">
+        <wsdl:part name="data" element="types:DetailResponse" />
+    </wsdl:message>
+
+    <wsdl:message name="claimFormIn">
+        <wsdl:part name="data" element="types:claimForm" />
+    </wsdl:message>
+
+    <wsdl:message name="claimFormOut">
+        <wsdl:part name="data" element="types:claimFormResponse" />
+    </wsdl:message>
+
+    <wsdl:portType name="Hello">
+        <!-- wsdl mime test with enableMTOMContent disabled(default) -->
+        <wsdl:operation name="echoData">
+            <wsdl:input message="tns:echoDataIn" />
+            <wsdl:output message="tns:echoDataOut" />
+        </wsdl:operation>
+
+        <!-- wsdl mime test with enableMIMEContent enabled -->
+        <wsdl:operation name="echoDataWithEnableMIMEContent">
+            <wsdl:input message="tns:echoDataMimeIn" />
+            <wsdl:output message="tns:echoDataMimeOut" />
+        </wsdl:operation>
+
+        <!-- wsdl mime test with enableMIMEContent enabled -->
+        <wsdl:operation name="Detail">
+            <wsdl:input message="tns:HelloIn" />
+            <wsdl:output message="tns:HelloOut" />
+        </wsdl:operation>
+
+        <!-- swaref test -->
+        <wsdl:operation name="claimForm">
+            <wsdl:input message="tns:claimFormIn" />
+            <wsdl:output message="tns:claimFormOut" />
+        </wsdl:operation>
+
+    </wsdl:portType>
+
+    <wsdl:binding name="HelloBinding" type="tns:Hello">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
+
+        <wsdl:operation name="echoData">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soap:body parts="body" use="literal" />
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="data" type="image/jpeg" />
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soap:body parts="" use="literal" />
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="data" type="image/jpeg" />
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="echoDataWithEnableMIMEContent">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soap:body parts="body" use="literal" />
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="data" type="image/bmp" />
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soap:body parts="" use="literal" />
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="data" type="image/bmp" />
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="Detail">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <mime:multipartRelated>
+                    <mime:part>
+                        <soap:body parts="" use="literal" />
+                    </mime:part>
+                    <mime:part>
+                        <mime:content part="data" type="text/xml" />
+                    </mime:part>
+                </mime:multipartRelated>
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="claimForm">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+
+    </wsdl:binding>
+
+    <wsdl:service name="HelloService">
+        <wsdl:port name="HelloPort" binding="tns:HelloBinding">
+            <soap:address location="http://localhost:9036/mime-test" />
+        </wsdl:port>
+    </wsdl:service>
 
 </wsdl:definitions>



Mime
View raw message