cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r585207 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/src/test/java/org/apache/cxf/systest/provider/ ...
Date Tue, 16 Oct 2007 17:54:34 GMT
Author: dkulp
Date: Tue Oct 16 10:54:24 2007
New Revision: 585207

URL: http://svn.apache.org/viewvc?rev=585207&view=rev
Log:
Merged revisions 585204 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r585204 | dkulp | 2007-10-16 13:35:49 -0400 (Tue, 16 Oct 2007) | 3 lines
  
  [CXF-1115] Fix issues with attachments when using provider/dispatch style services
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWSoapMessageProvider.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
    incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
Tue Oct 16 10:54:24 2007
@@ -21,12 +21,17 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.activation.DataSource;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeader;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPException;
@@ -40,6 +45,7 @@
 
 import org.w3c.dom.Node;
 
+import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -49,6 +55,7 @@
 import org.apache.cxf.databinding.source.NodeDataReader;
 import org.apache.cxf.databinding.source.XMLStreamDataReader;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
@@ -58,6 +65,7 @@
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
 import org.apache.cxf.jaxws.handler.soap.DispatchSOAPHandlerInterceptor;
+import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -111,11 +119,10 @@
             ex.put(Service.Mode.class, mode);            
             
             if (message instanceof SoapMessage) {
-                SOAPMessage soapMessage = newSOAPMessage(is, ((SoapMessage)message).getVersion());
+                SOAPMessage soapMessage = newSOAPMessage(is, (SoapMessage)message);
                 PostDispatchSOAPHandlerInterceptor postSoap = new PostDispatchSOAPHandlerInterceptor();
                 message.getInterceptorChain().add(postSoap);
                 
-                //soapMessage.writeTo(System.out);
                 message.setContent(SOAPMessage.class, soapMessage);               
             } else if (message instanceof XMLMessage) {
                 if (type.equals(DataSource.class)) {
@@ -144,16 +151,25 @@
             message.getInterceptorChain().add(postLogical);      
             
             is.close();
+            message.removeContent(InputStream.class);
         } catch (Exception e) {
             throw new Fault(e);
         }
     }
 
