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 ch...@apache.org on 2005/08/25 09:50:59 UTC

svn commit: r240018 - in /webservices/axis/trunk/java/modules/xml/src/org/apache/axis2: om/impl/llom/ om/impl/llom/builder/ soap/ soap/impl/llom/ soap/impl/llom/builder/ soap/impl/llom/factory/

Author: chinthaka
Date: Thu Aug 25 00:48:01 2005
New Revision: 240018

URL: http://svn.apache.org/viewcvs?rev=240018&view=rev
Log:
- Adding SOAPMessage

Added:
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPMessage.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
Modified:
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java?rev=240018&r1=240017&r2=240018&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMDocumentImpl.java Thu Aug 25 00:48:01 2005
@@ -31,7 +31,7 @@
     /**
      * Field rootElement
      */
-    private OMElement rootElement;
+    protected OMElement rootElement;
 
     /**
      * Field firstChild
@@ -41,7 +41,7 @@
     /**
      * Field lastChild
      */
-    private OMNode lastChild;
+    protected OMNode lastChild;
 
     /**
      * Field done
@@ -51,18 +51,18 @@
     /**
      * Field parserWrapper
      */
-    private OMXMLParserWrapper parserWrapper;
+    protected OMXMLParserWrapper parserWrapper;
 
     /**
      * Field charSetEncoding
      * Dafult : UTF-8
      */
-    private String charSetEncoding = "UTF-8";
+    protected String charSetEncoding = "UTF-8";
     
     /**
      * Field xmlVersion
      */
-    private String xmlVersion = "1.0";
+    protected String xmlVersion = "1.0";
     
 
     

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java?rev=240018&r1=240017&r2=240018&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/builder/StAXOMBuilder.java Thu Aug 25 00:48:01 2005
@@ -250,4 +250,8 @@
             }
         }
     }
+
+    public OMDocumentImpl getDocument() {
+        return document;
+    }
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java?rev=240018&r1=240017&r2=240018&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java Thu Aug 25 00:48:01 2005
@@ -27,6 +27,9 @@
      * Eran Chinthaka (chinthaka@apache.org)
      */
 
