cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r541462 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/...
Date Thu, 24 May 2007 22:33:44 GMT
Author: dandiep
Date: Thu May 24 15:33:40 2007
New Revision: 541462

URL: http://svn.apache.org/viewvc?view=rev&rev=541462
Log:
Get basic SwA working. The SwA tests now ensure that both the swaRef and
the normal <mime:content> attachment mechanisms work.

We still need to do the following:
1. CXF-677
2. Ensure the Content-Types are correct for the messages (i.e. no XOP content types)
3. Ensure that code first (@XmlAttachmentRef?) attachments are working
4. Translate DataHandlers into Images, OctetStreams, etc and vis a versa where appropriate.


Others can feel free to pick up any of these pieces, I'll be plugging away at them more
tomorrow and next week.


Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
  (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
  (with props)
Modified:
    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/model/SoapBodyInfo.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl

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=541462&r1=541461&r2=541462
==============================================================================
--- 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
Thu May 24 15:33:40 2007
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 
 import javax.wsdl.extensions.ExtensibilityElement;
@@ -336,6 +337,7 @@
             parts = soapBody.getParts();
         }
         // Initialize the body parts.
+        List<MessagePartInfo> attParts = null;
         if (parts != null) {
             List<MessagePartInfo> bodyParts = new ArrayList<MessagePartInfo>();
             for (Iterator itr = parts.iterator(); itr.hasNext();) {
@@ -348,28 +350,46 @@
                     }
                     Object content = mpart.getExtensibilityElements().get(0);
                     if (content instanceof MIMEContent) {
-                        partName = ((MIMEContent) content).getPart();
+                        MIMEContent mc = (MIMEContent)content;
+                        partName = mc.getPart();
+                        
+                        if (attParts == null) {
+                            attParts = new LinkedList<MessagePartInfo>();
+                        }
+
+                        MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
+                                                                           partName));
+                        mpi.setProperty(Message.CONTENT_TYPE, mc.getType());
+                        attParts.add(mpi);
+                        // Attachments shouldn't be part of the body message
+                        bmsg.getMessageParts().remove(mpi);
                     } else if (SOAPBindingUtil.isSOAPBody(content)) {
                         SoapBody sb = SOAPBindingUtil.getSoapBody(content);
                         if (sb.getParts().size() == 1) {
                             partName = (String) sb.getParts().get(0);
                         }
-                    }
+                        
+                        // We can have a list of empty part names here.
+                        if (partName != null) {
+                            addSoapBodyPart(msg, bodyParts, partName);
+                        }
+                    }                   
                 } else {
-                    partName = (String)part;
-                }
-                if (partName != null) {
-                    MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
-                                    partName));
-                    bodyParts.add(mpi);
+                    addSoapBodyPart(msg, bodyParts, (String)part);
                 }
             }
             bodyInfo.setParts(bodyParts);
+            bodyInfo.setAttachments(attParts);
         } else {
             bodyInfo.setParts(messageParts);
         }
 
         bmsg.addExtensor(bodyInfo);