-    private SOAPMessage newSOAPMessage(InputStream is, SoapVersion version) throws Exception
{
-        // TODO: Get header from message, this interceptor should after
-        // readHeadersInterceptor
+    private SOAPMessage newSOAPMessage(InputStream is, SoapMessage msg) throws Exception
{
+        SoapVersion version = msg.getVersion();
 
         MimeHeaders headers = new MimeHeaders();
+        if (msg.containsKey(Message.PROTOCOL_HEADERS)) {
+            Map<String, List<String>> heads = CastUtils.cast((Map<?, ?>)msg.get(Message.PROTOCOL_HEADERS));
+            for (Map.Entry<String, List<String>> entry : heads.entrySet()) {
+                for (String val : entry.getValue()) {
+                    headers.addHeader(entry.getKey(), val);
+                }
+            }
+        }
+        
         MessageFactory msgFactory = null;
         if (version == null || version instanceof Soap11) {
             msgFactory = MessageFactory.newInstance();
@@ -187,6 +203,24 @@
                         //This seems to be a problem in SAAJ. Envelope might not be initialized
properly 
                         //without calling getEnvelope()
                         soapMessage.getSOAPPart().getEnvelope();
+                        if (soapMessage.countAttachments() > 0) {
+                            if (message.getAttachments() == null) {
+                                message.setAttachments(new ArrayList<Attachment>(soapMessage
+                                        .countAttachments()));
+                            }
+                            Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
+                            while (it.hasNext()) {
+                                AttachmentPart part = it.next();
+                                AttachmentImpl att = new AttachmentImpl(part.getContentId());
+                                att.setDataHandler(part.getDataHandler());
+                                Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
+                                while (it2.hasNext()) {
+                                    MimeHeader header = it2.next();
+                                    att.setHeader(header.getName(), header.getValue());
+                                }
+                                message.getAttachments().add(att);
+                            }
+                        }
                     } catch (SOAPException e) {
                         throw new Fault(e);
                     } 
@@ -227,13 +261,30 @@
 
                 if (SOAPMessage.class.isAssignableFrom(type)) {
                     try {
-                        CachedOutputStream cos = new CachedOutputStream();
-                        Transformer transformer = XMLUtils.newTransformer();
-                        transformer.transform(source, new StreamResult(cos));
-                        InputStream in = cos.getInputStream();
-                        obj = newSOAPMessage(in, ((SoapMessage)message).getVersion());
-                        in.close();
-                        cos.close();
+                        SoapVersion version = ((SoapMessage)message).getVersion();
+                        MessageFactory msgFactory = null;
+                        if (version == null || version instanceof Soap11) {
+                            msgFactory = MessageFactory.newInstance();
+                        } else if (version instanceof Soap12) {
+                            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+                        }
+                        SOAPMessage msg = msgFactory.createMessage();
+                        msg.getSOAPPart().setContent(source);
+                        
+                        if (message.getAttachments() != null) {
+                            for (Attachment att : message.getAttachments()) {
+                                AttachmentPart part = msg.createAttachmentPart(att.getDataHandler());
+                                if (att.getId() != null) {
+                                    part.setContentId(att.getId());
+                                }
+                                for (Iterator<String> it = att.getHeaderNames(); it.hasNext();)
{
+                                    String s = it.next();
+                                    part.setMimeHeader(s, att.getHeader(s));
+                                }
+                                msg.addAttachmentPart(part);
+                            }
+                        }
+                        obj = msg;
                     } catch (Exception e) {
                         throw new Fault(e);
                     } 

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
Tue Oct 16 10:54:24 2007
@@ -22,15 +22,23 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.activation.DataSource;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeader;
 import javax.xml.soap.MimeHeaders;
 import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
@@ -42,6 +50,7 @@
 
 import org.w3c.dom.Node;
 
+import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -49,14 +58,15 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.source.NodeDataWriter;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
+import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.XMLMessage;
 import org.apache.cxf.phase.Phase;
@@ -77,9 +87,6 @@
     }
 
     public void handleMessage(Message message) throws Fault {
-        org.apache.cxf.service.Service service = 
-            message.getExchange().get(org.apache.cxf.service.Service.class);
-
         Object obj = null;
         Object result = message.getContent(List.class);
         if (result != null) {
@@ -97,26 +104,7 @@
         if (message instanceof SoapMessage) {
             Source source = null;
             if (mode == Service.Mode.PAYLOAD) {
-                if (obj instanceof SOAPMessage || obj instanceof DataSource) {
-                    throw new Fault(
-                                    new org.apache.cxf.common.i18n.Message(
-                                        "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING",
-                                        LOG, obj.getClass(), "PAYLOAD"));
-                } else if (obj instanceof Source) {
-                    source = (Source)obj;
-                } else {
-                    //JAXB
-                    try {
-                        SOAPMessage msg = newSOAPMessage(null, ((SoapMessage)message).getVersion());
-                        DataWriter<Node> dataWriter = getDataWriter(message, service,
Node.class);
-                        dataWriter.write(obj, msg.getSOAPBody());
-                        //msg.writeTo(System.out);
-                        source = new DOMSource(DOMUtils.getChild(msg.getSOAPBody(), Node.ELEMENT_NODE));
-                    } catch (Exception e) {
-                        throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT",
-                                                                               LOG), e);
-                    }
-                }
+                source = handlePayloadMode(obj, message);
             } else {
                 if (obj instanceof DataSource) {
                     throw new Fault(
@@ -124,7 +112,8 @@
                                         "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING",
                                         LOG, "DataSource", "MESSAGE"));
                 } else if (obj instanceof SOAPMessage) {
-                    source = new DOMSource(((SOAPMessage)obj).getSOAPPart());
+                    source = handleSOAPMessage(obj, message);
+
                 } else if (obj instanceof Source) {
                     source = (Source)obj;
                 } 
@@ -157,6 +146,8 @@
             } else {
                 // JAXB element
                 try {
+                    org.apache.cxf.service.Service service = 
+                        message.getExchange().get(org.apache.cxf.service.Service.class);
                     DataWriter<XMLStreamWriter> dataWriter = getDataWriter(message,
service,
                                                                            XMLStreamWriter.class);
                     W3CDOMStreamWriter xmlWriter = new W3CDOMStreamWriter();
@@ -173,6 +164,68 @@
         message.getInterceptorChain().add(ending);
     }
     
+    private Source handleSOAPMessage(Object obj, Message message) {
+        SOAPMessage soapMessage = (SOAPMessage)obj;
+        try {
+            //workaround bug in Sun SAAJ impl
+            soapMessage.getSOAPPart().getEnvelope();
+        } catch (SOAPException e1) {
+            //ignore
+        }
+        Source source = new DOMSource(soapMessage.getSOAPPart());
+        
+        if (soapMessage.countAttachments() > 0) {
+            if (message.getAttachments() == null) {
+                message.setAttachments(new ArrayList<Attachment>(soapMessage
+                        .countAttachments()));
+            }
+            Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
+            while (it.hasNext()) {
+                AttachmentPart part = it.next();
+                AttachmentImpl att = new AttachmentImpl(part.getContentId());
+                try {
+                    att.setDataHandler(part.getDataHandler());
+                } catch (SOAPException e) {
+                    throw new Fault(e);
+                }
+                Iterator<MimeHeader> it2 = CastUtils.cast(part.getAllMimeHeaders());
+                while (it2.hasNext()) {
+                    MimeHeader header = it2.next();
+                    att.setHeader(header.getName(), header.getValue());
+                }
+                message.getAttachments().add(att);
+            }
+        }
+        return source;
+    }
+
+    private Source handlePayloadMode(Object obj, Message message) {
+        Source source = null;
+        if (obj instanceof SOAPMessage || obj instanceof DataSource) {
+            throw new Fault(
+                            new org.apache.cxf.common.i18n.Message(
+                                "DISPATCH_OBJECT_NOT_SUPPORTED_SOAPBINDING",
+                                LOG, obj.getClass(), "PAYLOAD"));
+        } else if (obj instanceof Source) {
+            source = (Source)obj;
+        } else {
+            //JAXB
+            try {
+                org.apache.cxf.service.Service service = 
+                    message.getExchange().get(org.apache.cxf.service.Service.class);
+                SOAPMessage msg = newSOAPMessage(null, ((SoapMessage)message).getVersion());
+                DataWriter<Node> dataWriter = getDataWriter(message, service, Node.class);
+                dataWriter.write(obj, msg.getSOAPBody());
+                //msg.writeTo(System.out);
+                source = new DOMSource(DOMUtils.getChild(msg.getSOAPBody(), Node.ELEMENT_NODE));
+            } catch (Exception e) {
+                throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT",
+                                                                       LOG), e);
+            }
+        }
+        return source;
+    }
+
     private class DispatchOutDatabindingEndingInterceptor extends AbstractOutDatabindingInterceptor
{
         public DispatchOutDatabindingEndingInterceptor() {
             super(Phase.WRITE_ENDING);
@@ -190,6 +243,27 @@
                 if (xmlWriter != null) {
                     xmlWriter.flush();
                 } else if (soapMessage != null) {
+                    Map<String, List<String>> heads 
+                        = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+                    if (heads == null) {
+                        heads = new HashMap<String, List<String>>();
+                        message.put(Message.PROTOCOL_HEADERS, heads);
+                    }
+                    
+                    //soapMessage.saveChanges();
+                    Iterator<MimeHeader> smh = CastUtils.cast(soapMessage.getMimeHeaders().getAllHeaders());
+                    while (smh.hasNext()) {
+                        MimeHeader head = smh.next();
+                        if ("Content-Type".equals(head.getName())) {
+                            message.put(Message.CONTENT_TYPE, head.getValue());
+                        } else if (!"Content-Length".equals(head.getName())) {
+                            if (!heads.containsKey(head.getName())) {
+                                heads.put(head.getName(), new ArrayList<String>());
+                            }
+                            List<String>l = heads.get(head.getName());
+                            l.add(head.getValue());
+                        }
+                    }
                     soapMessage.writeTo(os);
                 } else if (source != null) {
                     doTransform(source, os);
@@ -200,6 +274,7 @@
                 // Finish the message processing, do flush
                 os.flush();
             } catch (Exception ex) {
+                ex.printStackTrace();
                 throw new Fault(new org.apache.cxf.common.i18n.Message("EXCEPTION_WRITING_OBJECT",
LOG, ex));
             }
         }      
@@ -221,6 +296,20 @@
                 Source source = message.getContent(Source.class);
                 message.removeContent(Source.class);
 
+                //workaround bug in Sun SAAJ impl where
+                //source doesn't work if the SOAPPart was already 
+                //created from a source
+                if (source instanceof DOMSource) {
+                    DOMSource ds = (DOMSource)source;
+                    if (ds.getNode() instanceof SOAPPart) {
+                        try {
+                            ((SOAPPart)ds.getNode()).getEnvelope();
+                        } catch (SOAPException e) {
+                            //ignore
+                        }
+                    }
+                }
+                
                 if (mode == Service.Mode.PAYLOAD) {
                     // Input is Source in payload mode, need to wrap it
                     // with a SOAPMessage
@@ -234,14 +323,32 @@
                     }
                 } else {
                     try {
-                        CachedOutputStream cos = new CachedOutputStream();
-                        Transformer transformer = XMLUtils.newTransformer();
-                        transformer.transform(source, new StreamResult(cos));
-                        InputStream in = cos.getInputStream();
-                        obj = newSOAPMessage(in, ((SoapMessage)message).getVersion());
-                        in.close();
-                        cos.close();
+                        SoapVersion version = ((SoapMessage)message).getVersion();
+                        MessageFactory msgFactory = null;
+                        if (version == null || version instanceof Soap11) {
+                            msgFactory = MessageFactory.newInstance();
+                        } else if (version instanceof Soap12) {
+                            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+                        }
+                        SOAPMessage msg = msgFactory.createMessage();
+                        msg.getSOAPPart().setContent(source);
+                        msg.saveChanges();
+                        if (message.getAttachments() != null) {
+                            for (Attachment att : message.getAttachments()) {
+                                AttachmentPart part = msg.createAttachmentPart(att.getDataHandler());
+                                if (att.getId() != null) {
+                                    part.setContentId(att.getId());
+                                }
+                                for (Iterator<String> it = att.getHeaderNames(); it.hasNext();)
{
+                                    String s = it.next();
+                                    part.setMimeHeader(s, att.getHeader(s));
+                                }
+                                msg.addAttachmentPart(part);
+                            }
+                        }
+                        obj = msg;                    
                     } catch (Exception e) {
+                        e.printStackTrace();
                         throw new Fault(e);
                     }
                 }                

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Tue Oct 16 10:54:24 2007
@@ -276,32 +276,34 @@
                     new HTTPServerPolicy(), HTTPServerPolicy.class);
         }
     }
