You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2004/12/15 13:06:17 UTC

svn commit: r111966 - in webservices/axis/trunk/java/dev/scratch/prototype2/src: java/org/apache/axis/impl/llom java/org/apache/axis/impl/llom/serialize java/org/apache/axis/transport test/org/apache/axis/engine test/org/apache/axis/om test/org/apache/axis/om/impl/seriliazer test/org/apache/axis/om/impl/streamwrapper

Author: ajith
Date: Wed Dec 15 04:06:14 2004
New Revision: 111966

URL: http://svn.apache.org/viewcvs?view=rev&rev=111966
Log:
changed the serilaiser to work with a XMLStreamWriter instead of the outputstream. Now the implementation is so configurable that there is one (actually two) serialisers that can be used to anything!
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java
Removed:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMElementImpl.java	Wed Dec 15 04:06:14 2004
@@ -33,7 +33,9 @@
     private OMNode firstChild;
     private OMXMLParserWrapper builder;
     private OMAttributeImpl firstAttribute;
-    private ArrayList namespaces;
+    private ArrayList namespaces = new ArrayList(5);
+    // the default size of the ArrayList is 10. But I think this is too much as on average number of namespaces is
+    // much more than 10. So I selected 5. Hope this is ok as an initial value. -- Eran Chinthaka 13/12/2004
     private ArrayList attributes;
 
     public OMElementImpl(OMElement parent) {
@@ -119,29 +121,22 @@
      * @return
      */
     public OMNamespace declareNamespace(String uri, String prefix) {
-
-        if (namespaces == null) {
-            namespaces = new ArrayList(5);
-            // the default size of the ArrayList is 10. But I think this is too much as on average number of namespaces is
-            // much more than 10. So I selected 5. Hope this is ok as an initial value. -- Eran Chinthaka 13/12/2004
-
-        }
         OMNamespaceImpl ns = new OMNamespaceImpl(uri, prefix);
         namespaces.add(ns);
         return ns;
     }
 
+    //TODO  correct this
+    public void setValue(String value) {
+       OMText txt = OMFactory.newInstance().createText(value);
+       this.addChild(txt);
+    }
+
     /**
      * @param namespace
      * @return
      */
     public OMNamespace declareNamespace(OMNamespace namespace) {
-        if (namespaces == null) {
-            namespaces = new ArrayList(5);
-            // the default size of the ArrayList is 10. But I think this is too much as on average number of namespaces is
-            // much more than 10. So I selected 5. Hope this is ok as an initial value. -- Eran Chinthaka 13/12/2004
-
-        }
         namespaces.add(namespace);
         return namespace;
     }
@@ -163,7 +158,6 @@
         if (namespace != null) {
             return namespace;
         }
-
         // go up to check with ancestors
         if (parent != null)
             return parent.findInScopeNamespace(uri, prefix);
@@ -196,6 +190,10 @@
     }
 
     public Iterator getAllDeclaredNamespaces() {
+        if (namespaces==null){
+            return null;
+        }
+
         return namespaces.listIterator();
     }
 
@@ -327,6 +325,8 @@
      *
      */
     public XMLStreamReader getPullParser(boolean cacheOff) {
-       return new OMStAXWrapper(builder,this,cacheOff);
+        if (builder==null)
+            throw new UnsupportedOperationException("This element was not created in a mnner to be switched");
+        return new OMStAXWrapper(builder, this, cacheOff);
     }
 }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/OMNodeImpl.java	Wed Dec 15 04:06:14 2004
@@ -67,7 +67,7 @@
      * @throws org.apache.axis.om.OMException
      */
     public OMNode getNextSibling() throws OMException {
-        if (nextSibling == null && parent!=null && !parent.isComplete())
+        if (nextSibling == null && parent != null && !parent.isComplete())
             parent.buildNext();
         return nextSibling;
     }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/SimpleOMSerializer.java	Wed Dec 15 04:06:14 2004
@@ -1,13 +1,12 @@
 package org.apache.axis.impl.llom.serialize;
 
-import org.apache.axis.impl.llom.exception.OMStreamingException;
+
 import org.apache.axis.om.*;
 
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
 import java.util.Iterator;
