cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r765773 [1/2] - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ rt/core/src/main/java/org/apache/cxf/attachment/ rt/core/src/main/java/org/apache/cxf/data...
Date Thu, 16 Apr 2009 21:36:55 GMT
Author: dkulp
Date: Thu Apr 16 21:36:54 2009
New Revision: 765773

URL: http://svn.apache.org/viewvc?rev=765773&view=rev
Log:
[CXF-1907] First part of refactoring the dispatch/provider stuff to use the same runtime parts as the non-dispatch stuff
This gets the dispatch stuff fairly close.  Provider stuff is untouched.   More cruft will be removed when provider is done.

Added:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java   (with props)
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java   (with props)
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java   (with props)
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsResponseCallback.java   (with props)
Removed:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/BindingProviderImpl.java
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/Messages.properties
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalHandlerOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/logical/LogicalMessageImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/DummyImpl.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/handlers/DispatchHandlerInvocationTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/AbstractDOMStreamReader.java Thu Apr 16 21:36:54 2009
@@ -76,16 +76,18 @@
             this.parent = parent;
             this.currentChild = ch;
         }
-        public ElementFrame(T doc) {
+        public ElementFrame(T doc, boolean s) {
             this.element = doc;
             parent = null;
-            started = true;
+            started = s;
             attributes = Collections.emptyList();
             prefixes = Collections.emptyList();
             uris = Collections.emptyList();
             allAttributes = Collections.emptyList();
         }
-        
+        public ElementFrame(T doc) {
+            this(doc, true);
+        }        
         public T getElement() {
             return element;
         }
@@ -96,7 +98,12 @@
         public void setCurrentChild(I o) {
             currentChild = o;
         }
-
+        public boolean isDocument() {
+            return false;
+        }
+        public boolean isDocumentFragment() {
+            return false;
+        }
     }
 
     /**
@@ -138,7 +145,7 @@
 
         if (!frame.started) {
             frame.started = true;
-            currentEvent = START_ELEMENT;
+            currentEvent = frame.isDocument() ? START_DOCUMENT : START_ELEMENT;
         } else if (frame.currentAttribute < getAttributeCount() - 1) {
             frame.currentAttribute++;
             currentEvent = ATTRIBUTE;
@@ -159,8 +166,12 @@
             }
         } else {
             frame.ended = true;
-            currentEvent = END_ELEMENT;
-            endElement();
+            if (frame.isDocument()) {
+                currentEvent = END_DOCUMENT;                
+            } else {
+                currentEvent = END_ELEMENT;
+                endElement();
+            }
         }
         return currentEvent;
     }
@@ -213,7 +224,8 @@
      * @see javax.xml.stream.XMLStreamReader#hasNext()
      */
     public boolean hasNext() throws XMLStreamException {
-        return !(frames.size() == 0 && frame.ended);
+        
+        return !(frame.ended && (frames.size() == 0 || frame.isDocumentFragment()));
 
     }
 