-
+    private static List<String> createMutableList(String val) {
+        return new ArrayList<String>(Arrays.asList(new String[] {val}));
+    }
     void setPolicies(Map<String, List<String>> headers) {
         HTTPServerPolicy policy = server; 
         if (policy.isSetCacheControl()) {
             headers.put("Cache-Control",
-                        Arrays.asList(new String[] {policy.getCacheControl().value()}));
+                        createMutableList(policy.getCacheControl().value()));
         }
         if (policy.isSetContentLocation()) {
             headers.put("Content-Location",
-                        Arrays.asList(new String[] {policy.getContentLocation()}));
+                        createMutableList(policy.getContentLocation()));
         }
         if (policy.isSetContentEncoding()) {
             headers.put("Content-Encoding",
-                        Arrays.asList(new String[] {policy.getContentEncoding()}));
+                        createMutableList(policy.getContentEncoding()));
         }
         if (policy.isSetContentType()) {
             headers.put(HttpHeaderHelper.CONTENT_TYPE,
-                        Arrays.asList(new String[] {policy.getContentType()}));
+                        createMutableList(policy.getContentType()));
         }
         if (policy.isSetServerType()) {
             headers.put("Server",
-                        Arrays.asList(new String[] {policy.getServerType()}));
+                        createMutableList(policy.getServerType()));
         }
         if (policy.isSetHonorKeepAlive() && !policy.isHonorKeepAlive()) {
             headers.put("Connection",
-                        Arrays.asList(new String[] {"close"}));
+                        createMutableList("close"));
         }
         
     

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Tue Oct 16 10:54:24 2007
@@ -29,6 +29,7 @@
 import java.net.Proxy;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -1059,7 +1060,7 @@
             type += " ";
             type += authPolicy.getAuthorization();
             headers.put("Authorization",
-                        Arrays.asList(new String[] {type}));
+                        createMutableList(type));
         }
         AuthorizationPolicy proxyAuthPolicy = getProxyAuthorization();
         if (proxyAuthPolicy != null && proxyAuthPolicy.isSetUserName()) {
@@ -1076,11 +1077,13 @@
                 type += " ";
                 type += proxyAuthPolicy.getAuthorization();
                 headers.put("Proxy-Authorization",
-                            Arrays.asList(new String[] {type}));
+                            createMutableList(type));
             }
         }
     }