+import java.util.Vector;
 
 /**
  * Copyright 2001-2004 The Apache Software Foundation.
@@ -25,163 +24,144 @@
  * limitations under the License.
  */
 public class SimpleOMSerializer {
-//determines whether the seriliased output contains new line characters
-    private boolean newLines = true;
-
-    public void setNewLines(boolean newLines) {
-        this.newLines = newLines;
-    }
 
-    public void serialize(Object node, OutputStream stream) {
+    private Vector prefixList = new Vector();
 
-        String output = serialize(node);
-        OutputStreamWriter streamWriter = new OutputStreamWriter(stream);
-        BufferedWriter writer = new BufferedWriter(streamWriter);
+    public void serialize(Object omNode, XMLStreamWriter writer) throws XMLStreamException {
 
-        try {
-            writer.write(output);
-            writer.flush();
-
-        } catch (IOException e) {
-            throw new OMStreamingException(e);
+        if (!(omNode instanceof OMNode)) {
+            throw new UnsupportedOperationException("Unsupported input object. Must be of the the type OMNode");
         }
+
+        OMNode node = (OMNode) omNode;
+        serializeNode(node, writer);
     }
 
-    private String serialize(Object o) {
-        String returnString = "";
-        OMNode node = (OMNode) o;
+    protected void serializeNode(OMNode node, XMLStreamWriter writer) throws XMLStreamException {
         short nodeType = node.getType();
         if (nodeType == OMNode.ELEMENT_NODE) {
-            returnString = serializeElement((OMElement) node);
-//        }else if (nodeType == OMNode.DOCUMENT_NODE){
-//            returnString = serializeDocment((OMMessage)node);
+            serializeElement((OMElement) node, writer);
         } else if (nodeType == OMNode.ATTRIBUTE_NODE) {
-            returnString = serializeAttribute((OMAttribute) node);
-        } else if (nodeType == OMNode.TEXT_NODE || nodeType == OMNode.COMMENT_NODE || nodeType == OMNode.CDATA_SECTION_NODE) {
-            returnString = serializeText((OMText) node);
+            serializeAttribute((OMAttribute) node, writer);
+        } else if (nodeType == OMNode.TEXT_NODE) {
+            serializeText((OMText) node, writer);
+        } else if (nodeType == OMNode.COMMENT_NODE) {
+            serializeComment((OMText) node, writer);
+        } else if (nodeType == OMNode.CDATA_SECTION_NODE) {
+            serializeCData((OMText) node, writer);
         }
-        return returnString;
+        writer.flush();
     }
 
-//    private String serializeDocment(OMMessage doc){
-//        return serializeElement(doc.getEnvelope());
-//    }
-
     /**
      * @param element
-     * @return
      */
-    private String serializeElement(OMElement element) {
+    protected void serializeElement(OMElement element, XMLStreamWriter writer) throws XMLStreamException {
 
-        //flag to say whther this element is prefixed or not
-        boolean prefixed = false;
-        String prefix = "";
-
-        //first serialize the element itself
-        String returnText = "<";
-
-        //add the namespace prefix
         OMNamespace ns = element.getNamespace();
+        String prefix = null;
+        String nameSpaceName = null;
         if (ns != null) {
-            //add the prefix if it's availble
             prefix = ns.getPrefix();
+            nameSpaceName = ns.getName();
             if (prefix != null) {
-                returnText = returnText + prefix + ":";
-                prefixed = true;
+                writer.writeStartElement(prefix, element.getLocalName(), nameSpaceName);
+                if (!prefixList.contains(prefix)){
+                    writer.writeNamespace(prefix,nameSpaceName);
+                    prefixList.add(prefix);
+                }
+            } else {
+                writer.writeStartElement(nameSpaceName, element.getLocalName());
+                //add the own namespace
+                if (!prefixList.contains(prefix)){
+                    writer.writeDefaultNamespace(nameSpaceName);
+                    prefixList.add(prefix);
+                }
+
             }
         }
-        //add the local name
-        returnText = returnText + element.getLocalName();
+
+
 
         //add the elements attributes
         Iterator attributes = element.getAttributes();
         while (attributes.hasNext()) {
-            returnText = returnText + " " + serializeAttribute((OMAttribute) attributes.next());
+            serializeAttribute((OMAttribute) attributes.next(), writer);
         }
 
         //add the namespaces
-        returnText = returnText + " " + serializeNamespace(element.getNamespace());
+        Iterator namespaces = element.getAllDeclaredNamespaces();
+        if (namespaces!=null){
+            while (namespaces.hasNext()) {
+                serializeNamespace((OMNamespace) namespaces.next(), writer);
+            }
+        }
 
-        returnText = returnText + ">";
-        //add the children
+        //add the children                                        hiiii
         Iterator children = element.getChildren();
+
         while (children.hasNext()) {
             Object node = children.next();
             if (node != null) {
-                returnText = returnText + serialize(node);
+                serializeNode((OMNode) node, writer);
             }
-            //add the line feed if specified
-
         }
 
+        writer.writeEndElement();
 
-        //add the closing tag
-        if (prefixed)
-            returnText = returnText + "</" + prefix + ":" + element.getLocalName() + ">";
-        else
-            returnText = returnText + "</" + element.getLocalName() + ">";
-
-        if (newLines)
-            returnText = returnText + "\n";
-
-        return returnText;
     }
 
     /**
-     * @param text
-     * @return
      */
-    private String serializeText(OMText text) {
-        short type = text.getType();
-        String returnText = null;
-        if (type == OMNode.COMMENT_NODE) {
-            returnText = "<!--" + text.getValue() + "-->";
-        } else if (type == OMNode.CDATA_SECTION_NODE) {
-            returnText = "<![CDATA[" + text.getValue() + "]]>";
-        } else {
-            returnText = text.getValue();
-        }
-        return returnText;
+    protected void serializeText(OMText text, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCharacters(text.getValue());
+    }
+
+    protected void serializeCData(OMText text, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCData(text.getValue());
+    }
+
+
+    protected void serializeComment(OMText text, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeComment(text.getValue());
     }
 
     /**
      * @param attr
-     * @return
+     * @param writer
+     * @throws XMLStreamException
      */
-    private String serializeAttribute(OMAttribute attr) {
-        String returnText = "";
+
+
+    protected void serializeAttribute(OMAttribute attr, XMLStreamWriter writer) throws XMLStreamException {
+
         //first check whether the attribute is associated with a namespace
         OMNamespace ns = attr.getNamespace();
+        String prefix = null;
+        String namespaceName = null;
         if (ns != null) {
             //add the prefix if it's availble
-            String prefix = ns.getPrefix();
+            prefix = ns.getPrefix();
+            namespaceName = ns.getName();
+
             if (prefix != null)
-                returnText = returnText + prefix + ":";
+                writer.writeAttribute(prefix, namespaceName, attr.getLocalName(), attr.getValue());
+            else
+                writer.writeAttribute(namespaceName, attr.getLocalName(), attr.getValue());
+        } else {
+            writer.writeAttribute(attr.getLocalName(), attr.getValue());
         }
-        //add the local name and the value
-        returnText = returnText + attr.getLocalName() + "=\"" + attr.getValue() + "\"";
-        return returnText;
-    }
 
+    }
 
-    private String serializeNamespace(OMNamespace namespace) {
-        String returnText = "";
 
+    protected void serializeNamespace(OMNamespace namespace, XMLStreamWriter writer) throws XMLStreamException {
         if (namespace != null) {
-            //add the prefix if it's availble
             String prefix = namespace.getPrefix();
-
-            if (prefix != null)
-                returnText = returnText + "xmlns:" + prefix + "=";
-            else
-                returnText = returnText + "xmlns=";
-
-            returnText = returnText + "\"" + namespace.getName() + "\"";
+            if (!prefixList.contains(prefix))
+                writer.writeNamespace(prefix, namespace.getName());
+            
         }
-        //add the local name and the value
-
-        return returnText;
     }
-
 
 }

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java?view=auto&rev=111966
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/StreamingOMSerializer.java	Wed Dec 15 04:06:14 2004
@@ -0,0 +1,136 @@
+package org.apache.axis.impl.llom.serialize;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamConstants;
+
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+public class StreamingOMSerializer implements XMLStreamConstants {
+
+    public void serialize(Object obj, XMLStreamWriter writer) throws XMLStreamException {
+
+        if (!(obj instanceof XMLStreamReader)) {
+            throw new UnsupportedOperationException("Unsupported input object. Must be of the the type XMLStreamReader");
+        }
+
+        XMLStreamReader node = (XMLStreamReader) obj;
+        serializeNode(node, writer);
+    }
+
+    protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        while (reader.hasNext()) {
+            int event = reader.next();
+            if (event == START_ELEMENT) {
+                serializeElement(reader, writer);
+            } else if (event == ATTRIBUTE) {
+                serializeAttributes(reader, writer);
+            } else if (event == CHARACTERS) {
+                serializeText(reader, writer);
+            } else if (event == COMMENT) {
+                serializeComment(reader, writer);
+            } else if (event == CDATA) {
+                serializeCData(reader, writer);
+            } else if (event == END_ELEMENT) {
+                serializeEndElement(writer);
+            }
+            writer.flush();
+        }
+    }
+
+    /**
+
+     */
+    protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+
+        String prefix = reader.getPrefix();
+        String nameSpaceName = reader.getNamespaceURI();
+        if (prefix != null) {
+            writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName);
+        } else {
+            writer.writeStartElement(nameSpaceName, reader.getLocalName());
+        }
+        //add the own namespace
+        writer.writeNamespace(prefix == null ? "" : prefix, nameSpaceName);
+
+        //add attributes
+        serializeAttributes(reader, writer);
+        //add the namespaces
+        serializeNamespaces(reader, writer);
+
+
+    }
+
+    protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeEndElement();
+    }
+
+    /**
+     */
+    protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCharacters(reader.getText());
+    }
+
+    protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeCData(reader.getText());
+    }
+
+
+    protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        writer.writeComment(reader.getText());
+    }
+
+    /**
+     * @param writer
+     * @throws XMLStreamException
+     */
+
+
+    protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+
+        int count = reader.getAttributeCount();
+        String prefix = null;
+        String namespaceName = null;
+        for (int i = 0; i < count; i++) {
+            prefix = reader.getAttributePrefix(i);
+            namespaceName = reader.getAttributeNamespace(i);
+            if (prefix != null && !namespaceName.equals("")) {
+                writer.writeAttribute(prefix,
+                        namespaceName,
+                        reader.getAttributeLocalName(i),
+                        reader.getAttributeValue(i));
+            } else {
+                writer.writeAttribute(reader.getAttributeLocalName(i),
+                        reader.getAttributeValue(i));
+            }
+
+        }
+
+
+    }
+
+
+    protected void serializeNamespaces(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
+        int count = reader.getNamespaceCount();
+        for (int i = 0; i < count; i++) {
+            writer.writeNamespace(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
+        }
+
+    }
+
+}