+    }
+    private void addSoapBodyPart(MessageInfo msg, List<MessagePartInfo> bodyParts,
String partName) {
+        MessagePartInfo mpi = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(),
+                                                           partName));
+        bodyParts.add(mpi);
     }
     
     @Override

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBodyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBodyInfo.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBodyInfo.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/model/SoapBodyInfo.java
Thu May 24 15:33:40 2007
@@ -26,6 +26,7 @@
 
 public class SoapBodyInfo {
     private List <MessagePartInfo> parts = new ArrayList<MessagePartInfo>();
+    private List <MessagePartInfo> attachments = new ArrayList<MessagePartInfo>();
     private String use;
     
     public List<MessagePartInfo> getParts() {
@@ -43,4 +44,13 @@
     public void setUse(String use) {
         this.use = use;
     }
+
+    public List<MessagePartInfo> getAttachments() {
+        return attachments;
+    }
+
+    public void setAttachments(List<MessagePartInfo> attachments) {
+        this.attachments = attachments;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
Thu May 24 15:33:40 2007
@@ -44,15 +44,15 @@
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataWriter<T> writer = service.getDataBinding().createWriter(output);
         
+        Collection<Attachment> atts = message.getAttachments();
         if (MessageUtils.isTrue(message.getContextualProperty(
-              org.apache.cxf.message.Message.MTOM_ENABLED))) {
-            Collection<Attachment> atts = message.getAttachments();
-            if (atts == null) {
-                atts = new ArrayList<Attachment>();
-                message.setAttachments(atts);
-            }
-            writer.setAttachments(atts);
+              org.apache.cxf.message.Message.MTOM_ENABLED))
+              && atts == null) {
+            atts = new ArrayList<Attachment>();
+            message.setAttachments(atts);
         }
+        
+        writer.setAttachments(atts);
         
         setSchemaOutMessage(service, message, writer);
         return writer;

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
Thu May 24 15:33:40 2007
@@ -31,6 +31,8 @@
 
 public class AttachmentOutInterceptor extends AbstractPhaseInterceptor<Message> {
 
+    public static final String WRITE_ATTACHMENTS = "write.attachments";
+    
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AttachmentOutInterceptor.class);
 
     public AttachmentOutInterceptor() {
@@ -41,7 +43,8 @@
     public void handleMessage(Message message) {
         
         if (!MessageUtils.isTrue(message.getContextualProperty(
-                org.apache.cxf.message.Message.MTOM_ENABLED))) {
+                org.apache.cxf.message.Message.MTOM_ENABLED))
+                && !MessageUtils.isTrue(message.getContextualProperty(WRITE_ATTACHMENTS)))
{
             return;
         }
 

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Thu May 24 15:33:40 2007
@@ -114,6 +114,10 @@
         setContext(context);
     }
 
+    public JAXBContext getContext() {
+        return context;
+    }
+
     public void setContext(JAXBContext ctx) {
         context = ctx;
     }    

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=541462&r1=541461&r2=541462
==============================================================================
--- 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
Thu May 24 15:33:40 2007
@@ -92,7 +92,7 @@
     }
 
     @Override