-    
+    private static List<String> createMutableList(String val) {
+        return new ArrayList<String>(Arrays.asList(new String[] {val}));
+    }
     /**
      * This call places HTTP Header strings into the headers that are relevant
      * to the ClientPolicy that is set on this conduit by configuration.
@@ -1097,44 +1100,44 @@
         }
         if (policy.isSetCacheControl()) {
             headers.put("Cache-Control",
-                Arrays.asList(new String[] {policy.getCacheControl().value()}));
+                        createMutableList(policy.getCacheControl().value()));
         }
         if (policy.isSetHost()) {
             headers.put("Host",
-                Arrays.asList(new String[] {policy.getHost()}));
+                        createMutableList(policy.getHost()));
         }
         if (policy.isSetConnection()) {
             headers.put("Connection",
-                Arrays.asList(new String[] {policy.getConnection().value()}));
+                        createMutableList(policy.getConnection().value()));
         }
         if (policy.isSetAccept()) {
             headers.put("Accept",
-                Arrays.asList(new String[] {policy.getAccept()}));
+                        createMutableList(policy.getAccept()));
         } else {
-            headers.put("Accept", Arrays.asList(new String[] {"*"}));
+            headers.put("Accept", createMutableList("*"));
         }
         if (policy.isSetAcceptEncoding()) {
             headers.put("Accept-Encoding",
-                Arrays.asList(new String[] {policy.getAcceptEncoding()}));
+                        createMutableList(policy.getAcceptEncoding()));
         }
         if (policy.isSetAcceptLanguage()) {
             headers.put("Accept-Language",
-                Arrays.asList(new String[] {policy.getAcceptLanguage()}));
+                        createMutableList(policy.getAcceptLanguage()));
         }
         if (policy.isSetContentType()) {
             message.put(Message.CONTENT_TYPE, policy.getContentType());
         }
         if (policy.isSetCookie()) {
             headers.put("Cookie",
-                Arrays.asList(new String[] {policy.getCookie()}));
+                        createMutableList(policy.getCookie()));
         }
         if (policy.isSetBrowserType()) {
             headers.put("BrowserType",
-                Arrays.asList(new String[] {policy.getBrowserType()}));
+                        createMutableList(policy.getBrowserType()));
         }
         if (policy.isSetReferer()) {
             headers.put("Referer",
-                Arrays.asList(new String[] {policy.getReferer()}));
+                        createMutableList(policy.getReferer()));
         }
     }
 
@@ -1651,7 +1654,7 @@
         }
         String token = Base64Utility.encode(userpass.getBytes());
         headers.put("Authorization",
-                    Arrays.asList(new String[] {"Basic " + token}));
+                    createMutableList("Basic " + token));
     }
 
     /**
@@ -1677,7 +1680,7 @@
         }
         String token = Base64Utility.encode(userpass.getBytes());
         headers.put("Proxy-Authorization",
-                    Arrays.asList(new String[] {"Basic " + token}));
+                    createMutableList("Basic " + token));
     }
     
     /**
@@ -1905,8 +1908,10 @@
             Map<String, List<String>> headers = 
                 new HashMap<String, List<String>>();
             for (String key : connection.getHeaderFields().keySet()) {
-                headers.put(HttpHeaderHelper.getHeaderKey(key), 
+                if (key != null) {
+                    headers.put(HttpHeaderHelper.getHeaderKey(key), 
                         connection.getHeaderFields().get(key));
+                }
             }
             
             inMessage.put(Message.PROTOCOL_HEADERS, headers);

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWSoapMessageProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWSoapMessageProvider.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWSoapMessageProvider.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/HWSoapMessageProvider.java
Tue Oct 16 10:54:24 2007
@@ -22,6 +22,7 @@
 
 import javax.jws.HandlerChain;
 import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPMessage;
@@ -75,6 +76,15 @@
                 response = sayHiResponse;
             } else if (n.getLocalName().equals(greetMe.getLocalPart())) {
                 response = greetMeResponse;
+            } else if (n.getLocalName().equals("sayHiWAttach")) {
+                MessageFactory factory = MessageFactory.newInstance();            
+                InputStream is = getClass().getResourceAsStream("resources/sayHiRpcLiteralResp.xml");
+                response = factory.createMessage(null, is);
+                is.close();
+                
+                AttachmentPart ap1 = response.createAttachmentPart();
+                ap1.setContent("Return Attachment content", "text/plain");
+                response.addAttachmentPart(ap1);
             }
         } catch (Exception ex) {
             ex.printStackTrace();

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/ProviderRPCClientServerTest.java
Tue Oct 16 10:54:24 2007
@@ -23,6 +23,12 @@
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPMessage;
 
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.hello_world_rpclit.GreeterRPCLit;
@@ -35,6 +41,27 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", launchServer(Server.class));
+    }
+    
+    @Test
+    public void testSWA() throws Exception {
+        SOAPFactory soapFac = SOAPFactory.newInstance();
+        MessageFactory msgFac = MessageFactory.newInstance();
+        SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
+        SOAPMessage msg = msgFac.createMessage();
+        
+        QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach");
+        msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
+        AttachmentPart ap1 = msg.createAttachmentPart();
+        ap1.setContent("Attachment content", "text/plain");
+        msg.addAttachmentPart(ap1);
+        
+        SOAPConnection con = conFac.createConnection();
+        URL endpoint = new URL("http://localhost:9008/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1");
+        SOAPMessage response = con.call(msg, endpoint); 
+        QName sayHiResp = new QName("http://apache.org/hello_world_rpclit", "sayHiResponse");
+        assertNotNull(response.getSOAPBody().getChildElements(sayHiResp));
+        assertEquals(1, response.countAttachments());
     }
 
     private void doGreeterRPCLit(SOAPServiceRPCLit service, QName portName, int count) throws
Exception {

Modified: incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=585207&r1=585206&r2=585207&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Oct 16 10:54:24 2007
@@ -328,7 +328,6 @@
                                           output.getCanonicalPath() + "/classes", "-d",
                                           output.getCanonicalPath(), "-b",
                                           getLocation("/wsdl2java_wsdl/bug305924/binding1.xml"),
-                                          "-verbose",
                                           getLocation("/wsdl2java_wsdl/bug305924/hello_world.wsdl")};
             WSDLToJava.main(args);
         } catch (Exception e) {



Mime
View raw message