Deleted: /webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/impl/llom/serialize/XMLSerilazer.java?view=auto&rev=111965
==============================================================================

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTrasnportSender.java	Wed Dec 15 04:06:14 2004
@@ -24,11 +24,15 @@
 import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.SOAPEnvelope;
 
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
 import java.io.OutputStream;
 
 /**
  */
 public abstract class AbstractTrasnportSender extends AbstractHandler implements TransportSender {
+
     public final void invoke(MessageContext msgContext) throws AxisFault {
         OutputStream out = null;
         if (msgContext.isProcessingFault()) {
@@ -50,8 +54,13 @@
         startSending();
         SOAPEnvelope envelope = msgContext.getEnvelope();
         if (envelope != null) {
-            SimpleOMSerializer serializer = new SimpleOMSerializer();
-            serializer.serialize(envelope, out);
+            try {
+                SimpleOMSerializer serializer = new SimpleOMSerializer();
+                XMLStreamWriter outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+                serializer.serialize(envelope, outputWriter);
+            } catch (XMLStreamException e) {
+                throw new AxisFault("Stream error",e);
+            }
 
         }
         finalizeSending();

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java	Wed Dec 15 04:06:14 2004
@@ -19,6 +19,8 @@
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.client.Call;
@@ -31,6 +33,7 @@
 import org.apache.axis.impl.description.SimpleAxisServiceImpl;
 import org.apache.axis.impl.providers.RawXMLProvider;
 import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
+import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.OMElement;
 import org.apache.axis.om.OMFactory;
 import org.apache.axis.om.OMNamespace;
@@ -87,10 +90,11 @@
             OMElement value =  fac.createOMElement("myValue",omNs) ;
             value.setValue("Isaac Assimov, the foundation Sega");
             method.addChild(value);
-            
+
             Call call = new Call();
             URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoBadXMLService");
             OMElement omele = call.syncCall(method,url);
+
             assertNotNull(omele);
         }catch(AxisFault e){
             tearDown();

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java	Wed Dec 15 04:06:14 2004
@@ -19,6 +19,9 @@
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.client.Call;
@@ -32,6 +35,7 @@
 import org.apache.axis.impl.description.SimpleAxisServiceImpl;
 import org.apache.axis.impl.providers.RawXMLProvider;
 import org.apache.axis.impl.transport.http.SimpleHTTPReceiver;
+import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
 import org.apache.axis.om.OMElement;
 import org.apache.axis.om.OMFactory;
 import org.apache.axis.om.OMNamespace;
@@ -90,9 +94,10 @@
             OMElement value =  fac.createOMElement("myValue",omNs) ;
             value.setValue("Isaac Assimov, the foundation Sega");
             method.addChild(value);
-            
+
             Call call = new Call();
             URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
+
             OMElement omele = call.syncCall(method,url);
             assertNotNull(omele);
         }catch(Exception e){
@@ -110,7 +115,7 @@
             OMElement value =  fac.createOMElement("myValue",omNs) ;
             value.setValue("Isaac Assimov, the foundation Sega");
             method.addChild(value);
-            
+
             Call call = new Call();
             URL url = new URL("http","127.0.0.1",EngineUtils.TESTING_PORT,"/axis/services/EchoXMLService");
             

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMNavigatorTest.java	Wed Dec 15 04:06:14 2004
@@ -7,6 +7,8 @@
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.OMNavigator;
@@ -34,6 +36,7 @@
     private SimpleOMSerializer serilizer;
     private StAXSOAPModelBuilder builder;
     private File tempFile;
+    private XMLStreamWriter writer;
 
     public OMNavigatorTest(String testName) {
         super(testName);
@@ -46,8 +49,10 @@
         builder = new StAXSOAPModelBuilder(factory, xmlStreamReader);
         envelope = builder.getOMEnvelope();
         serilizer = new SimpleOMSerializer();
-
         tempFile = File.createTempFile("temp", "xml");
+        writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
+
+
     }
 
 
@@ -55,11 +60,7 @@
 
         assertNotNull(envelope);
         //dump the out put to a  temporary file
-        try {
-            serilizer.serialize(envelope, new FileOutputStream(tempFile));
-        } catch (FileNotFoundException e) {
-            throw e;
-        }
+        serilizer.serialize(envelope,writer);
 
         //now the OM is fully created test the navigation
         OMNavigator navigator = new OMNavigator(envelope);

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java?view=auto&rev=111966
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/seriliazer/OMSerailizerTest.java	Wed Dec 15 04:06:14 2004
@@ -0,0 +1,79 @@
+package org.apache.axis.om.impl.seriliazer;
+
+import junit.framework.TestCase;
+import org.apache.axis.impl.llom.serialize.StreamingOMSerializer;
+import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axis.AbstractTestCase;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMXMLParserWrapper;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.SOAPBody;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
+import java.io.FileReader;
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * <p/>
+ * Licensed 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+public class OMSerailizerTest extends AbstractTestCase {
+
+    private XMLStreamReader reader;
+    private XMLStreamWriter writer;
+    private File tempFile;
+
+    public OMSerailizerTest(String testName) {
+        super(testName);
+    }
+
+    protected void setUp() throws Exception {
+        reader = XMLInputFactory.newInstance().
+                createXMLStreamReader(new FileReader(getTestResourceFile("soap/soapmessage.xml")));
+        tempFile = File.createTempFile("temp", "xml");
+        writer = XMLOutputFactory.newInstance().
+                createXMLStreamWriter(new FileOutputStream(tempFile));
+    }
+
+    public void testRawSerializer() throws Exception {
+        StreamingOMSerializer serializer = new StreamingOMSerializer();
+        serializer.serialize(reader, writer);
+    }
+
+    public void testElementPullStream1() throws Exception {
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
+                reader);
+        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
+        StreamingOMSerializer serializer = new StreamingOMSerializer();
+        serializer.serialize(env.getPullParser(false), writer);
+    }
+
+    public void testElementPullStream2() throws Exception {
+        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(OMFactory.newInstance(),
+                reader);
+        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
+        SOAPBody body = env.getBody();
+        StreamingOMSerializer serializer = new StreamingOMSerializer();
+
+        serializer.serialize(body.getPullParser(false), writer);
+    }
+
+    protected void tearDown() throws Exception {
+           tempFile.delete();
+    }
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OMStaxStreamingWrapperTest.java	Wed Dec 15 04:06:14 2004
@@ -1,17 +1,13 @@
 package org.apache.axis.om.impl.streamwrapper;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileReader;
 
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.*;
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
-import org.apache.axis.impl.llom.OMStAXWrapper;
 import org.apache.axis.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.axis.om.OMFactory;
 import org.apache.axis.om.SOAPEnvelope;
@@ -58,7 +54,8 @@
     public void testWrapperFullOM() throws Exception {
         assertNotNull(envelope);
         //this serializing will cause the OM to fully build!
-        serilizer.serialize(envelope, new FileOutputStream(tempFile));
+        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
+        serilizer.serialize(envelope,writer);
         parser = envelope.getPullParser(false);
         while (parser.hasNext()) {
             int event = parser.next();
@@ -91,9 +88,9 @@
         while (parser.hasNext()) {
             int event = parser.next();
             assertTrue(event > 0);
-            if (event == XMLStreamReader.START_ELEMENT) {
+            if (event == XMLStreamConstants.START_ELEMENT) {
                 checkStartElement(parser);
-            } else if (event == XMLStreamReader.CHARACTERS) {
+            } else if (event == XMLStreamConstants.CHARACTERS) {
                 checkCharacters(parser);
             }
         }
@@ -107,9 +104,9 @@
         while (parser.hasNext()) {
             int event = parser.next();
             assertTrue(event > 0);
-            if (event == XMLStreamReader.START_ELEMENT) {
+            if (event == XMLStreamConstants.START_ELEMENT) {
                 checkStartElement(parser);
-            } else if (event == XMLStreamReader.CHARACTERS) {
+            } else if (event == XMLStreamConstants.CHARACTERS) {
                 checkCharacters(parser);
             }
         }

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java?view=diff&rev=111966&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java&r1=111965&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java&r2=111966
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/impl/streamwrapper/OmStAXBuilderTest.java	Wed Dec 15 04:06:14 2004
@@ -6,6 +6,8 @@
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.XMLOutputFactory;
 
 import org.apache.axis.AbstractTestCase;
 import org.apache.axis.impl.llom.serialize.SimpleOMSerializer;
@@ -44,7 +46,7 @@
     protected void setUp() throws Exception {
         factory = OMFactory.newInstance();
         XMLStreamReader reader = XMLInputFactory.newInstance().
-                createXMLStreamReader(new FileReader(getTestResourceFile("soap/soapmessage1.xml")));
+                createXMLStreamReader(new FileReader(getTestResourceFile("soap/soapmessage.xml")));
         builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(factory,reader);
         serilizer = new SimpleOMSerializer();
 
@@ -55,7 +57,9 @@
 
         SOAPEnvelope envelope = (SOAPEnvelope)builder.getDocumentElement();
         assertNotNull(envelope);
-        serilizer.serialize(envelope,new FileOutputStream(tempFile));
+        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(tempFile));
+//        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
+        serilizer.serialize(envelope,writer);
 
 
     }