-    public String addSwaRefAttachment(DataHandler handler) {        
+    public String addSwaRefAttachment(DataHandler handler) {
         String id = UUID.randomUUID() + "@apache.org";
         AttachmentImpl att = new AttachmentImpl(id, handler);
         att.setXOP(false);

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
Thu May 24 15:33:40 2007
@@ -75,12 +75,15 @@
     }
 
     private DataSource getAttachmentDataSource(String contentId) {
+        // Is this right? - DD
         if (contentId.startsWith("cid:")) {
             try {
                 contentId = URLDecoder.decode(contentId.substring(4), "UTF-8");
             } catch (UnsupportedEncodingException ue) {
                 contentId = contentId.substring(4);
             }
+            return new LazyDataSource(contentId, attachments);
+        } else if (contentId.indexOf("://") == -1) {
             return new LazyDataSource(contentId, attachments);
         } else {
             try {

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java?view=auto&rev=541462
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
Thu May 24 15:33:40 2007
@@ -0,0 +1,92 @@
+/**
+ * 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.cxf.jaxws.interceptors;
+
+import java.util.List;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.model.SoapBodyInfo;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+public class SwAInInterceptor extends AbstractSoapInterceptor {
+
+    public SwAInInterceptor() {
+        super();
+        setPhase(Phase.PRE_INVOKE);
+        getBefore().add(HolderInInterceptor.class.getName());
+    }
+
+    public void handleMessage(SoapMessage message) throws Fault {
+        BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
+        if (bop == null) {
+            return;
+        }
+        
+        if (bop.isUnwrapped()) {
+            bop = bop.getWrappedOperation();
+        }
+        
+        boolean client = isRequestor(message);
+        BindingMessageInfo bmi = client ? bop.getOutput() : bop.getInput();
+        
+        SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class);
+        
+        if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().size() ==
0) {
+            return;
+        }
+        
+        List<Object> inObjects = CastUtils.cast(message.getContent(List.class));
+
+        for (MessagePartInfo mpi : sbi.getAttachments()) {
+            String partName = mpi.getConcreteName().getLocalPart();
+            
+            String start = partName + "=";
+            for (Attachment a : message.getAttachments()) {
+                if (a.getId().startsWith(start)) {
+//                    String ct = (String) mpi.getProperty(Message.CONTENT_TYPE);
+//
+//                    System.out.println("Content type " + ct);
+//                    Object content = null;
+//                    try {
+//                        DataFlavor flavor = new DataFlavor(ct);
+//                        content = a.getDataHandler().getTransferData(flavor);
+//                    } catch (IOException e) {
+//                        // TODO Auto-generated catch block
+//                        e.printStackTrace();
+//                    } catch (UnsupportedFlavorException e) {
+//                        // TODO Auto-generated catch block
+//                        e.printStackTrace();
+//                    } catch (ClassNotFoundException e) {
+//                        // TODO Auto-generated catch block
+//                        e.printStackTrace();
+//                    }
+//                    System.out.println("Content " + content);
+                    inObjects.add(a.getDataHandler());
+                }
+            }
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?view=auto&rev=541462
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Thu May 24 15:33:40 2007
@@ -0,0 +1,123 @@
+/**
+ * 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.cxf.jaxws.interceptors;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.JAXBContext;
+
+import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
+
+import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.model.SoapBodyInfo;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+public class SwAOutInterceptor extends AbstractSoapInterceptor {
+
+    public SwAOutInterceptor() {
+        super();
+        addAfter(HolderOutInterceptor.class.getName());
+        addBefore(WrapperClassOutInterceptor.class.getName());
+        setPhase(Phase.PRE_LOGICAL);
+    }
+
+    public void handleMessage(SoapMessage message) throws Fault {
+        BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
+        if (bop == null) {
+            return;
+        }
+        
+        if (bop.isUnwrapped()) {
+            bop = bop.getWrappedOperation();
+        }
+        
+        boolean client = isRequestor(message);
+        BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput();
+        
+        SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class);
+        
+        if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().size() ==
0) {
+            Service s = message.getExchange().get(Service.class);
+            DataBinding db = s.getDataBinding();
+            if (db instanceof JAXBDataBinding) {
+                JAXBContext context = ((JAXBDataBinding)db).getContext();
+                if (context instanceof JAXBContextImpl) {
+                    JAXBContextImpl riCtx = (JAXBContextImpl) context;
+                    if (riCtx.hasSwaRef()) {
+                        setupAttachmentOutput(message);
+                    }
+                }
+            }
+            return;
+        }
+        
+        Collection<Attachment> atts = setupAttachmentOutput(message);
+
+        List<Object> outObjects = CastUtils.cast(message.getContent(List.class));
+
+        int bodyParts = sbi.getParts().size();
+        for (MessagePartInfo mpi : sbi.getAttachments()) {
+            String partName = mpi.getConcreteName().getLocalPart();
+            
+            String id = new StringBuilder().append(partName)
+                .append("=")
+                .append(UUID.randomUUID())
+                .append("@apache.org").toString();
+            
+            Object o = outObjects.remove(bodyParts);
+            
+            AttachmentImpl att = new AttachmentImpl(id);
+            att.setDataHandler((DataHandler) o);
+            att.setHeader("Content-Type", (String)mpi.getProperty(Message.CONTENT_TYPE));
+            atts.add(att);
+        }
+    }
+
+    private Collection<Attachment> setupAttachmentOutput(SoapMessage message) {
+        // We have attachments, so add the interceptor
+        message.getInterceptorChain().add(new AttachmentOutInterceptor());
+        // We should probably come up with another property for this
+        message.put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE);
+        
+        
+        Collection<Attachment> atts = message.getAttachments();
+        if (atts == null) {
+            atts = new ArrayList<Attachment>();
+            message.setAttachments(atts);
+        }
+        return atts;
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Thu May 24 15:33:40 2007
@@ -43,6 +43,8 @@
 import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
 import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
 import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
+import org.apache.cxf.jaxws.interceptors.SwAInInterceptor;
+import org.apache.cxf.jaxws.interceptors.SwAOutInterceptor;
 import org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor;
 import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
 import org.apache.cxf.service.Service;
@@ -68,6 +70,8 @@
         Interceptor soap = null;
         if (getBinding() instanceof SoapBinding) {
             soap = new SOAPHandlerInterceptor(binding);
+            getInInterceptors().add(new SwAInInterceptor());
+            getOutInterceptors().add(new SwAOutInterceptor());
         } else {
              // TODO: what for non soap bindings?
         }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ConfiguredEndpointTest.java
Thu May 24 15:33:40 2007
@@ -290,11 +290,11 @@
         assertTrue("Unexpected value for property validating", 
                    Boolean.valueOf((String) ei.getProperties().get(Message.SCHEMA_VALIDATION_ENABLED)));
         List<Interceptor> interceptors = endpoint.getInInterceptors();
-        assertEquals("Unexpected number of interceptors.", 5, interceptors.size());
+        assertEquals("Unexpected number of interceptors.", 6, interceptors.size());
         assertEquals("Unexpected interceptor id.", "endpoint-in", 
                      findTestInterceptor(interceptors).getId());
         interceptors = endpoint.getOutInterceptors();
-        assertEquals("Unexpected number of interceptors.", 6, interceptors.size());
+        assertEquals("Unexpected number of interceptors.", 7, interceptors.size());
         assertEquals("Unexpected interceptor id.", "endpoint-out", 
                      findTestInterceptor(interceptors).getId());
         interceptors = endpoint.getInFaultInterceptors();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java
Thu May 24 15:33:40 2007
@@ -22,18 +22,15 @@
 
 import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
-import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Holder;
-import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.cxf.swa.SwAService;
 import org.apache.cxf.swa.SwAServiceInterface;
 import org.apache.cxf.swa.types.DataStruct;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
-@Ignore
+
 public class ClientServerSwaTest extends AbstractBusClientServerTestBase {
 
     @BeforeClass
@@ -46,28 +43,54 @@
         SwAService service = new SwAService();
         
         SwAServiceInterface port = service.getSwAServiceHttpPort();
-        ((SOAPBinding) ((BindingProvider)port).getBinding()).setMTOMEnabled(true);
+//        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

+//                                                        "http://localhost:9037/swa");
         
-        Holder<DataStruct> structHolder = new Holder<DataStruct>();
+        Holder<String> textHolder = new Holder<String>();
         Holder<DataHandler> data = new Holder<DataHandler>();
         
         ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
         DataHandler handler = new DataHandler(source);
         
-        DataStruct struct = new DataStruct();
-        struct.setDataRef(handler);
         data.value = handler;
         
-        structHolder.value = struct;
+        textHolder.value = "Hi";
 
-        port.echoData(structHolder, data);
+        port.echoData(textHolder, data);
         InputStream bis = null;
         bis = data.value.getDataSource().getInputStream();
         byte b[] = new byte[10];
         bis.read(b, 0, 10);
         String string = new String(b);
         assertEquals("testfoobar", string);
-        
+        assertEquals("Hi", textHolder.value);
     }
+    
+    @Test
+    public void testSwaDataStruct() throws Exception {
+        SwAService service = new SwAService();
+        
+        SwAServiceInterface port = service.getSwAServiceHttpPort();
+//        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,

+//                                                        "http://localhost:9037/swa");
+        
+        Holder<DataStruct> structHolder = new Holder<DataStruct>();
+        
+        ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
+        DataHandler handler = new DataHandler(source);
+        
+        DataStruct struct = new DataStruct();
+        struct.setDataRef(handler);
+        structHolder.value = struct;
+
+        port.echoDataRef(structHolder);
 
+        handler = structHolder.value.getDataRef();
+        InputStream bis = null;
+        bis = handler.getDataSource().getInputStream();
+        byte b[] = new byte[10];
+        bis.read(b, 0, 10);
+        String string = new String(b);
+        assertEquals("testfoobar", string);
+    }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/Server.java Thu
May 24 15:33:40 2007
@@ -20,8 +20,8 @@
 package org.apache.cxf.systest.swa;
 
 import javax.xml.ws.Endpoint;
-import javax.xml.ws.soap.SOAPBinding;
 
+import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
 public class Server extends AbstractBusTestServerBase {
@@ -30,8 +30,9 @@
         Object implementor = new SwAServiceImpl();
         String address = "http://localhost:9036/swa";
         try {
-            Endpoint endpoint = Endpoint.publish(address, implementor);
-            ((SOAPBinding)endpoint.getBinding()).setMTOMEnabled(true);
+            EndpointImpl ep = (EndpointImpl) Endpoint.create(implementor);
+            ep.setWsdlLocation("classpath:wsdl/swa-mime.wsdl");
+            ep.publish(address);
         } catch (Exception e) {
             e.printStackTrace();
             Thread.currentThread().interrupt();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java
Thu May 24 15:33:40 2007
@@ -35,7 +35,23 @@
             portName = "SwAServiceHttpPort")
 public class SwAServiceImpl implements SwAServiceInterface {
 
-    public void echoData(Holder<DataStruct> text, Holder<DataHandler> data) {
+    public void echoDataRef(Holder<DataStruct> data) {
+        try {
+            InputStream bis = null;
+            bis = data.value.getDataRef().getDataSource().getInputStream();
+            byte b[] = new byte[6];
+            bis.read(b, 0, 6);
+            String string = new String(b);
+            
+            ByteArrayDataSource source = 
+                new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
+            data.value.setDataRef(new DataHandler(source));
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void echoData(Holder<String> text, Holder<DataHandler> data) {
 
         try {
             InputStream bis = null;
@@ -45,13 +61,11 @@
             String string = new String(b);
             
             ByteArrayDataSource source = 
-                new ByteArrayDataSource(("test" + string).getBytes(), "text/xml");
+                new ByteArrayDataSource(("test" + string).getBytes(), "application/octet-stream");
             data.value = new DataHandler(source);
         } catch (IOException e) {
-            // TODO Auto-generated catch block
-
+            e.printStackTrace();
         }
-
     }
 
 }

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl?view=diff&rev=541462&r1=541461&r2=541462
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl (original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl Thu May 24 15:33:40
2007
@@ -39,6 +39,7 @@
         </xsd:complexType>
       </xsd:element>
       
+      <xsd:element name="text" type="xsd:string"/>
     </xsd:schema>
 
     <xsd:schema targetNamespace="http://ws-i.org/profiles/basic/1.1/xsd"
@@ -49,18 +50,31 @@
     </xsd:schema>
   </wsdl:types>
 
+  <wsdl:message name="echoDataRefRequest">
+    <wsdl:part name="data" element="types:DataStruct" />
+  </wsdl:message>
+
+  <wsdl:message name="echoDataRefResponse">
+    <wsdl:part name="data" element="types:DataStruct" />
+  </wsdl:message>
+
   <wsdl:message name="echoDataRequest">
-    <wsdl:part name="text" element="types:DataStruct" />
+    <wsdl:part name="text" element="types:text" />
     <wsdl:part name="data" type="xsd:base64Binary"/>
   </wsdl:message>
 
   <wsdl:message name="echoDataResponse">
-    <wsdl:part name="text" element="types:DataStruct" />
+    <wsdl:part name="text" element="types:text" />
     <wsdl:part name="data" type="xsd:base64Binary" />
   </wsdl:message>
 
   <wsdl:portType name="SwAServiceInterface">
 
+    <wsdl:operation name="echoDataRef">
+      <wsdl:input message="tns:echoDataRefRequest" />
+      <wsdl:output message="tns:echoDataRefResponse" />
+    </wsdl:operation>
+
     <wsdl:operation name="echoData">
       <wsdl:input message="tns:echoDataRequest" />
       <wsdl:output message="tns:echoDataResponse" />
@@ -71,7 +85,17 @@
   <wsdl:binding name="SwAServiceBinding" type="tns:SwAServiceInterface">
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
 
-    <wsdl:operation name="echoData">
+    <wsdl:operation name="echoDataRef">
+      <soap:operation soapAction="" style="literal" />
+      <wsdl:input>
+        <soap:body parts="data" use="literal" />
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body parts="data" use="literal" />
+      </wsdl:output>
+    </wsdl:operation>
+
+   <wsdl:operation name="echoData">
       <soap:operation soapAction="" style="literal" />
       <wsdl:input>
         <mime:multipartRelated>
@@ -94,7 +118,6 @@
         </mime:multipartRelated>
       </wsdl:output>
     </wsdl:operation>
-
   </wsdl:binding>
 
   <wsdl:service name="SwAService">



Mime
View raw message