Added: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java?rev=765773&view=auto
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java (added)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java Thu Apr 16 21:36:54 2009
@@ -0,0 +1,112 @@
+/**
+ * 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.staxutils;
+
+
+import javax.xml.stream.XMLStreamException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.common.util.StringUtils;
+
+
+/**
+ * Special StreamWriter that will "overlay" any write events onto the DOM.
+ * If the startElement ends up writing an element that already exists at that
+ * location, it will just walk into it instead of creating a new element
+ */
+public class OverlayW3CDOMStreamWriter extends W3CDOMStreamWriter {
+
+    public OverlayW3CDOMStreamWriter(Document document) {
+        super(document);
+    }
+
+    public OverlayW3CDOMStreamWriter(Element e) {
+        super(e);
+    }
+    
+    public void writeStartElement(String local) throws XMLStreamException {
+        Element nd = getCurrentNode();
+        Node nd2 = null;
+        if (nd == null) {
+            nd2 = getDocument().getDocumentElement();
+        } else {
+            nd2 = nd.getFirstChild();
+        }
+        while (nd2 != null) {
+            if (nd2.getNodeType() == Node.ELEMENT_NODE 
+                && local.equals(nd2.getLocalName())
+                && StringUtils.isEmpty(nd2.getNamespaceURI())) {
+                setChild((Element)nd2, false);
+                return;
+            }
+            nd2 = nd2.getNextSibling();
+        }
+        super.writeStartElement(local);
+    }
+
+    public void writeStartElement(String namespace, String local) throws XMLStreamException {
+        Element nd = getCurrentNode();
+        Node nd2 = null;
+        if (nd == null) {
+            nd2 = getDocument().getDocumentElement();
+        } else {
+            nd2 = nd.getFirstChild();
+        }
+        while (nd2 != null) {
+            if (nd2.getNodeType() == Node.ELEMENT_NODE 
+                && local.equals(nd2.getLocalName())
+                && namespace.equals(nd2.getNamespaceURI())) {
+                setChild((Element)nd2, false);
+                return;
+            }
+            nd2 = nd2.getNextSibling();
+        }
+        super.writeStartElement(namespace, local);
+    }
+
+    public void writeStartElement(String prefix, String local, String namespace) throws XMLStreamException {
+        if (prefix == null || prefix.equals("")) {
+            writeStartElement(namespace, local);
+        } else {
+            Element nd = getCurrentNode();
+            Node nd2 = null;
+            if (nd == null) {
+                nd2 = getDocument().getDocumentElement();
+            } else {
+                nd2 = nd.getFirstChild();
+            }
+            
+            while (nd2 != null) {
+                if (nd2.getNodeType() == Node.ELEMENT_NODE 
+                    && local.equals(nd2.getLocalName())
+                    && namespace.equals(nd2.getNamespaceURI())) {
+                    setChild((Element)nd2, false);
+                    return;
+                }
+                nd2 = nd2.getNextSibling();
+            }
+            super.writeStartElement(prefix, local, namespace);
+        }
+    }
+
+    
+}

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/OverlayW3CDOMStreamWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java?rev=765773&view=auto
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java (added)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java Thu Apr 16 21:36:54 2009
@@ -0,0 +1,281 @@
+/**
+ * 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.staxutils;
+
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.sax.SAXSource;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class StaxSource extends SAXSource implements XMLReader {
+
+    private XMLStreamReader streamReader;
+
+    private ContentHandler contentHandler;
+    
+    private LexicalHandler lexicalHandler;
+
+    public StaxSource(XMLStreamReader streamReader) {
+        this.streamReader = streamReader;
+        setInputSource(new InputSource());
+    }
+
+    public XMLReader getXMLReader() {
+        return this;
+    }
+
+    public XMLStreamReader getXMLStreamReader() {
+        return streamReader;
+    }
+
+    protected void parse() throws SAXException {
+        try {
+            while (true) {
+                switch (streamReader.getEventType()) {
+                // Attributes are handled in START_ELEMENT
+                case XMLStreamConstants.ATTRIBUTE:
+                    break;
+                case XMLStreamConstants.CDATA:
+                {
+                    if (lexicalHandler != null) {
+                        lexicalHandler.startCDATA();
+                    }
+                    int length = streamReader.getTextLength();
+                    int start = streamReader.getTextStart();
+                    char[] chars = streamReader.getTextCharacters();
+                    contentHandler.characters(chars, start, length);
+                    if (lexicalHandler != null) {
+                        lexicalHandler.endCDATA();
+                    }
+                    break;
+                }
+                case XMLStreamConstants.CHARACTERS:
+                {
+                    int length = streamReader.getTextLength();
+                    int start = streamReader.getTextStart();
+                    char[] chars = streamReader.getTextCharacters();
+                    contentHandler.characters(chars, start, length);
+                    break;
+                }
+                case XMLStreamConstants.SPACE:
+                {
+                    int length = streamReader.getTextLength();
+                    int start = streamReader.getTextStart();
+                    char[] chars = streamReader.getTextCharacters();
+                    contentHandler.ignorableWhitespace(chars, start, length);
+                    break;
+                }
+                case XMLStreamConstants.COMMENT:
+                    if (lexicalHandler != null) {
+                        int length = streamReader.getTextLength();
+                        int start = streamReader.getTextStart();
+                        char[] chars = streamReader.getTextCharacters();
+                        lexicalHandler.comment(chars, start, length);
+                    }
+                    break;
+                case XMLStreamConstants.DTD:
+                    break;
+                case XMLStreamConstants.END_DOCUMENT:
+                    contentHandler.endDocument();
+                    return;
+                case XMLStreamConstants.END_ELEMENT: {
+                    String uri = streamReader.getNamespaceURI();
+                    String localName = streamReader.getLocalName();
+                    String prefix = streamReader.getPrefix();
+                    String qname = prefix != null && prefix.length() > 0 
+                        ? prefix + ":" + localName : localName;
+                    contentHandler.endElement(uri, localName, qname);
+                    //for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+                    //    contentHandler.endPrefixMapping(streamReader.getNamespaceURI(i));
+                    //}
+                    break;
+                }
+                case XMLStreamConstants.ENTITY_DECLARATION:
+                case XMLStreamConstants.ENTITY_REFERENCE:
+                case XMLStreamConstants.NAMESPACE:
+                case XMLStreamConstants.NOTATION_DECLARATION:
+                    break;
+                case XMLStreamConstants.PROCESSING_INSTRUCTION:
+                    break;
+                case XMLStreamConstants.START_DOCUMENT:
+                    contentHandler.startDocument();
+                    break;
+                case XMLStreamConstants.START_ELEMENT: {
+                    //for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+                    //    contentHandler.startPrefixMapping(streamReader.getNamespacePrefix(i),
+                    //                                      streamReader.getNamespaceURI(i));
+                    //}
+                    String uri = streamReader.getNamespaceURI();
+                    String localName = streamReader.getLocalName();
+                    String prefix = streamReader.getPrefix();
+                    String qname = prefix != null && prefix.length() > 0 
+                        ? prefix + ":" + localName : localName;
+                    contentHandler.startElement(uri == null ? "" : uri, localName, qname, getAttributes());
+                    break;
+                }
+                default:
+                    break;
+                }
+                streamReader.next();
+            }
+        } catch (XMLStreamException e) {
+            SAXParseException spe;
+            if (e.getLocation() != null) {
+                spe = new SAXParseException(e.getMessage(), null, null,
+                                            e.getLocation().getLineNumber(),
+                                            e.getLocation().getColumnNumber(), e);
+            } else {
+                spe = new SAXParseException(e.getMessage(), null, null, -1, -1, e);
+            }
+            spe.initCause(e);
+            throw spe;
+        }
+    }
+
+    protected String getQualifiedName() {
+        String prefix = streamReader.getPrefix();
+        if (prefix != null && prefix.length() > 0) {
+            return prefix + ":" + streamReader.getLocalName();
+        } else {
+            return streamReader.getLocalName();
+        }
+    }
+
+    protected Attributes getAttributes() {
+        AttributesImpl attrs = new AttributesImpl();
+        // Adding namespace declaration as attributes is necessary because
+        // the xalan implementation that ships with SUN JDK 1.4 is bugged
+        // and does not handle the startPrefixMapping method
+        for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+            String prefix = streamReader.getNamespacePrefix(i);
+            String uri = streamReader.getNamespaceURI(i);
+            if (uri == null) {
+                uri = "";
+            }
+            // Default namespace
+            if (prefix == null || prefix.length() == 0) {
+                attrs.addAttribute(XMLConstants.DEFAULT_NS_PREFIX, 
+                                   null, 
+                                   XMLConstants.XMLNS_ATTRIBUTE, 
+                                   "CDATA", 
+                                   uri);
+            } else {
+                attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, 
+                                   prefix, 
+                                   XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, 
+                                   "CDATA", 
+                                   uri);
+            }
+        }
+        for (int i = 0; i < streamReader.getAttributeCount(); i++) {
+            String uri = streamReader.getAttributeNamespace(i);
+            String localName = streamReader.getAttributeLocalName(i);
+            String prefix = streamReader.getAttributePrefix(i);
+            String qName;
+            if (prefix != null && prefix.length() > 0) {
+                qName = prefix + ':' + localName;
+            } else {
+                qName = localName;
+            }
+            String type = streamReader.getAttributeType(i);
+            String value = streamReader.getAttributeValue(i);
+            if (value == null) {
+                value = "";
+            }
+
+            attrs.addAttribute(uri == null ? "" : uri, localName, qName, type, value);
+        }
+        return attrs;
+    }
+
+    public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+        return false;
+    }
+
+    public void setFeature(String name, boolean value) 
+        throws SAXNotRecognizedException, SAXNotSupportedException {
+    }
+
+    public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+        return null;
+    }
+
+    public void setProperty(String name, Object value) 
+        throws SAXNotRecognizedException, SAXNotSupportedException {
+        if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
+            lexicalHandler = (LexicalHandler) value;
+        } else {
+            throw new SAXNotRecognizedException(name);
+        }
+    }
+
+    public void setEntityResolver(EntityResolver resolver) {
+    }
+
+    public EntityResolver getEntityResolver() {
+        return null;
+    }
+
+    public void setDTDHandler(DTDHandler handler) {
+    }
+
+    public DTDHandler getDTDHandler() {
+        return null;
+    }
+
+    public void setContentHandler(ContentHandler handler) {
+        this.contentHandler = handler;
+    }
+
+    public ContentHandler getContentHandler() {
+        return this.contentHandler;
+    }
+
+    public void setErrorHandler(ErrorHandler handler) {
+    }
+
+    public ErrorHandler getErrorHandler() {
+        return null;
+    }
+
+    public void parse(InputSource input) throws SAXException {
+        StaxSource.this.parse();
+    }
+
+    public void parse(String systemId) throws SAXException {
+        StaxSource.this.parse();
+    }
+
+}

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxSource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Thu Apr 16 21:36:54 2009
@@ -54,6 +54,7 @@
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
 import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 import org.w3c.dom.EntityReference;
 import org.w3c.dom.NamedNodeMap;
@@ -659,6 +660,15 @@
         case Node.DOCUMENT_NODE:
             writeDocument((Document)n, writer, repairing);
             break;
+        case Node.DOCUMENT_FRAGMENT_NODE: {
+            DocumentFragment frag = (DocumentFragment)n;
+            Node child = frag.getFirstChild();
+            while (child != null) {
+                writeNode(child, writer, repairing);
+                child = child.getNextSibling();
+            }
+            break;
+        }
         default:
             throw new IllegalStateException("Found type: " + n.getClass().getName());
         }        

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java Thu Apr 16 21:36:54 2009
@@ -27,6 +27,7 @@
 import org.w3c.dom.Attr;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -54,9 +55,21 @@
         this.document = element.getOwnerDocument();
     }
     public W3CDOMStreamReader(Document doc) {
-        super(new ElementFrame<Node, Node>(doc));
+        super(new ElementFrame<Node, Node>(doc, false) {
+            public boolean isDocument() {
+                return true;
+            }
+        });
         this.document = doc;
     }
+    public W3CDOMStreamReader(DocumentFragment docfrag) {
+        super(new ElementFrame<Node, Node>(docfrag, true) {
+            public boolean isDocumentFragment() {
+                return true;
+            }
+        });
+        this.document = docfrag.getOwnerDocument();
+    }
 
     /**
      * Get the document associated with this stream.

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java Thu Apr 16 21:36:54 2009
@@ -30,16 +30,18 @@
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 import org.apache.cxf.helpers.MapNamespaceContext;
 import org.apache.cxf.helpers.XMLUtils;
 
 public class W3CDOMStreamWriter implements XMLStreamWriter {
     static final String XML_NS = "http://www.w3.org/2000/xmlns/";
-    private Stack<Element> stack = new Stack<Element>();
+    private Stack<Node> stack = new Stack<Node>();
     private Document document;
-    private Element currentNode;
+    private Node currentNode;
     private NamespaceContext context = new W3CNamespaceContext();
     private boolean nsRepairing;
     private Map properties = Collections.EMPTY_MAP;
@@ -55,6 +57,10 @@
     public W3CDOMStreamWriter(Document document) {
         this.document = document;
     }
+    public W3CDOMStreamWriter(DocumentFragment frag) {
+        this.document = frag.getOwnerDocument();
+        currentNode = frag;
+    }
 
     public W3CDOMStreamWriter(Element e) {
         this.document = e.getOwnerDocument();
@@ -64,7 +70,16 @@
     }
     
     public Element getCurrentNode() {
-        return currentNode;
+        if (currentNode instanceof Element) {
+            return (Element)currentNode;
+        }
+        return null;
+    }
+    public DocumentFragment getCurrentFragment() {
+        if (currentNode instanceof DocumentFragment) {
+            return (DocumentFragment)currentNode;
+        }
+        return null;
     }
     
     public void setNsRepairing(boolean b) {
@@ -85,12 +100,19 @@
         newChild(document.createElement(local));
     }
 
-    private void newChild(Element element) {
+    protected void newChild(Element element) {
+        setChild(element, true);
+    }
+    protected void setChild(Element element, boolean append) {
         if (currentNode != null) {
             stack.push(currentNode);
-            currentNode.appendChild(element);
+            if (append) {
+                currentNode.appendChild(element);
+            }
         } else {
-            document.appendChild(element);
+            if (append) {
+                document.appendChild(element);
+            }
         }
         if (!(context instanceof W3CNamespaceContext)) {
             context = new W3CNamespaceContext();
@@ -117,24 +139,27 @@
 
     public void writeEmptyElement(String namespace, String local) throws XMLStreamException {
         writeStartElement(namespace, local);
+        writeEndElement();
     }
 
     public void writeEmptyElement(String prefix, String namespace, String local) throws XMLStreamException {
         writeStartElement(prefix, namespace, local);
+        writeEndElement();
     }
 
     public void writeEmptyElement(String local) throws XMLStreamException {
         writeStartElement(local);
+        writeEndElement();
     }
 
     public void writeEndElement() throws XMLStreamException {
         if (stack.size() > 0) {
-            currentNode = (Element)stack.pop();
+            currentNode = stack.pop();
         } else {
             currentNode = null;
         }
-        if (context instanceof W3CNamespaceContext) {
-            ((W3CNamespaceContext)context).setElement(currentNode);
+        if (context instanceof W3CNamespaceContext && currentNode instanceof Element) {
+            ((W3CNamespaceContext)context).setElement((Element)currentNode);
         } else if (context instanceof MapNamespaceContext) {
             ((MapNamespaceContext) context).setTargetNode(currentNode);
         }
@@ -146,7 +171,7 @@
     public void writeAttribute(String local, String value) throws XMLStreamException {
         Attr a = document.createAttribute(local);
         a.setValue(value);
-        currentNode.setAttributeNode(a);
+        ((Element)currentNode).setAttributeNode(a);
     }
 
     public void writeAttribute(String prefix, String namespace, String local, String value)
@@ -157,7 +182,7 @@
         
         Attr a = document.createAttributeNS(namespace, local);
         a.setValue(value);
-        currentNode.setAttributeNodeNS(a);
+        ((Element)currentNode).setAttributeNodeNS(a);
         if (nsRepairing
             && !prefix.equals(getNamespaceContext().getPrefix(namespace))) {
             writeNamespace(prefix, namespace);
@@ -167,7 +192,7 @@
     public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
         Attr a = document.createAttributeNS(namespace, local);
         a.setValue(value);
-        currentNode.setAttributeNodeNS(a);
+        ((Element)currentNode).setAttributeNodeNS(a);
     }
 
     public void writeNamespace(String prefix, String namespace) throws XMLStreamException {
@@ -176,14 +201,14 @@
         } else {
             Attr attr = document.createAttributeNS(XML_NS, "xmlns:" + prefix);
             attr.setValue(namespace);
-            currentNode.setAttributeNodeNS(attr);
+            ((Element)currentNode).setAttributeNodeNS(attr);
         }
     }
 
     public void writeDefaultNamespace(String namespace) throws XMLStreamException {
         Attr attr = document.createAttributeNS(XML_NS, "xmlns");
         attr.setValue(namespace);
-        currentNode.setAttributeNodeNS(attr);
+        ((Element)currentNode).setAttributeNodeNS(attr);
     }
 
     public void writeComment(String value) throws XMLStreamException {

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Thu Apr 16 21:36:54 2009
@@ -20,7 +20,8 @@
 package org.apache.cxf.binding.soap.saaj;
 
 
-import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.ResourceBundle;
@@ -61,10 +62,11 @@
  * SOAPMessage.
  */
 public class SAAJOutInterceptor extends AbstractSoapInterceptor {
-
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJOutInterceptor.class);
-    private static final String ORIGINAL_XML_WRITER 
+    public static final String ORIGINAL_XML_WRITER 
         = SAAJOutInterceptor.class.getName() + ".original.xml.writer";