+    public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder);
+    public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper);
+
     /**
      * @param builder
      * @return

Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPMessage.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPMessage.java?rev=240018&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPMessage.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPMessage.java Thu Aug 25 00:48:01 2005
@@ -0,0 +1,29 @@
+package org.apache.axis2.soap;
+
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * 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
+ *
+ *      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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public interface SOAPMessage extends OMDocument {
+
+    public SOAPEnvelope getSOAPEnvelope() throws SOAPProcessingException;
+    public void setSOAPEnvelope(SOAPEnvelope envelope) throws SOAPProcessingException;
+
+}

Added: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java?rev=240018&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java (added)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/SOAPMessageImpl.java Thu Aug 25 00:48:01 2005
@@ -0,0 +1,86 @@
+package org.apache.axis2.soap.impl.llom;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNode;
+import org.apache.axis2.om.OMXMLParserWrapper;
+import org.apache.axis2.om.impl.OMOutputImpl;
+import org.apache.axis2.om.impl.llom.OMDocumentImpl;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPMessage;
+
+import javax.xml.stream.XMLStreamException;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * 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
+ *
+ *      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.
+ *
+ * @author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class SOAPMessageImpl extends OMDocumentImpl implements SOAPMessage {
+
+
+    public SOAPMessageImpl() {
+    }
+
+    public SOAPMessageImpl(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper) {
+        super(envelope, parserWrapper);
+    }
+
+    public SOAPMessageImpl(OMXMLParserWrapper parserWrapper) {
+        super(parserWrapper);
+    }
+
+
+    public SOAPEnvelope getSOAPEnvelope() throws SOAPProcessingException {
+        return (SOAPEnvelope) getDocumentElement();
+    }
+
+    public void setSOAPEnvelope(SOAPEnvelope envelope) throws SOAPProcessingException {
+        super.addChild(envelope);
+        this.rootElement = envelope;
+    }
+
+    public void setDocumentElement(OMElement rootElement) {
+        throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
+    }
+
+    public void addChild(OMNode child) {
+        throw new UnsupportedOperationException("Can not add normal children to SOAP envelope. Use setSOAPEnvelope()");
+    }
+
+
+    public void setFirstChild(OMNode firstChild) {
+        throw new UnsupportedOperationException("This is not allowed. Use set SOAPEnvelope instead");
+    }
+
+    private void serialize(OMOutputImpl omOutput, boolean cache, boolean includeXMLDeclaration) throws XMLStreamException {
+        if (includeXMLDeclaration) {
+            //Check whether the OMOutput char encoding and OMDocument char
+            //encoding matches, if not use char encoding of OMOutput
+            String outputCharEncoding = omOutput.getCharSetEncoding();
+            if (!outputCharEncoding.equalsIgnoreCase(this.charSetEncoding)) {
+                this.charSetEncoding = outputCharEncoding;
+            }
+            omOutput.getXmlStreamWriter().writeStartDocument(charSetEncoding,
+                    xmlVersion);
+        }
+
+        if (cache) {
+            this.rootElement.serializeWithCache(omOutput);
+        } else {
+            this.rootElement.serialize(omOutput);
+        }
+    }
+}

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=240018&r1=240017&r2=240018&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java Thu Aug 25 00:48:01 2005
@@ -16,6 +16,7 @@
 package org.apache.axis2.soap.impl.llom.builder;
 
 import org.apache.axis2.om.*;
+import org.apache.axis2.om.impl.llom.OMDocumentImpl;
 import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
 import org.apache.axis2.soap.*;
 import org.apache.axis2.soap.impl.llom.SOAPConstants;
@@ -30,6 +31,8 @@
  * Class StAXSOAPModelBuilder
  */
 public class StAXSOAPModelBuilder extends StAXOMBuilder {
+
+    SOAPMessage soapMessage;
     /**
      * Field envelope
      */
@@ -86,6 +89,7 @@
     public StAXSOAPModelBuilder(XMLStreamReader parser, String soapVersion) {
         super(parser);
         soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        soapMessage = soapFactory.createSOAPMessage(this);
         identifySOAPVersion(soapVersion);
         parseHeaders();
     }
@@ -102,8 +106,8 @@
     public StAXSOAPModelBuilder(XMLStreamReader parser, SOAPFactory factory, String soapVersion) {
         super(parser);
         soapFactory = factory;
+        soapMessage = soapFactory.createSOAPMessage(this);
         identifySOAPVersion(soapVersion);
-
         parseHeaders();
     }
 
@@ -176,6 +180,7 @@
         String elementName = parser.getLocalName();
         if (lastNode == null) {
             node = constructNode(null, elementName, true);
+            soapMessage.setSOAPEnvelope((SOAPEnvelope) node);
         } else if (lastNode.isComplete()) {
             node =
                     constructNode((OMElement) lastNode.getParent(),
@@ -201,7 +206,6 @@
      * @param parent
      * @param elementName
      * @param isEnvelope
-     * @return
      */
     protected OMElement constructNode(OMElement parent, String elementName,
                                       boolean isEnvelope) {
@@ -353,7 +357,7 @@
     protected OMNode createDTD() throws OMException {
     	throw new OMException("SOAP message MUST NOT contain a Document Type Declaration(DTD)");
     }
-    
+
     /**
      * Method createPI
      * 
@@ -363,7 +367,7 @@
     protected OMNode createPI() throws OMException {
     	throw new OMException("SOAP message MUST NOT contain Processing Instructions(PI)");
     }
-    
+
     /**
      * Method getDocumentElement
      *
@@ -401,7 +405,7 @@
                 namespace = node.findNamespace(namespaceURI, prefix);
             }
             node.setNamespace(namespace);
-        } 
+        }
 
 
 
@@ -437,6 +441,14 @@
 
     public void setProcessingDetailElements(boolean value) {
         processingDetailElements = value;
+    }
+
+    public SOAPMessage getSoapMessage() {
+        return soapMessage;
+    }
+
+    public OMDocumentImpl getDocument() {
+        return (OMDocumentImpl) this.soapMessage;
     }
 
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java?rev=240018&r1=240017&r2=240018&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java Thu Aug 25 00:48:01 2005
@@ -5,6 +5,7 @@
 import org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory;
 import org.apache.axis2.soap.*;
 import org.apache.axis2.soap.impl.llom.SOAPEnvelopeImpl;
+import org.apache.axis2.soap.impl.llom.SOAPMessageImpl;
 import org.apache.axis2.soap.impl.llom.SOAPProcessingException;
 
 /**
@@ -24,6 +25,14 @@
  * <p/>
  */
 public class SOAPLinkedListImplFactory extends OMLinkedListImplFactory implements SOAPFactory {
+    public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
+        return new SOAPMessageImpl(builder);
+    }
+
+    public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper) {
+        return new SOAPMessageImpl(envelope, parserWrapper);
+    }
+
     /**
      * Eran Chinthaka (chinthaka@apache.org)
      */