+    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJOutInterceptor.class);
+    
 
     public SAAJOutInterceptor() {
         super(Phase.PRE_PROTOCOL);
@@ -96,7 +98,7 @@
             } catch (SOAPException e) {
                 throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, version.getSender());
             }
-        } else {
+        } else if (!message.containsKey(ORIGINAL_XML_WRITER)) {
             //as the SOAPMessage already has everything in place, we do not need XMLStreamWriter to write
             //anything for us, so we just set XMLStreamWriter's output to a dummy output stream.         
             try {
@@ -104,15 +106,20 @@
                 message.put(ORIGINAL_XML_WRITER, origWriter);
                 
                 XMLStreamWriter dummyWriter = StaxUtils.getXMLOutputFactory()
-                    .createXMLStreamWriter(new ByteArrayOutputStream());
+                    .createXMLStreamWriter(new OutputStream() {
+                        public void write(int b) throws IOException {
+                        }
+                        public void write(byte b[], int off, int len) throws IOException {
+                        }                        
+                    });
                 message.setContent(XMLStreamWriter.class, dummyWriter);
             } catch (XMLStreamException e) {
                 // do nothing
-            }
+            }   
         }
         
         // Add a final interceptor to write the message
-        message.getInterceptorChain().add(new SAAJOutEndingInterceptor());
+        message.getInterceptorChain().add(SAAJOutEndingInterceptor.INSTANCE);
     }
     @Override
     public void handleFault(SoapMessage message) {
@@ -120,11 +127,14 @@
         XMLStreamWriter writer = (XMLStreamWriter)message.get(ORIGINAL_XML_WRITER);
         if (writer != null) {
             message.setContent(XMLStreamWriter.class, writer);
+            message.remove(ORIGINAL_XML_WRITER);
         }
     }
 
     
-    public class SAAJOutEndingInterceptor extends AbstractSoapInterceptor {
+    public static class SAAJOutEndingInterceptor extends AbstractSoapInterceptor {
+        public static final SAAJOutEndingInterceptor INSTANCE = new SAAJOutEndingInterceptor();
+        
         public SAAJOutEndingInterceptor() {
             super(SAAJOutEndingInterceptor.class.getName(), Phase.PRE_PROTOCOL_ENDING);
         }
@@ -157,11 +167,14 @@
                 }
                 
                 XMLStreamWriter writer = (XMLStreamWriter)message.get(ORIGINAL_XML_WRITER);
-                try {
-                    StaxUtils.copy(new W3CDOMStreamReader(soapMessage.getSOAPPart()), writer);
-                    writer.flush();
-                    message.setContent(XMLStreamWriter.class, writer);
+                message.remove(ORIGINAL_XML_WRITER);
 
+                try {
+                    if (writer != null) {
+                        StaxUtils.copy(new W3CDOMStreamReader(soapMessage.getSOAPPart()), writer);
+                        writer.flush();
+                        message.setContent(XMLStreamWriter.class, writer);
+                    }
                 } catch (XMLStreamException e) {
                     throw new SoapFault(new Message("SOAPEXCEPTION", BUNDLE), e, message.getVersion()
                                         .getSender());

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java Thu Apr 16 21:36:54 2009
@@ -125,6 +125,10 @@
         writer.write("Content-Transfer-Encoding: binary\r\n");
 
         writer.write("Content-ID: <");
+        if (attachmentId.charAt(0) == '<'
+            && attachmentId.charAt(attachmentId.length() - 1) == '>') {
+            attachmentId = attachmentId.substring(1, attachmentId.length() - 2);
+        }
         writer.write(URLDecoder.decode(attachmentId, "UTF-8"));
         writer.write(">\r\n\r\n");
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataWriter.java Thu Apr 16 21:36:54 2009
@@ -30,6 +30,9 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.validation.Schema;
 
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Node;
+
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
@@ -37,6 +40,7 @@
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
 public class XMLStreamDataWriter implements DataWriter<XMLStreamWriter> {
     private static final Logger LOG = LogUtils.getL7dLogger(XMLStreamDataWriter.class);
@@ -53,6 +57,22 @@
                 reader = StaxUtils.createXMLStreamReader(ds.getInputStream());
                 StaxUtils.copy(reader, writer);
                 reader.close();
+            } else if (obj instanceof Node) {
+                Node nd = (Node)obj;
+                if (writer instanceof W3CDOMStreamWriter
+                    && ((W3CDOMStreamWriter)writer).getCurrentNode() != null) {
+                    W3CDOMStreamWriter dw = (W3CDOMStreamWriter)writer;
+                    
+                    if (nd.getOwnerDocument() == dw.getDocument()) {
+                        dw.getCurrentNode().appendChild(nd);
+                        return;
+                    } else if (nd instanceof DocumentFragment) {
+                        nd = dw.getDocument().importNode(nd, true);
+                        dw.getCurrentNode().appendChild(nd);
+                        return;
+                    }
+                }
+                StaxUtils.writeNode(nd, writer, true);
             } else {
                 Source s = (Source) obj;
                 if (s instanceof DOMSource

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/DocLiteralInInterceptor.java Thu Apr 16 21:36:54 2009
@@ -136,6 +136,9 @@
                             exchange.setOneWay(true);
                         }
                     }
+                    if (msgInfo == null) {
+                        return;
+                    }
                     setMessage(message, bop, client, si, msgInfo.getMessageInfo());
                 }
     

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java Thu Apr 16 21:36:54 2009
@@ -45,7 +45,6 @@
     protected JAXBContext context; 
     protected Schema schema;
     protected Collection<Attachment> attachments;
-    protected boolean unwrapJAXBElement = true;
     protected Integer mtomThreshold; // null if we should default.
     
     protected JAXBDataBase(JAXBContext ctx) {
@@ -84,9 +83,6 @@
     }
     
     public void setProperty(String prop, Object value) {
-        if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
-            unwrapJAXBElement = Boolean.TRUE.equals(value);
-        }
     }
     
     protected Annotation[] getJAXBAnnotation(MessagePartInfo mpi) {

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Thu Apr 16 21:36:54 2009
@@ -156,6 +156,7 @@
     private Marshaller.Listener marshallerListener;
     private ValidationEventHandler validationEventHandler;
     
+    private boolean unwrapJAXBElement = true;
 
     private boolean qualifiedSchemas;
     private Service service;
@@ -219,11 +220,11 @@
     public <T> DataReader<T> createReader(Class<T> c) {
         DataReader<T> dr = null;
         if (c == XMLStreamReader.class) {
-            dr = (DataReader<T>)new DataReaderImpl<XMLStreamReader>(this);
+            dr = (DataReader<T>)new DataReaderImpl<XMLStreamReader>(this, unwrapJAXBElement);
         } else if (c == XMLEventReader.class) {
-            dr = (DataReader<T>)new DataReaderImpl<XMLEventReader>(this);
+            dr = (DataReader<T>)new DataReaderImpl<XMLEventReader>(this, unwrapJAXBElement);
         } else if (c == Node.class) {
-            dr = (DataReader<T>)new DataReaderImpl<Node>(this);
+            dr = (DataReader<T>)new DataReaderImpl<Node>(this, unwrapJAXBElement);
         }
 
         return dr;
@@ -715,6 +716,14 @@
     }
 
     
+    public boolean isUnwrapJAXBElement() {
+        return unwrapJAXBElement;
+    }
+
+    public void setUnwrapJAXBElement(boolean unwrapJAXBElement) {
+        this.unwrapJAXBElement = unwrapJAXBElement;
+    }
+
     public static void clearCaches() {
         synchronized (JAXBCONTEXT_CACHE) {
             JAXBCONTEXT_CACHE.clear();

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java Thu Apr 16 21:36:54 2009
@@ -41,16 +41,22 @@
 public class DataReaderImpl<T> extends JAXBDataBase implements DataReader<T> {
     private static final Logger LOG = LogUtils.getLogger(JAXBDataBinding.class);
     JAXBDataBinding databinding;
+    boolean unwrapJAXBElement = true;
     
-    public DataReaderImpl(JAXBDataBinding binding) {
+    public DataReaderImpl(JAXBDataBinding binding, boolean unwrap) {
         super(binding.getContext());
+        unwrapJAXBElement = unwrap;
         databinding = binding;
     }
 
     public Object read(T input) {
         return read(null, input);
     }
-    
+    public void setProperty(String prop, Object value) {
+        if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
+            unwrapJAXBElement = Boolean.TRUE.equals(value);
+        }
+    }
     private Unmarshaller createUnmarshaller() {
         try {
             Unmarshaller um = null;

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java Thu Apr 16 21:36:54 2009
@@ -20,31 +20,31 @@
 package org.apache.cxf.jaxws;
 
 import java.net.HttpURLConnection;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Executor;
 import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.activation.DataSource;
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
-import javax.xml.soap.Detail;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPConstants;
 import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
 import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Binding;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
+import javax.xml.ws.EndpointReference;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
@@ -54,72 +54,153 @@
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
 
-import org.w3c.dom.Element;
+import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.Node;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.binding.soap.SoapBinding;
-import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor.SAAJOutEndingInterceptor;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Client;
-import org.apache.cxf.endpoint.ConduitSelector;
+import org.apache.cxf.endpoint.ClientCallback;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.endpoint.UpfrontConduitSelector;
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.interceptor.InterceptorProvider;
-import org.apache.cxf.interceptor.MessageSenderInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
-import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
-import org.apache.cxf.jaxws.handler.soap.DispatchSOAPHandlerInterceptor;
-import org.apache.cxf.jaxws.interceptors.DispatchInDatabindingInterceptor;
-import org.apache.cxf.jaxws.interceptors.DispatchOutDatabindingInterceptor;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.message.ExchangeImpl;
-import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.phase.PhaseInterceptorChain;
-import org.apache.cxf.phase.PhaseManager;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.MessageObserver;
-import org.apache.cxf.workqueue.WorkQueueManager;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessageInfo.Type;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.staxutils.OverlayW3CDOMStreamWriter;
+import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamReader;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
-public class DispatchImpl<T> extends BindingProviderImpl implements Dispatch<T>, MessageObserver {
+public class DispatchImpl<T> implements Dispatch<T>, BindingProvider {
     private static final Logger LOG = LogUtils.getL7dLogger(DispatchImpl.class);
-    private static final String FINISHED = "exchange.finished";
+    
+    private final Binding binding;
+    private final EndpointReferenceBuilder builder;
 
-    private Bus bus;
-    private InterceptorProvider iProvider;
-    private Class<T> cl;
-    private Executor executor;
-    private JAXBContext context;
-    private Service.Mode mode;
+    private final Client client;
+    private final Class<T> cl;
+    private final JAXBContext context;
+    private Message error;
+    
+    DispatchImpl(Client client, Service.Mode m, JAXBContext ctx, Class<T> clazz) {
+        this.binding = ((JaxWsEndpointImpl)client.getEndpoint()).getJaxwsBinding();
+        this.builder = new EndpointReferenceBuilder((JaxWsEndpointImpl)client.getEndpoint());
 
-    private ConduitSelector conduitSelector;
-    
-    DispatchImpl(Bus b, Client client, Service.Mode m, JAXBContext ctx, Class<T> clazz, Executor e) {
-        super((JaxWsEndpointImpl)client.getEndpoint());
-        bus = b;
-        this.iProvider = client;
-        executor = e;
+        this.client = client;
         context = ctx;
         cl = clazz;
-        mode = m;
-        getConduitSelector().setEndpoint(client.getEndpoint());
         setupEndpointAddressContext(client.getEndpoint());
+        addInvokeOperation(false);
+        addInvokeOperation(true);
+        if (m == Service.Mode.MESSAGE && binding instanceof SOAPBinding) {
+            if (DataSource.class.isAssignableFrom(clazz)) {
+                error = new Message("DISPATCH_OBJECT_NOT_SUPPORTED", LOG,
+                                    "DataSource",
+                                    m,
+                                    "SOAP/HTTP");
+            } else if (m == Service.Mode.MESSAGE) {
+                client.getOutInterceptors().add(new SAAJOutInterceptor());
+                client.getOutInterceptors().add(new MessageModeOutInterceptor());
+                client.getInInterceptors().add(new SAAJInInterceptor());
+                client.getInInterceptors().add(new MessageModeInInterceptor(clazz));
+            }
+        } else if (m == Service.Mode.PAYLOAD 
+            && binding instanceof SOAPBinding
+            && SOAPMessage.class.isAssignableFrom(clazz)) {
+            error = new Message("DISPATCH_OBJECT_NOT_SUPPORTED", LOG,
+                                "SOAPMessage",
+                                m,
+                                "SOAP/HTTP");
+        } else if (DataSource.class.isAssignableFrom(clazz)
+            && binding instanceof HTTPBinding) {
+            error = new Message("DISPATCH_OBJECT_NOT_SUPPORTED", LOG,
+                                "DataSource",
+                                m,
+                                "XML/HTTP");            
+        }
+    }
+    
+    DispatchImpl(Client cl, Service.Mode m, Class<T> clazz) {
+        this(cl, m, null, clazz);
+    }
+    
+    private void addInvokeOperation(boolean oneWay) {
+        String name = oneWay ? "InvokeOneWay" : "Invoke";
+            
+        String ns = "http://cxf.apache.org/jaxws/dispatch";
+        ServiceInfo info = client.getEndpoint().getEndpointInfo().getService();
+        OperationInfo opInfo = info.getInterface()
+            .addOperation(new QName(ns, name));
+        MessageInfo mInfo = opInfo.createMessage(new QName(ns, name + "Request"), Type.INPUT);
+        opInfo.setInput(name + "Request", mInfo);
+        MessagePartInfo mpi = mInfo.addMessagePart("parameters");
+        if (context == null) {
+            mpi.setTypeClass(cl);
+        }
+        mpi.setElement(true);
+
+        if (!oneWay) {
+            mInfo = opInfo.createMessage(new QName(ns, name + "Response"), Type.OUTPUT);
+            opInfo.setOutput(name + "Response", mInfo);
+            mpi = mInfo.addMessagePart("parameters");
+            mpi.setElement(true);
+            if (context == null) {
+                mpi.setTypeClass(cl);
+            }
+        }
+        
+        for (BindingInfo bind : client.getEndpoint().getEndpointInfo().getService().getBindings()) {
+            BindingOperationInfo bo = new BindingOperationInfo(bind, opInfo);
+            bind.addOperation(bo);
+        }
     }
     
-    DispatchImpl(Bus b, Client cl, Service.Mode m, Class<T> clazz, Executor e) {
-        this(b, cl, m, null, clazz, e);
+    public Map<String, Object> getRequestContext() {
+        return new WrappedMessageContext(client.getRequestContext(),
+                                         null,
+                                         Scope.APPLICATION);
+    }
+    public Map<String, Object> getResponseContext() {
+        return new WrappedMessageContext(client.getResponseContext(),
+                                         null,
+                                         Scope.APPLICATION);
+    }
+    public Binding getBinding() {
+        return binding;
+    }
+    public EndpointReference getEndpointReference() {            
+        return builder.getEndpointReference();
+    }
+    public <X extends EndpointReference> X getEndpointReference(Class<X> clazz) {
+        return builder.getEndpointReference(clazz);
     }
 
     private void setupEndpointAddressContext(Endpoint endpoint) {
         //NOTE for jms transport the address would be null
         if (null != endpoint
             && null != endpoint.getEndpointInfo().getAddress()) {
-            Map<String, Object> requestContext = this.getRequestContext();
+            Map<String, Object> requestContext
+                = new WrappedMessageContext(client.getRequestContext(),
+                                            null,
+                                            Scope.APPLICATION);
             requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                            endpoint.getEndpointInfo().getAddress());
         }    
@@ -128,312 +209,210 @@
         return invoke(obj, false);
     }
 
-    public T invoke(T obj, boolean isOneWay) {
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Dispatch: invoke called");
-        }
-
-        Bus origBus = BusFactory.getThreadDefaultBus(false);
-        BusFactory.setThreadDefaultBus(bus);
-        try { 
-            Endpoint endpoint = getEndpoint();
-            Message message = endpoint.getBinding().createMessage();
-    
-            if (context != null) {
-                message.setContent(JAXBContext.class, context);
-            }
-            
-            
-            Map<String, Object> reqContext = new HashMap<String, Object>();
-            WrappedMessageContext ctx = new WrappedMessageContext(reqContext,
-                                                                  null,
-                                                                  Scope.APPLICATION);
-            ctx.putAll(this.getRequestContext());
-            Map<String, Object> respContext = this.getResponseContext();
-            // clear the response context's hold information
-            // Not call the clear Context is to avoid the error 
-            // that getResponseContext() would be called by Client code first
-            respContext.clear();
-            
-            message.putAll(reqContext);
-            //need to do context mapping from jax-ws to cxf message
-            
-            Exchange exchange = new ExchangeImpl();
-            exchange.setOneWay(isOneWay);
-    
-            exchange.setOutMessage(message);
-            setExchangeProperties(exchange, endpoint);
-    
-            message.setContent(Object.class, obj);
-            
-            if (obj instanceof SOAPMessage) {
-                message.setContent(SOAPMessage.class, obj);
-            } else if (obj instanceof Source) {
-                message.setContent(Source.class, obj);
-            } else if (obj instanceof DataSource) {
-                message.setContent(DataSource.class, obj);
-            }
-      
-            message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
-    
-            PhaseInterceptorChain chain = getDispatchOutChain(endpoint);
-            message.setInterceptorChain(chain);
-    
-            // setup conduit selector
-            prepareConduitSelector(message);
-            
-            // execute chain
-            chain.doIntercept(message);
-            
-            Exception exp = message.getContent(Exception.class);
-            if (exp == null && exchange.getInMessage() != null) {
-                exp = exchange.getInMessage().getContent(Exception.class);
-            }
-
-            if (exp != null) {
-                getConduitSelector().complete(exchange);
-                if (getBinding() instanceof SOAPBinding && exp instanceof Fault) {
-                    try {
-                        SOAPFault soapFault = SOAPFactory.newInstance().createFault();
-                        Fault fault = (Fault)exp;
-                        soapFault.setFaultCode(fault.getFaultCode());
-                        soapFault.setFaultString(fault.getMessage());
-                        if (fault.getDetail() != null) {
-                            Detail det = soapFault.addDetail();
-                            Element fd = fault.getDetail();
-                            Node child = fd.getFirstChild();
-                            while (child != null) {
-                                Node next = child.getNextSibling();
-                                det.appendChild(det.getOwnerDocument().importNode(child, true));
-                                child = next;
-                            }
-                        }
-                        SOAPFaultException ex = new SOAPFaultException(soapFault);
-                        ex.initCause(exp);
-                        throw ex;
-                    } catch (SOAPException e) {
-                        throw new WebServiceException(e);
-                    }
-                } else if (getBinding() instanceof HTTPBinding) {
-                    HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
-                    exception.initCause(exp);
-                    throw exception;
-                } else {
-                    throw new WebServiceException(exp);
+    private void checkError() {
+        if (error != null) {
+            if (getBinding() instanceof SOAPBinding) {
+                SOAPFault soapFault = null;
+                try {
+                    soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(),
+                                                                 new Exception(error.toString()));
+                } catch (SOAPException e) {
+                    //ignore
                 }
-            }
-    
-            // correlate response        
-            if (getConduitSelector().selectConduit(message).getBackChannel() != null) {
-                // process partial response and wait for decoupled response
-            } else {
-                // process response: send was synchronous so when we get here we can assume that the 
-                // Exchange's inbound message is set and had been passed through the inbound
-                // interceptor chain.
-            }
-    
-            if (!isOneWay) {
-                synchronized (exchange) {
-                    Message inMsg = waitResponse(exchange);
-                    respContext.putAll(inMsg);
-                    getConduitSelector().complete(exchange);
-                    return cl.cast(inMsg.getContent(Object.class));
+                if (soapFault != null) {
+                    throw new SOAPFaultException(soapFault);
                 }
+            } else if (getBinding() instanceof HTTPBinding) {
+                HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
+                exception.initCause(new Exception(error.toString()));
+                throw exception;
             }
-            return null;
-        } finally {
-            BusFactory.setThreadDefaultBus(origBus);
-        }        
+            throw new WebServiceException(error.toString());
+        }
     }
-
-    private Message waitResponse(Exchange exchange) {
-        while (!Boolean.TRUE.equals(exchange.get(FINISHED))) {
+    private RuntimeException mapException(Exception ex) {
+        if (getBinding() instanceof HTTPBinding) {
+            HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
+            exception.initCause(ex);
+            return exception;
+        } else if (getBinding() instanceof SOAPBinding) {
+            SOAPFault soapFault = null;
             try {
-                exchange.wait();
-            } catch (InterruptedException e) {
-                //TODO - timeout
+                soapFault = JaxWsClientProxy.createSoapFault((SOAPBinding)getBinding(), ex);
+            } catch (SOAPException e) {
+                //ignore
             }
-        }
-        Message inMsg = exchange.getInMessage();
-        if (inMsg == null) {
-            try {
-                exchange.wait();
-            } catch (InterruptedException e) {
-                //TODO - timeout
+            if (soapFault == null) {
+                return new WebServiceException(ex);
             }
-            inMsg = exchange.getInMessage();
-        }
-        if (inMsg.getContent(Exception.class) != null) {
-            //TODO - exceptions 
-            throw new RuntimeException(inMsg.getContent(Exception.class));
+            
+            SOAPFaultException  exception = new SOAPFaultException(soapFault);
+            exception.initCause(ex);
+            return exception;                
         }
-        return inMsg;
+        return new WebServiceException(ex);
     }
-
-    private PhaseInterceptorChain getDispatchOutChain(Endpoint endpoint) {
-        PhaseManager pm = bus.getExtension(PhaseManager.class);
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
-
-        List<Interceptor> il = bus.getOutInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + il);
-        }
-        chain.add(il);
-        List<Interceptor> i2 = iProvider.getOutInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by client: " + i2);
-        }
-        chain.add(i2);
-        
-        if (endpoint instanceof JaxWsEndpointImpl) {
-            Binding jaxwsBinding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
-            if (endpoint.getBinding() instanceof SoapBinding) {
-                chain.add(new DispatchSOAPHandlerInterceptor(jaxwsBinding));
-            } else {
-                // TODO: what for non soap bindings?
-            }       
-            chain.add(new DispatchLogicalHandlerInterceptor(jaxwsBinding));
-        }
-
-        if (getBinding() instanceof SOAPBinding) {
-            chain.add(new SoapPreProtocolOutInterceptor());
-        }
-
-        chain.add(new MessageSenderInterceptor());
-
-        chain.add(new DispatchOutDatabindingInterceptor(mode));
-        return chain;
-    }
-
-    public void onMessage(Message message) {
-        Endpoint endpoint = getEndpoint();
-        message = endpoint.getBinding().createMessage(message);
-
-        message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
-
-        PhaseManager pm = bus.getExtension(PhaseManager.class);
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getInPhases());
-        message.setInterceptorChain(chain);
-
-        List<Interceptor> il = bus.getInInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by bus: " + il);
-        }
-        chain.add(il);
-        List<Interceptor> i2 = iProvider.getInInterceptors();
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Interceptors contributed by client: " + i2);
-        }
-        chain.add(i2);
-
-        if (endpoint instanceof JaxWsEndpointImpl) {
-            Binding jaxwsBinding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
-            if (endpoint.getBinding() instanceof SoapBinding) {
-                chain.add(new DispatchSOAPHandlerInterceptor(jaxwsBinding));
-            }      
-            DispatchLogicalHandlerInterceptor slhi 
-                = new DispatchLogicalHandlerInterceptor(jaxwsBinding, Phase.USER_LOGICAL);            
-            chain.add(slhi);
-        }
-
-        List<Interceptor> inInterceptors = new ArrayList<Interceptor>();
-        inInterceptors.add(new DispatchInDatabindingInterceptor(cl, mode));
-        chain.add(inInterceptors);
-
-        // execute chain
-        Bus origBus = BusFactory.getThreadDefaultBus(false);
-        BusFactory.setThreadDefaultBus(bus);
+    
+    @SuppressWarnings("unchecked")
+    public T invoke(T obj, boolean isOneWay) {
+        checkError();
         try {
-            chain.doIntercept(message);
-        } finally {
-            synchronized (message.getExchange()) {
-                message.getExchange().put(FINISHED, Boolean.TRUE);
-                message.getExchange().setInMessage(message);
-                message.getExchange().notifyAll();
+            if (obj instanceof SOAPMessage) {
+                SOAPMessage msg = (SOAPMessage)obj;
+                if (msg.countAttachments() > 0) {
+                    client.getRequestContext().put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE);
+                }
             }
-            BusFactory.setThreadDefaultBus(origBus);
-        }
-    }
-
-    private Executor getExecutor() {
-        if (executor == null) {
-            executor = bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
-        }
-        if (executor == null) {
-            System.err.println("Can't not get executor");
+            Object ret[] = client.invokeWrapped(new QName("http://cxf.apache.org/jaxws/dispatch",
+                                                          "Invoke" + (isOneWay ? "OneWay" : "")),
+                                                obj);
+            if (isOneWay) {
+                return null;
+            }
+            return (T)ret[0];
+        } catch (Exception ex) {
+            throw mapException(ex);
         }
-        return executor;
-    }
-    
-    private Endpoint getEndpoint() {
-        return getConduitSelector().getEndpoint();
     }
 
+  
     public Future<?> invokeAsync(T obj, AsyncHandler<T> asyncHandler) {
-        FutureTask<T> f = new FutureTask<T>(new DispatchAsyncCallable<T>(this, obj, asyncHandler));
-        getExecutor().execute(f);
-        
-        return f;
+        checkError();
+        client.setExecutor(getClient().getEndpoint().getExecutor());
+
+        ClientCallback callback = new JaxwsClientCallback<T>(asyncHandler);
+             
+        Response<T> ret = new JaxwsResponseCallback<T>(callback);
+        try {
+            client.invokeWrapped(callback, 
+                                 new QName("http://cxf.apache.org/jaxws/dispatch",
+                                       "Invoke"),
+                                       obj);
+            
+            return ret;
+        } catch (Exception ex) {
+            throw mapException(ex);
+        }
     }
 
+    @SuppressWarnings("unchecked")
     public Response<T> invokeAsync(T obj) {
-        FutureTask<T> f = new FutureTask<T>(new DispatchAsyncCallable<T>(this, obj, null));
-
-        getExecutor().execute(f);
-        return new AsyncResponse<T>(f, cl);
+        return (Response)invokeAsync(obj, null);
     }
 
     public void invokeOneWay(T obj) {
         invoke(obj, true);
     }
         
-    public synchronized ConduitSelector getConduitSelector() {
-        if (null == conduitSelector) {
-            conduitSelector = new UpfrontConduitSelector();
-        }
-        return conduitSelector;
-    }
-
-    public void setConduitSelector(ConduitSelector selector) {
-        conduitSelector = selector;
+    public Client getClient() {
+        return client;
     }
     
-    protected void prepareConduitSelector(Message message) {
-        message.getExchange().put(ConduitSelector.class, getConduitSelector());
-    }
     
-    protected void setExchangeProperties(Exchange exchange, Endpoint endpoint) {
-        exchange.put(Service.Mode.class, mode);
-        exchange.put(Class.class, cl);
-        exchange.put(org.apache.cxf.service.Service.class, endpoint.getService());
-        exchange.put(Endpoint.class, endpoint);
-        
-        exchange.put(MessageObserver.class, this);
-        exchange.put(Bus.class, bus);
-
-        if (endpoint != null) {
-
-            EndpointInfo endpointInfo = endpoint.getEndpointInfo();
+    static class MessageModeOutInterceptor extends AbstractSoapInterceptor {
+        public MessageModeOutInterceptor() {
+            super(Phase.PRE_PROTOCOL);
+            addBefore(SAAJOutInterceptor.class.getName());
+        }
 
-            QName serviceQName = endpointInfo.getService().getName();
-            exchange.put(Message.WSDL_SERVICE, serviceQName);
+        public void handleMessage(SoapMessage message) throws Fault {
+            MessageContentsList list = (MessageContentsList)message.getContent(List.class);
+            Object o = list.get(0);
+            SOAPMessage soapMessage = null;
+            
+            if (o instanceof SOAPMessage) {
+                soapMessage = (SOAPMessage)o;
+            } else {
+                try {
+                    MessageFactory factory = null;
+                    if (message.getVersion() instanceof Soap11) {
+                        factory = MessageFactory.newInstance();
+                    } else {
+                        factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+                    }
+                    
+                    soapMessage = factory.createMessage();
+                    SOAPPart part = soapMessage.getSOAPPart();
+                    if (o instanceof Source) {
+                        StaxUtils.copy((Source)o, new W3CDOMStreamWriter(part));
+                    }
+                } catch (SOAPException e) {
+                    throw new SoapFault("Error creating SOAPMessage", e, 
+                                        message.getVersion().getSender());
+                } catch (XMLStreamException e) {
+                    throw new SoapFault("Error creating SOAPMessage", e, 
+                                        message.getVersion().getSender());
+                }
+            }
+            message.setContent(SOAPMessage.class, soapMessage);
+            
+            if (!message.containsKey(SAAJOutInterceptor.ORIGINAL_XML_WRITER)) {
+                XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
+                message.put(SAAJOutInterceptor.ORIGINAL_XML_WRITER, origWriter);
+            }
+            W3CDOMStreamWriter writer = new OverlayW3CDOMStreamWriter(soapMessage.getSOAPPart());
+            // Replace stax writer with DomStreamWriter
+            message.setContent(XMLStreamWriter.class, writer);
+            message.setContent(SOAPMessage.class, soapMessage);
+            
+            DocumentFragment frag = soapMessage.getSOAPPart().createDocumentFragment();
+            try {
+                Node body = soapMessage.getSOAPBody();
+                Node nd = body.getFirstChild();
+                while (nd != null) {
+                    body.removeChild(nd);
+                    frag.appendChild(nd);
+                    nd = soapMessage.getSOAPBody().getFirstChild();
+                    list.set(0, frag);
+                }
+            } catch (Exception ex) {
+                throw new Fault(ex);
+            }
+            
+            
+            // Add a final interceptor to write the message
+            message.getInterceptorChain().add(SAAJOutEndingInterceptor.INSTANCE);
+        }
+        
+    }
 
-            QName interfaceQName = endpointInfo.getService().getInterface().getName();
-            exchange.put(Message.WSDL_INTERFACE, interfaceQName);
+    static class MessageModeInInterceptor extends AbstractSoapInterceptor {
+        Class<?> type;
+        public MessageModeInInterceptor(Class<?> c) {
+            super(Phase.POST_LOGICAL);
+            type = c;
+        }
 
-            QName portQName = endpointInfo.getName();
-            exchange.put(Message.WSDL_PORT, portQName);
-            URI wsdlDescription = endpointInfo.getProperty("URI", URI.class);
-            if (wsdlDescription == null) {
-                String address = endpointInfo.getAddress();
+        public void handleMessage(SoapMessage message) throws Fault {
+            SOAPMessage m = message.getContent(SOAPMessage.class);
+            MessageContentsList list = (MessageContentsList)message.getContent(List.class); 
+            if (list == null) {
+                list = new MessageContentsList();
+                message.setContent(List.class, list);
+            }
+            Object o = m;
+            
+            if (StreamSource.class.isAssignableFrom(type)) {
                 try {
-                    wsdlDescription = new URI(address + "?wsdl");
-                } catch (URISyntaxException e) {
-                    // do nothing
+                    CachedOutputStream out = new CachedOutputStream();
+                    try {
+                        XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
+                        StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw);
+                        xsw.close();
+                        o = new StreamSource(out.getInputStream());
+                    } finally {
+                        out.close();
+                    }
+                } catch (Exception e) {
+                    throw new Fault(e);
                 }
-                endpointInfo.setProperty("URI", wsdlDescription);
+            } else if (SAXSource.class.isAssignableFrom(type)) {
+                o = new StaxSource(new W3CDOMStreamReader(m.getSOAPPart()));
+            } else if (Source.class.isAssignableFrom(type)) {
+                o = new DOMSource(m.getSOAPPart());
             }
-            exchange.put(Message.WSDL_DESCRIPTION, wsdlDescription);
-        }      
+            
+            list.set(0, o);
+        }
     }
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?rev=765773&r1=765772&r2=765773&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java Thu Apr 16 21:36:54 2009
@@ -25,10 +25,7 @@
 import java.net.HttpURLConnection;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.logging.Logger;
 
 import javax.xml.soap.SOAPException;
@@ -100,7 +97,6 @@
         if (oi == null) {
             // check for method on BindingProvider and Object
             if (method.getDeclaringClass().equals(BindingProvider.class)
-                || method.getDeclaringClass().equals(BindingProviderImpl.class)
                 || method.getDeclaringClass().equals(Object.class)) {
                 try {
                     return method.invoke(this, params);
@@ -137,7 +133,7 @@
                 exception.initCause(ex);
                 throw exception;
             } else if (getBinding() instanceof SOAPBinding) {
-                SOAPFault soapFault = createSoapFault(ex);
+                SOAPFault soapFault = createSoapFault((SOAPBinding)getBinding(), ex);
                 if (soapFault == null) {
                     throw new WebServiceException(ex);
                 }
@@ -172,15 +168,15 @@
                 || Response.class.equals(m.getReturnType()));
     }
     
-    private SOAPFault createSoapFault(Exception ex) throws SOAPException {
+    static SOAPFault createSoapFault(SOAPBinding binding, Exception ex) throws SOAPException {
         SOAPFault soapFault;
         try {
-            soapFault = ((SOAPBinding)getBinding()).getSOAPFactory().createFault();
+            soapFault = binding.getSOAPFactory().createFault();
         } catch (Throwable t) {
             //probably an old version of saaj or something that is not allowing createFault 
             //method to work.  Try the saaj 1.2 method of doing this.
             try {
-                soapFault = ((SOAPBinding)getBinding()).getMessageFactory().createMessage()
+                soapFault = binding.getMessageFactory().createMessage()
                     .getSOAPBody().addFault();
             } catch (Throwable t2) {
                 //still didn't work, we'll just throw what we have
@@ -231,131 +227,11 @@
         }
         ClientCallback callback = new JaxwsClientCallback(handler);
              
-        Response<Object> ret = new ResponseCallback(callback);
+        Response<Object> ret = new JaxwsResponseCallback(callback);
         client.invoke(callback, oi, params);
         return ret;
     }
 
-    static class JaxwsClientCallback extends ClientCallback {
-        final AsyncHandler<Object> handler;
-        
-        public JaxwsClientCallback(final AsyncHandler<Object> handler) {
-            this.handler = handler;
-        }
-        public void handleResponse(Map<String, Object> ctx, Object[] res) {
-            context = ctx;
-            result = res;
-            if (handler != null) {
-                handler.handleResponse(new Response<Object>() {
-
-                    public Map<String, Object> getContext() {
-                        return context;
-                    }
-
-                    public boolean cancel(boolean mayInterruptIfRunning) {
-                        cancelled = true;
-                        return true;
-                    }
-
-                    public Object get() throws InterruptedException, ExecutionException {
-                        return result[0];
-                    }
-
-                    public Object get(long timeout, TimeUnit unit) throws InterruptedException,
-                        ExecutionException, TimeoutException {
-                        return result[0];
-                    }
-
-                    public boolean isCancelled() {
-                        return cancelled;
-                    }
-
-                    public boolean isDone() {
-                        return true;
-                    }
-                    
-                });
-            }
-            done = true;
-            synchronized (this) {
-                notifyAll();
-            }
-        }
-
-        @Override
-        public void handleException(Map<String, Object> ctx, final Throwable ex) {
-            context = ctx;
-            exception = ex;
-            if (handler != null) {
-                handler.handleResponse(new Response<Object>() {
-
-                    public Map<String, Object> getContext() {
-                        return context;
-                    }
-
-                    public boolean cancel(boolean mayInterruptIfRunning) {
-                        cancelled = true;
-                        return true;
-                    }
-
-                    public Object get() throws InterruptedException, ExecutionException {
-                        throw new ExecutionException(ex);
-                    }
-
-                    public Object get(long timeout, TimeUnit unit) 
-                        throws InterruptedException, ExecutionException, TimeoutException {
-                        
-                        throw new ExecutionException(ex);
-                    }
-
-                    public boolean isCancelled() {
-                        return cancelled;
-                    }
-
-                    public boolean isDone() {
-                        return true;
-                    }
-
-                });
-            }
-            done = true;
-            synchronized (this) {
-                notifyAll();
-            }
-        }
-    }
-    static class ResponseCallback implements Response<Object> {
-        ClientCallback callback;
-        public ResponseCallback(ClientCallback cb) {
-            callback = cb;
-        }
-        
-        public Map<String, Object> getContext() {
-            try {
-                return callback.getResponseContext();
-            } catch (Exception ex) {
-                return null;
-            }
-        }
-        public boolean cancel(boolean mayInterruptIfRunning) {
-            return callback.cancel(mayInterruptIfRunning);
-        }
-        public Object get() throws InterruptedException, ExecutionException {
-            return callback.get()[0];
-        }
-        public Object get(long timeout, TimeUnit unit) throws InterruptedException,
-            ExecutionException, TimeoutException {
-            return callback.get(timeout, unit)[0];
-        }
-        public boolean isCancelled() {
-            return callback.isCancelled();
-        }
-        public boolean isDone() {
-            return callback.isDone();
-        }
-    };
-
-    
     public Map<String, Object> getRequestContext() {
         return new WrappedMessageContext(this.getClient().getRequestContext(),
                                          null,

Added: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java?rev=765773&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxwsClientCallback.java Thu Apr 16 21:36:54 2009
@@ -0,0 +1,121 @@
+/**
+ * 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;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.cxf.endpoint.ClientCallback;
+
+class JaxwsClientCallback<T> extends ClientCallback {
+    final AsyncHandler<T> handler;
+    
+    public JaxwsClientCallback(final AsyncHandler<T> handler) {
+        this.handler = handler;
+    }
+    public void handleResponse(Map<String, Object> ctx, Object[] res) {
+        context = ctx;
+        result = res;
+        if (handler != null) {
+            handler.handleResponse(new Response<T>() {
+
+                public Map<String, Object> getContext() {
+                    return context;
+                }
+
+                public boolean cancel(boolean mayInterruptIfRunning) {
+                    cancelled = true;
+                    return true;
+                }
+
+                @SuppressWarnings("unchecked")
+                public T get() throws InterruptedException, ExecutionException {
+                    return (T)result[0];
+                }
+
+                @SuppressWarnings("unchecked")
+                public T get(long timeout, TimeUnit unit) throws InterruptedException,
+                    ExecutionException, TimeoutException {
+                    return (T)result[0];
+                }
+
+                public boolean isCancelled() {
+                    return cancelled;
+                }
+
+                public boolean isDone() {
+                    return true;
+                }
+                
+            });
+        }
+        done = true;
+        synchronized (this) {
+            notifyAll();
+        }
+    }
+
+    @Override
+    public void handleException(Map<String, Object> ctx, final Throwable ex) {
+        context = ctx;
+        exception = ex;
+        if (handler != null) {
+            handler.handleResponse(new Response<T>() {
+
+                public Map<String, Object> getContext() {
+                    return context;
+                }
+
+                public boolean cancel(boolean mayInterruptIfRunning) {
+                    cancelled = true;
+                    return true;
+                }
+
+                public T get() throws InterruptedException, ExecutionException {
+                    throw new ExecutionException(ex);
+                }
+
+                public T get(long timeout, TimeUnit unit) 
+                    throws InterruptedException, ExecutionException, TimeoutException {
+                    
+                    throw new ExecutionException(ex);
+                }
+
+                public boolean isCancelled() {
+                    return cancelled;
+                }
+
+                public boolean isDone() {
+                    return true;
+                }
+
+            });
+        }
+        done = true;
+        synchronized (this) {
+            notifyAll();
+        }
+    }
+}
\ No newline at end of file

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

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



Mime
View raw message