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 th...@apache.org on 2007/02/26 07:58:07 UTC

svn commit: r511738 [1/2] - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: builder/ context/ deployment/ engine/ transport/ transport/http/ transport/http/util/ transport/jms/ transport/local/ transport/mail/ transport/mail/serve...

Author: thilina
Date: Sun Feb 25 22:58:06 2007
New Revision: 511738

URL: http://svn.apache.org/viewvc?view=rev&rev=511738
Log:
Moving the Builders to a separate package
Adding Builder wrappers to SOAP, MIME, MTOM
Renaming Builder util class to BuilderUtil

Adding MTOM, SOAP, MIME builders mappings by defualt when creating AxisConfig
refactoring TransportUtils


Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/Builder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java
Removed:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/OMBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/RESTUtil.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSUtils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportReceiver.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailTransportSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/server/MailSorter.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/tcp/TCPWorker.java

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/Builder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/Builder.java?view=auto&rev=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/Builder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/Builder.java Sun Feb 25 22:58:06 2007
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006,2007 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.
+ */
+
+package org.apache.axis2.builder;
+
+import java.io.InputStream;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+public interface Builder {
+    
+    /**
+     * @return Returns the document element.
+     */
+    public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault;
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?view=auto&rev=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Sun Feb 25 22:58:06 2007
@@ -0,0 +1,423 @@
+/*
+ * Copyright 2004,2005 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.
+ */
+
+package org.apache.axis2.builder;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PushbackInputStream;
+import java.io.Reader;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.MTOMConstants;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPConstants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+public class BuilderUtil {
+    public static final int BOM_SIZE = 4;
+    
+    public static StAXBuilder getPOXBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
+        StAXBuilder builder;
+        XMLStreamReader xmlreader =
+            StAXUtils.createXMLStreamReader(inStream, charSetEnc);
+        builder = new StAXOMBuilder(xmlreader);
+        return builder;
+    }
+    
+    /**
+     * Use the BOM Mark to identify the encoding to be used. Fall back to
+     * default encoding specified
+     *
+     * @param is
+     * @param charSetEncoding
+     * @throws java.io.IOException
+     */
+    public static Reader getReader(InputStream is, String charSetEncoding) throws IOException {
+        PushbackInputStream is2 = new PushbackInputStream(is, BOM_SIZE);
+        String encoding;
+        byte bom[] = new byte[BOM_SIZE];
+        int n, unread;
+        
+        n = is2.read(bom, 0, bom.length);
+        
+        if ((bom[0] == (byte) 0xEF) && (bom[1] == (byte) 0xBB) && (bom[2] == (byte) 0xBF)) {
+            encoding = "UTF-8";
+            unread = n - 3;
+        } else if ((bom[0] == (byte) 0xFE) && (bom[1] == (byte) 0xFF)) {
+            encoding = "UTF-16BE";
+            unread = n - 2;
+        } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE)) {
+            encoding = "UTF-16LE";
+            unread = n - 2;
+        } else if ((bom[0] == (byte) 0x00) && (bom[1] == (byte) 0x00) && (bom[2] == (byte) 0xFE)
+                && (bom[3] == (byte) 0xFF)) {
+            encoding = "UTF-32BE";
+            unread = n - 4;
+        } else if ((bom[0] == (byte) 0xFF) && (bom[1] == (byte) 0xFE) && (bom[2] == (byte) 0x00)
+                && (bom[3] == (byte) 0x00)) {
+            encoding = "UTF-32LE";
+            unread = n - 4;
+        } else {
+            
+            // Unicode BOM mark not found, unread all bytes
+            encoding = charSetEncoding;
+            unread = n;
+        }
+        
+        if (unread > 0) {
+            is2.unread(bom, (n - unread), unread);
+        }
+        
+        return new BufferedReader(new InputStreamReader(is2, encoding));
+    }
+    
+    
+    public static String getEnvelopeNamespace(String contentType) {
+        String soapNS = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+        if(contentType != null) {
+            if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
+                // it is SOAP 1.2
+                soapNS = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            } else if (contentType.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
+                // SOAP 1.1
+                soapNS = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+            }
+        }
+        return soapNS;
+    }
+    
+    /**
+     * Extracts and returns the character set encoding from the
+     * Content-type header
+     * Example:
+     * Content-Type: text/xml; charset=utf-8
+     *
+     * @param contentType
+     */
+    public static String getCharSetEncoding(String contentType) {
+        if (contentType == null) {
+            // Using the default UTF-8
+            return MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+        
+        int index = contentType.indexOf(HTTPConstants.CHAR_SET_ENCODING);
+        
+        if (index == -1) {    // Charset encoding not found in the content-type header
+            // Using the default UTF-8
+            return MessageContext.DEFAULT_CHAR_SET_ENCODING;
+        }
+        
+        // If there are spaces around the '=' sign
+        int indexOfEq = contentType.indexOf("=", index);
+        
+        // There can be situations where "charset" is not the last parameter of the Content-Type header
+        int indexOfSemiColon = contentType.indexOf(";", indexOfEq);
+        String value;
+        
+        if (indexOfSemiColon > 0) {
+            value = (contentType.substring(indexOfEq + 1, indexOfSemiColon));
+        } else {
+            value = (contentType.substring(indexOfEq + 1, contentType.length())).trim();
+        }
+        
+        // There might be "" around the value - if so remove them
+        if(value.indexOf('\"')!=-1){
+            value = value.replaceAll("\"", "");
+        }
+        
+        return value.trim();
+    }
+    
+    public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
+            InputStream inStream, String contentTypeString, boolean isSOAP)
+    throws OMException, XMLStreamException, FactoryConfigurationError {
+        StAXBuilder builder = null;
+        XMLStreamReader streamReader;
+        
+        Attachments attachments = createAttachmentsMap(msgContext, inStream, contentTypeString);
+        String charSetEncoding = getCharSetEncoding(attachments.getSOAPPartContentType());
+        
+        if ((charSetEncoding == null)
+                || "null".equalsIgnoreCase(charSetEncoding)) {
+            charSetEncoding = MessageContext.UTF_8;
+        }
+        msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
+                charSetEncoding);
+        
+        try {
+            streamReader = StAXUtils.createXMLStreamReader(getReader(
+                    attachments.getSOAPPartInputStream(), charSetEncoding));
+        } catch (IOException e) {
+            throw new XMLStreamException(e);
+        }
+        
+        
+        //  Put a reference to Attachments Map in to the message context For
+        // backword compatibility with Axis2 1.0 
+        msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
+        
+        // Setting the Attachments map to new SwA API
+        msgContext.setAttachmentMap(attachments);
+        
+        String soapEnvelopeNamespaceURI = getEnvelopeNamespace(contentTypeString);
+        
+        if (isSOAP) {
+            if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.MTOM_TYPE)) {
+                //Creates the MTOM specific MTOMStAXSOAPModelBuilder
+                builder = new MTOMStAXSOAPModelBuilder(streamReader,
+                        attachments, soapEnvelopeNamespaceURI);
+                msgContext.setDoingMTOM(true);
+            } else if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.SWA_TYPE)) {
+                builder = new StAXSOAPModelBuilder(streamReader,
+                        soapEnvelopeNamespaceURI);
+            } else if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.SWA_TYPE_12) ) {
+                builder = new StAXSOAPModelBuilder(streamReader,
+                        soapEnvelopeNamespaceURI);
+            }
+            
+        }
+        // To handle REST XOP case
+        else {
+            if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.MTOM_TYPE)) {
+                XOPAwareStAXOMBuilder stAXOMBuilder = new XOPAwareStAXOMBuilder(
+                        streamReader, attachments);
+                builder = stAXOMBuilder;
+                
+            } else if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.SWA_TYPE)) {
+                builder = new StAXOMBuilder(streamReader);
+            } else if (attachments.getAttachmentSpecType().equals(
+                    MTOMConstants.SWA_TYPE_12) ) {
+                builder = new StAXOMBuilder(streamReader);
+            }
+        }
+        
+        return builder;
+    }
+    
+    protected static Attachments createAttachmentsMap(MessageContext msgContext, InputStream inStream, String contentTypeString) {
+        Object cacheAttachmentProperty = msgContext
+        .getProperty(Constants.Configuration.CACHE_ATTACHMENTS);
+        String cacheAttachmentString = null;
+        boolean fileCacheForAttachments;
+        
+        if (cacheAttachmentProperty != null
+                && cacheAttachmentProperty instanceof String) {
+            cacheAttachmentString = (String) cacheAttachmentProperty;
+            fileCacheForAttachments = (Constants.VALUE_TRUE
+                    .equals(cacheAttachmentString));
+        } else {
+            Parameter parameter_cache_attachment = msgContext
+            .getParameter(Constants.Configuration.CACHE_ATTACHMENTS);
+            cacheAttachmentString = (parameter_cache_attachment != null) ? (String) parameter_cache_attachment
+                    .getValue()
+                    : null;
+        }
+        fileCacheForAttachments = (Constants.VALUE_TRUE
+                .equals(cacheAttachmentString));
+        
+        String attachmentRepoDir = null;
+        String attachmentSizeThreshold = null;
+        
+        if (fileCacheForAttachments) {
+            Object attachmentRepoDirProperty = msgContext
+            .getProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+            
+            if (attachmentRepoDirProperty != null) {
+                attachmentRepoDir = (String) attachmentRepoDirProperty;
+            } else {
+                Parameter attachmentRepoDirParameter = msgContext
+                .getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+                attachmentRepoDir = (attachmentRepoDirParameter != null) ? (String) attachmentRepoDirParameter
+                        .getValue()
+                        : null;
+            }
+            
+            Object attachmentSizeThresholdProperty = msgContext
+            .getProperty(Constants.Configuration.FILE_SIZE_THRESHOLD);
+            if (attachmentSizeThresholdProperty != null
+                    && attachmentSizeThresholdProperty instanceof String) {
+                attachmentSizeThreshold = (String) attachmentSizeThresholdProperty;
+            } else {
+                Parameter attachmentSizeThresholdParameter = msgContext
+                .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
+                attachmentSizeThreshold = attachmentSizeThresholdParameter
+                .getValue().toString();
+            }
+        }
+        
+        Attachments attachments = new Attachments(inStream, contentTypeString,
+                fileCacheForAttachments, attachmentRepoDir,
+                attachmentSizeThreshold);
+        return attachments;
+    }
+    
+    /**
+     * @deprecated If some one really need this method, please shout.
+     * 
+     * @param in
+     * @return
+     * @throws XMLStreamException
+     */
+    public static StAXBuilder getBuilder(Reader in) throws XMLStreamException {
+        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in);
+        StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
+        return builder;
+    }
+    
+    /**
+     * Creates an OMBuilder for a plain XML message. Default character set encording is used.
+     * 
+     * @param inStream InputStream for a XML message
+     * @return Handler to a OMBuilder implementation instance
+     * @throws XMLStreamException
+     */
+    public static StAXBuilder getBuilder(InputStream inStream) throws XMLStreamException {
+        XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
+        return new StAXOMBuilder(xmlReader);
+    }
+    
+    /**
+     * Creates an OMBuilder for a plain XML message.
+     * 
+     * @param inStream InputStream for a XML message
+     * @param charSetEnc Character set encoding to be used
+     * @return Handler to a OMBuilder implementation instance
+     * @throws XMLStreamException
+     */
+    public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
+        XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
+        return new StAXOMBuilder(xmlReader);
+    }
+    
+    /**
+     * Creates an OMBuilder for a SOAP message. Default character set encording is used.
+     * 
+     * @param inStream InputStream for a SOAP message
+     * @param soapNamespaceURI Specifies which SOAP version to use, 
+     *              {@link SOAP11Constants#SOAP_11_CONTENT_TYPE} or 
+     *              {@link SOAP12Constants#SOAP_12_CONTENT_TYPE}
+     * @return Handler to a OMBuilder implementation instance
+     * @throws XMLStreamException
+     */
+    public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
+        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(inStream);
+        return new StAXSOAPModelBuilder(xmlreader);
+    }
+    
+    /**
+     * Creates an OMBuilder for a SOAP message.
+     * 
+     * @param inStream InputStream for a SOAP message
+     * @param charSetEnc Character set encoding to be used
+     * @param soapNamespaceURI Specifies which SOAP version to use, 
+     *              {@link SOAP11Constants#SOAP_11_CONTENT_TYPE} or 
+     *              {@link SOAP12Constants#SOAP_12_CONTENT_TYPE}
+     * @return Handler to a OMBuilder implementation instance
+     * @throws XMLStreamException
+     */
+    public static StAXBuilder getSOAPBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
+        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
+        return new StAXSOAPModelBuilder(xmlreader);
+    }
+    
+    public static StAXBuilder getBuilder(SOAPFactory soapFactory, InputStream in, String charSetEnc) throws XMLStreamException {
+        StAXBuilder builder;
+        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in, charSetEnc);
+        builder = new StAXOMBuilder(soapFactory, xmlreader);
+        return builder;
+    }
+    
+    /**
+     * Initial work for a builder selector which selects the builder for a given
+     * message format based on the the content type of the recieved message.
+     * content-type to builder mapping can be specified through the Axis2.xml.
+     * 
+     * @param type
+     * @param msgContext
+     * @return the builder registered against the given content-type
+     * @throws AxisFault
+     */
+    public static Builder getBuilderFromSelector(String type,MessageContext msgContext) throws AxisFault {
+        
+        Builder builder = msgContext.getConfigurationContext().getAxisConfiguration()
+        .getMessageBuilder(type);
+        if (builder != null) {
+            // Setting the received content-type as the messageType to make
+            // sure that we respond using the received message serialisation
+            // format.
+            msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, type);
+        }
+        return builder;
+    }
+    
+    public static void validateSOAPVersion(String soapNamespaceURIFromTransport, SOAPEnvelope envelope)
+    {
+        if (soapNamespaceURIFromTransport != null) {
+            OMNamespace envelopeNamespace = envelope.getNamespace();
+            String namespaceName = envelopeNamespace.getNamespaceURI();
+            if (!(soapNamespaceURIFromTransport.equals(namespaceName))){
+                throw new SOAPProcessingException("Transport level information does not match with SOAP" +
+                        " Message namespace URI", envelopeNamespace.getPrefix() + ":" + SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
+            }
+        }
+    }
+    public static void validateCharSetEncoding(String charsetEncodingFromTransport,String charsetEncodingFromXML, String soapNamespaceURI) throws AxisFault {
+        if ((charsetEncodingFromXML != null)
+                && !"".equals(charsetEncodingFromXML)
+                && (charsetEncodingFromTransport != null)
+                && !charsetEncodingFromXML.equalsIgnoreCase((String) charsetEncodingFromTransport)) {
+            String faultCode;
+            
+            if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
+                faultCode = SOAP12Constants.FAULT_CODE_SENDER;
+            } else {
+                faultCode = SOAP11Constants.FAULT_CODE_SENDER;
+            }
+            
+            throw new AxisFault("Character Set Encoding from "
+                    + "transport information do not match with "
+                    + "character set encoding in the received SOAP message", faultCode);
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java?view=auto&rev=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MIMEBuilder.java Sun Feb 25 22:58:06 2007
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2006,2007 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.
+ */
+
+package org.apache.axis2.builder;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.MTOMConstants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+
+public class MIMEBuilder implements Builder {
+    
+    public OMElement processDocument(InputStream inputStream, String contentType, MessageContext msgContext)
+    throws AxisFault {
+        XMLStreamReader streamReader;
+        Attachments attachments = BuilderUtil.createAttachmentsMap(msgContext, inputStream, contentType);
+        String charSetEncoding = BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());
+        
+        if ((charSetEncoding == null)
+                || "null".equalsIgnoreCase(charSetEncoding)) {
+            charSetEncoding = MessageContext.UTF_8;
+        }
+        msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
+                charSetEncoding);
+        
+        //  Put a reference to Attachments Map in to the message context For
+        // backword compatibility with Axis2 1.0 
+        msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
+        
+        // Setting the Attachments map to new SwA API
+        msgContext.setAttachmentMap(attachments);
+        
+//      if (isSOAP) {
+        Builder builder = BuilderUtil.getBuilderFromSelector(attachments.getAttachmentSpecType(),msgContext);
+        OMElement element = builder.processDocument(attachments.getSOAPPartInputStream(),contentType,msgContext);
+        
+//      }
+//      // To handle REST XOP case
+//      else {
+//      if (attachments.getAttachmentSpecType().equals(
+//      MTOMConstants.MTOM_TYPE)) {
+//      XOPAwareStAXOMBuilder stAXOMBuilder = new XOPAwareStAXOMBuilder(
+//      streamReader, attachments);
+//      builder = stAXOMBuilder;
+//      
+//      } else if (attachments.getAttachmentSpecType().equals(
+//      MTOMConstants.SWA_TYPE)) {
+//      builder = new StAXOMBuilder(streamReader);
+//      } else if (attachments.getAttachmentSpecType().equals(
+//      MTOMConstants.SWA_TYPE_12) ) {
+//      builder = new StAXOMBuilder(streamReader);
+//      }
+//      }
+        
+        return element;
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java?view=auto&rev=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/MTOMBuilder.java Sun Feb 25 22:58:06 2007
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006,2007 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.
+ */
+
+package org.apache.axis2.builder;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+
+public class MTOMBuilder implements Builder {
+    
+    public OMElement processDocument(InputStream inputStream, String contentType,MessageContext messageContext)
+    throws AxisFault {
+        XMLStreamReader streamReader;
+        try {
+            Attachments attachments = messageContext.getAttachmentMap();
+            String charSetEncoding = (String) messageContext
+            .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+            streamReader = StAXUtils.createXMLStreamReader(BuilderUtil.getReader(inputStream,
+                    charSetEncoding));
+            StAXBuilder builder = new MTOMStAXSOAPModelBuilder(streamReader,
+                    attachments);
+            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
+            BuilderUtil.validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
+            BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
+                    .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
+            return envelope;
+        } catch (IOException e) {
+            throw new AxisFault(e);
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java?view=auto&rev=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/builder/SOAPBuilder.java Sun Feb 25 22:58:06 2007
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006,2007 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.
+ */
+
+package org.apache.axis2.builder;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+
+public class SOAPBuilder implements Builder {
+    
+    public OMElement processDocument(InputStream inputStream, String contentType,
+            MessageContext messageContext) throws AxisFault {
+        XMLStreamReader streamReader;
+        try {
+            String charSetEncoding = (String) messageContext
+            .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+            streamReader = StAXUtils.createXMLStreamReader(BuilderUtil.getReader(inputStream,
+                    charSetEncoding));
+            StAXBuilder builder = new StAXSOAPModelBuilder(streamReader);
+            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
+            BuilderUtil.validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
+            BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
+                    .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
+            return envelope;
+        } catch (IOException e) {
+            throw new AxisFault(e);
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Sun Feb 25 22:58:06 2007
@@ -31,6 +31,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.description.AxisMessage;
 import org.apache.axis2.description.AxisModule;
@@ -45,7 +46,6 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Handler;
 import org.apache.axis2.engine.Phase;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.LoggingControl;
 import org.apache.axis2.util.MetaDataEntry;
 import org.apache.axis2.util.ObjectStateUtils;
@@ -2951,7 +2951,7 @@
                 try {
                     if (persistedWithOptimizedMTOM) {
                         boolean isSOAP = true;
-                        StAXBuilder builder = Builder.getAttachmentsBuilder(this, msgBuffer, contentType, isSOAP);
+                        StAXBuilder builder = BuilderUtil.getAttachmentsBuilder(this, msgBuffer, contentType, isSOAP);
                         envelope = (SOAPEnvelope) builder.getDocumentElement();
                     } else {
                         xmlreader = StAXUtils.createXMLStreamReader(msgBuffer, charSetEnc);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Sun Feb 25 22:58:06 2007
@@ -20,7 +20,10 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.OMBuilder;
+import org.apache.axis2.builder.Builder;
+import org.apache.axis2.builder.MIMEBuilder;
+import org.apache.axis2.builder.MTOMBuilder;
+import org.apache.axis2.builder.SOAPBuilder;
 import org.apache.axis2.dataretrieval.DRConstants;
 import org.apache.axis2.deployment.util.PhasesInfo;
 import org.apache.axis2.deployment.util.Utils;
@@ -160,9 +163,16 @@
                 Iterator keys = builderSelector.keySet().iterator();
                 while (keys.hasNext()) {
                     String key = (String) keys.next();
-                    axisConfig.addMessageBuilder(key, (OMBuilder) builderSelector.get(key));
+                    axisConfig.addMessageBuilder(key, (Builder) builderSelector.get(key));
                 }
             }
+    		/*
+    		 * Add Axis2 default builders if they are not overidden by the config
+    		 */
+    			axisConfig.addMessageBuilder("multipart/related", new MIMEBuilder());
+    			axisConfig.addMessageBuilder("application/soap+xml", new SOAPBuilder());
+    			axisConfig.addMessageBuilder("text/xml", new SOAPBuilder());
+    			axisConfig.addMessageBuilder("application/xop+xml", new MTOMBuilder());
 
             //process dataLocator configuration
             OMElement dataLocatorElement =

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java Sun Feb 25 22:58:06 2007
@@ -20,7 +20,9 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.builder.OMBuilder;
+import org.apache.axis2.builder.Builder;
+import org.apache.axis2.builder.MIMEBuilder;
+import org.apache.axis2.builder.SOAPBuilder;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
@@ -208,100 +210,103 @@
      * @param messageBuildersElement
      */
     protected HashMap processMessageBuilders(OMElement messageBuildersElement)
-            throws DeploymentException {
+    throws DeploymentException {
         HashMap builderSelector = new HashMap();
         Iterator msgBuilders = messageBuildersElement
-                .getChildrenWithName(new QName(TAG_MESSAGE_BUILDER));
+        .getChildrenWithName(new QName(TAG_MESSAGE_BUILDER));
         while (msgBuilders.hasNext()) {
             OMElement msgBuilderElement = (OMElement) msgBuilders.next();
-            final OMElement tempMsgBuilder = msgBuilderElement;
+            OMElement tempMsgBuilder = msgBuilderElement;
+            OMAttribute builderName = tempMsgBuilder.getAttribute(new QName(TAG_CLASS_NAME));
+            String className = builderName.getAttributeValue();
             Class builderClass = null;
-            OMBuilder builderObject;
+            Builder builderObject;
             try {
-                builderClass = findAndValidateSelectorClass(tempMsgBuilder,
+                builderClass = findAndValidateSelectorClass(className,
                         DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_BUILDER);
-                builderObject = (OMBuilder)builderClass.newInstance();
+                builderObject = (Builder)builderClass.newInstance();
             } catch (PrivilegedActionException e) {
                 throw (DeploymentException) e.getException();
             } catch (InstantiationException e) {
                 throw new DeploymentException(
                         "Cannot instantiate the specified Builder Class  : "
-                                + builderClass.getName() + ".", e);
+                        + builderClass.getName() + ".", e);
             } catch (IllegalAccessException e) {
                 throw new DeploymentException(
                         "Cannot instantiate the specified Builder Class : "
-                                + builderClass.getName() + ".", e);
+                        + builderClass.getName() + ".", e);
             }
             OMAttribute contentTypeAtt = msgBuilderElement
-                    .getAttribute(new QName(TAG_CONTENT_TYPE));
+            .getAttribute(new QName(TAG_CONTENT_TYPE));
             builderSelector.put(contentTypeAtt.getAttributeValue(),
                     builderObject);
-        }
+        }		
         return builderSelector;
     }
     
+    
     /**
      * Processes the message builders specified in axis2.xml or services.xml.
      * 
      * @param messageBuildersElement
      */
     protected HashMap processMessageFormatters(OMElement messageFormattersElement)
-            throws DeploymentException {
+    throws DeploymentException {
         HashMap messageFormatters = new HashMap();
         Iterator msgFormatters = messageFormattersElement
-                .getChildrenWithName(new QName(TAG_MESSAGE_FORMATTER));
+        .getChildrenWithName(new QName(TAG_MESSAGE_FORMATTER));
         while (msgFormatters.hasNext()) {
             OMElement msgFormatterElement = (OMElement) msgFormatters.next();
-            final OMElement tempMsgFormatter = msgFormatterElement;
+            OMElement tempMsgFormatter = msgFormatterElement;
+            OMAttribute formatterName = tempMsgFormatter.getAttribute(new QName(TAG_CLASS_NAME));
+            String className = formatterName.getAttributeValue();
             MessageFormatter formatterObject;
             Class formatterClass = null;
             try {
-                formatterClass = findAndValidateSelectorClass(tempMsgFormatter,DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_FORMATTER );
+                formatterClass = findAndValidateSelectorClass(className,DeploymentErrorMsgs.ERROR_LOADING_MESSAGE_FORMATTER );
                 formatterObject = (MessageFormatter)formatterClass.newInstance();
             } catch (PrivilegedActionException e) {
                 throw (DeploymentException) e.getException();
             } catch (InstantiationException e) {
                 throw new DeploymentException(
                         "Cannot instantiate the specified Formatter Class  : "
-                                + formatterClass.getName() + ".", e);
+                        + formatterClass.getName() + ".", e);
             } catch (IllegalAccessException e) {
                 throw new DeploymentException(
                         "Cannot instantiate the specified Formatter Class : "
-                                + formatterClass.getName() + ".", e);
+                        + formatterClass.getName() + ".", e);
             }
             OMAttribute contentTypeAtt = msgFormatterElement
-                    .getAttribute(new QName(TAG_CONTENT_TYPE));
+            .getAttribute(new QName(TAG_CONTENT_TYPE));
             messageFormatters.put(contentTypeAtt.getAttributeValue(),
                     formatterObject);
         }
         return messageFormatters;
     }
-
-    protected Class findAndValidateSelectorClass(final OMElement tempMsgBuilder, final String errorMsg)
-            throws PrivilegedActionException {
+    
+    protected Class findAndValidateSelectorClass(final String className, final String errorMsg)
+    throws PrivilegedActionException {
         return (Class) org.apache.axis2.java.security.AccessController
-                .doPrivileged(new PrivilegedExceptionAction() {
-                    public Object run()
-                            throws org.apache.axis2.deployment.DeploymentException {
-                        OMAttribute builderName = tempMsgBuilder
-                                .getAttribute(new QName(TAG_CLASS_NAME));
-                        String className = builderName.getAttributeValue();
-                        Class selectorClass;
-                        try {
-                            if ((className != null) && !"".equals(className)) {
-                                selectorClass = Loader.loadClass(Thread.currentThread()
-                                        .getContextClassLoader(), className);
-                            } else {
-                                throw new DeploymentException(Messages.getMessage(errorMsg,
-                                        "Invalid Class Name",className));
-                            }
-                        } catch (ClassNotFoundException e) {
-                            throw new DeploymentException(Messages.getMessage(errorMsg,
-                                                    "ClassNotFoundException",className), e);
-                        }
-                        return selectorClass;
+        .doPrivileged(new PrivilegedExceptionAction() {
+            public Object run()
+            throws org.apache.axis2.deployment.DeploymentException {
+                Class selectorClass;
+                try {
+                    if ((className != null) && !"".equals(className)) {
+                        selectorClass = Loader.loadClass(Thread.currentThread()
+                                .getContextClassLoader(), className);
+                    }else
+                    {
+                        throw new DeploymentException(Messages.getMessage(errorMsg,
+                                "Invalid Class Name",className));
                     }
-                });
+                } catch (ClassNotFoundException e) {
+                    throw new DeploymentException(Messages.getMessage(errorMsg,
+                            "ClassNotFoundException",className), e);
+                }
+                return selectorClass;
+            }
+        });
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java Sun Feb 25 22:58:06 2007
@@ -17,7 +17,7 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.builder.OMBuilder;
+import org.apache.axis2.builder.Builder;
 import org.apache.axis2.cluster.ClusterManager;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.dataretrieval.AxisDataLocator;
@@ -169,25 +169,23 @@
         this.phasesinfo = new PhasesInfo();
         targetResolvers = new ArrayList();
     }
-
+    
     public void addMessageReceiver(String mepURL,
-                                   MessageReceiver messageReceiver) {
+            MessageReceiver messageReceiver) {
         messageReceivers.put(mepURL, messageReceiver);
     }
-
+    
     /**
      * Register a messageBuilder implementation against a content type.
      * This is used by Axis2 to support different message formats.
-     *
      * @param contentType
      * @param messageBuilder
      */
     public void addMessageBuilder(String contentType,
-            OMBuilder messageBuilder) {
+            Builder messageBuilder) {
         messageBuilders.put(contentType, messageBuilder);
     }
     
-
     /**
      * Register a messageFormatter implementation against a content type.
      * This is used by Axis2 to support serialization of messages to different 
@@ -632,8 +630,8 @@
      * @return the configured message builder implementation class name against
      *         the given content type.
      */
-    public OMBuilder getMessageBuilder(String contentType) {
-        return (OMBuilder)messageBuilders.get(contentType);
+    public Builder getMessageBuilder(String contentType) {
+        return (Builder)messageBuilders.get(contentType);
     }
     
     /**

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Sun Feb 25 22:58:06 2007
@@ -19,23 +19,26 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
-import org.apache.axis2.builder.OMBuilder;
+import org.apache.axis2.builder.BuilderUtil;
+import org.apache.axis2.builder.Builder;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.ApplicationXMLFormatter;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.SOAPMessageFormatter;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -53,53 +56,40 @@
         try {
             InputStream inStream = (InputStream) msgContext
                     .getProperty(MessageContext.TRANSPORT_IN);
-
             msgContext.setProperty(MessageContext.TRANSPORT_IN, null);
 
-            // this inputstram is set by the TransportSender represents a two
-            // way transport or by a Transport Recevier
-            if (inStream == null) {
-                throw new AxisFault(Messages.getMessage("inputstreamNull"));
-            }
-            Object contentTypeObject;
-            boolean isMIME = false;
-            
-            contentTypeObject = msgContext.getProperty(HTTPConstants.CONTENT_TYPE);
-
-            String contentType=null;
-            if(contentTypeObject!=null){
-                contentType =(String) contentTypeObject;
-                if (JavaUtils.indexOfIgnoreCase(contentType,
-                        HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
-                    isMIME = true;
-                }
-            }
-            
-            String soapNamespaceURI = getSOAPNamespaceFromContentType(contentType, null);
-
-            String charSetEnc = (String) msgContext
-                    .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
-            if (charSetEnc == null) {
-                charSetEnc = (String) msgContext
-                        .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
-            }
-            if (charSetEnc == null) {
-                charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
-            }
-            return createSOAPMessage(msgContext, inStream, soapNamespaceURI,
-                    isMIME, contentType, charSetEnc);
-        } catch (AxisFault e) {
-            throw e;
-        } catch (OMException e) {
-            throw new AxisFault(e);
-        } catch (XMLStreamException e) {
-            throw new AxisFault(e);
-        } catch (FactoryConfigurationError e) {
-            throw new AxisFault(e);
-        }
-    }
+			// this inputstram is set by the TransportSender represents a two
+			// way transport or a Transport Recevier
+			if (inStream == null) {
+				throw new AxisFault(Messages.getMessage("inputstreamNull"));
+			}
+
+			String contentType = (String) msgContext
+					.getProperty(Constants.Configuration.CONTENT_TYPE);
+
+			// get the type of char encoding
+			String charSetEnc = (String) msgContext
+					.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+			if (charSetEnc == null && contentType != null) {
+				charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
+			} else if (charSetEnc == null) {
+				charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
+			}
+			msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
+
+			return createSOAPMessage(msgContext, inStream, contentType);
+		} catch (AxisFault e) {
+			throw e;
+		} catch (OMException e) {
+			throw new AxisFault(e);
+		} catch (XMLStreamException e) {
+			throw new AxisFault(e);
+		} catch (FactoryConfigurationError e) {
+			throw new AxisFault(e);
+		}
+	}
 
-    /**
+	/**
      * Objective of this method is to capture the SOAPEnvelope creation logic
      * and make it a common for all the transports and to in/out flows.
      * 
@@ -115,69 +105,52 @@
      * @throws XMLStreamException
      * @throws FactoryConfigurationError
      */
-    public static SOAPEnvelope createSOAPMessage(MessageContext msgContext,
-            InputStream inStream, String soapNamespaceURI, boolean isMIME,
-            String contentType, String charSetEnc) throws AxisFault,
-            OMException, XMLStreamException, FactoryConfigurationError {
-        OMElement documentElement=null;
-        String charsetEncoding=null;
-        if (isMIME) {
-            StAXBuilder builder = Builder.getAttachmentsBuilder(
-                    msgContext, inStream, contentType, !(msgContext
-                            .isDoingREST()));
-            documentElement = builder.getDocumentElement();
-            charsetEncoding = builder.getDocument().getCharsetEncoding();
-        } else if (msgContext.isDoingREST()) {
-            StAXBuilder builder = Builder.getPOXBuilder(inStream,
-                    charSetEnc, soapNamespaceURI);
-            documentElement = builder.getDocumentElement();
-            charsetEncoding = builder.getDocument().getCharsetEncoding();
-//        } else if (soapNamespaceURI!=null){
-//                builder = Builder.getBuilder(inStream, charSetEnc,soapNamespaceURI);
-        } else if (contentType != null) {
-            OMBuilder builder = Builder.getBuilderFromSelector(contentType, msgContext);
-            if (builder != null) {
-                documentElement = builder.processDocument(inStream, msgContext);
-//                charsetEncoding = builder.getCharsetEncoding();
-            }
-        }
-        if (documentElement == null) {
-            //FIXME making soap defualt for the moment..might effect the performance
-            StAXBuilder builder = Builder.getSOAPBuilder(inStream, charSetEnc,soapNamespaceURI);
-            documentElement = builder.getDocumentElement();
-            charsetEncoding = builder.getDocument().getCharsetEncoding();
-//            throw new AxisFault("Cannot find a matching builder for the message. Unsupported Content Type.");
-        }
-        
-        SOAPEnvelope envelope;
-        //Check whether we have received a SOAPEnvelope or not
-        if (documentElement instanceof SOAPEnvelope) {
-            envelope = (SOAPEnvelope) documentElement;
-        } else {
-            //If it is not a SOAPEnvelope we wrap that with a fake SOAPEnvelope.
-            SOAPFactory soapFactory = new SOAP11Factory();
-            envelope= soapFactory.getDefaultEnvelope();
-            envelope.getBody().addChild(documentElement);
-        }
-
-    /*    if ((charsetEncoding != null)
-                && !"".equals(charsetEncoding)
-                && (msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING) != null)
-                && !charsetEncoding.equalsIgnoreCase((String) msgContext
-                                .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING))) {
-            String faultCode;
-
-            if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
-                    envelope.getNamespace().getNamespaceURI())) {
-                faultCode = SOAP12Constants.FAULT_CODE_SENDER;
-            } else {
-                faultCode = SOAP11Constants.FAULT_CODE_SENDER;
-            }
-
-            throw new AxisFault(
-                    "Character Set Encoding from " + "transport information do not match with "
-                    + "character set encoding in the received SOAP message", faultCode);
-        }*/
+	public static SOAPEnvelope createSOAPMessage(MessageContext msgContext, InputStream inStream,
+			String contentType) throws AxisFault, OMException, XMLStreamException,
+			FactoryConfigurationError {
+		OMElement documentElement = null;
+		String charsetEncoding = null;
+		if (msgContext.isDoingREST()) {
+			//TODO KEITH :Do we need this anymore
+			String charSetEnc = (String) msgContext
+					.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+			StAXBuilder builder = BuilderUtil.getPOXBuilder(inStream, charSetEnc);
+			documentElement = builder.getDocumentElement();
+			charsetEncoding = builder.getDocument().getCharsetEncoding();
+		} else if (contentType != null) {
+			String type;
+			int index = contentType.indexOf(';');
+			if (index > 0) {
+				type = contentType.substring(0, index);
+			} else {
+				type = contentType;
+			}
+			Builder builder = BuilderUtil.getBuilderFromSelector(type, msgContext);
+			if (builder != null) {
+				documentElement = builder.processDocument(inStream, contentType, msgContext);
+			}
+		}
+		if (documentElement == null) {
+			// FIXME making soap defualt for the moment..might effect the
+			// performance
+			String charSetEnc = (String) msgContext
+					.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+			StAXBuilder builder = BuilderUtil.getSOAPBuilder(inStream, charSetEnc);
+			documentElement = builder.getDocumentElement();
+			charsetEncoding = builder.getDocument().getCharsetEncoding();
+		}
+
+		SOAPEnvelope envelope;
+		// Check whether we have received a SOAPEnvelope or not
+		if (documentElement instanceof SOAPEnvelope) {
+			envelope = (SOAPEnvelope) documentElement;
+		} else {
+			// If it is not a SOAPEnvelope we wrap that with a fake
+			// SOAPEnvelope.
+			SOAPFactory soapFactory = new SOAP11Factory();
+			envelope = soapFactory.getDefaultEnvelope();
+			envelope.getBody().addChild(documentElement);
+		}
         return envelope;
     }
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Sun Feb 25 22:58:06 2007
@@ -214,9 +214,9 @@
             OperationContext opContext = msgContext.getOperationContext();
             
             if (opContext != null) {
-                opContext.setProperty(
-                        HTTPConstants.CONTENT_TYPE,header.getValue());
-        
+                opContext.setProperty(Constants.Configuration.CONTENT_TYPE,
+                        header.getValue());
+                
             for (int i = 0; i < headers.length; i++) {
                 NameValuePair charsetEnc =headers[i].getParameterByName(
                         HTTPConstants.CHAR_SET_ENCODING);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Sun Feb 25 22:58:06 2007
@@ -110,6 +110,7 @@
         String contentType = request.getContentType();
         if (!isRESTRequest(contentType)) {
             msgContext = createMessageContext(request, response);
+            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE,contentType);
             try {
                 // adding ServletContext into msgContext;
                 InvocationResponse pi = HTTPTransportUtils.

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java Sun Feb 25 22:58:06 2007
@@ -377,10 +377,13 @@
      */
     public static final byte SENDER[] = "400".getBytes();
     public static final String PROXY = "PROXY";
-    public static final String MAIL_SMTP = "_MAIL_SMTP_";
-    public static final String MAIL_POP3 = "_MAIL_POP3_";
     public static final String AUTHENTICATE = "_NTLM_DIGEST_BASIC_AUTHENTICATION_";
+    
+    /**
+     * @deprecated
+     */
     public static final String MTOM_RECEIVED_CONTENT_TYPE = "MTOM_RECEIVED";
+    
     /**
      * Field ISE[]
      */
@@ -467,6 +470,10 @@
     public static final String COOKIE_STRING = "Cookie";
     public static final String HTTP_METHOD_GET = "GET";
     public static final String HTTP_METHOD_POST = "POST";
+    
+    /**
+     * @deprecated Please use Constants.Configuration.CONTENT_TYPE
+     */
     public static final String CONTENT_TYPE = "Content-Type";
 
     public static final String OMIT_SOAP_12_ACTION = "OmitSOAP12Action";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Sun Feb 25 22:58:06 2007
@@ -30,6 +30,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
@@ -38,7 +39,6 @@
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Utils;
 
@@ -194,22 +194,21 @@
     public static InvocationResponse processHTTPPostRequest(MessageContext msgContext, InputStream in,
                                               OutputStream out, String contentType, String soapActionHeader, String requestURI)
             throws AxisFault {
-
         int soapVersion = VERSION_UNKNOWN;
-
         InvocationResponse pi = InvocationResponse.CONTINUE;
         
         try {
 
             Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
-
+            
             if (headers != null) {
-                if (HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING)) ||
-                        HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING_LOWERCASE))) {
+                if (HTTPConstants.COMPRESSION_GZIP.equals(headers
+                        .get(HTTPConstants.HEADER_CONTENT_ENCODING))
+                        || HTTPConstants.COMPRESSION_GZIP.equals(headers
+                                .get(HTTPConstants.HEADER_CONTENT_ENCODING_LOWERCASE))) {
                     in = new GZIPInputStream(in);
                 }
-                }
-
+            }
 
             // remove the starting and trailing " from the SOAP Action
             if ((soapActionHeader != null) && soapActionHeader.charAt(0) == '\"'
@@ -227,49 +226,41 @@
             boolean isMIME=false;
 
             // get the type of char encoding
-            String charSetEnc = Builder.getCharSetEncoding(contentType);
+            String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
             if(charSetEnc == null){
                 charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
             }
-            // Setting the value in msgCtx
             msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
 
-            String soapNS = null;
             if (contentType != null) {
-                if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
-                    soapVersion = VERSION_SOAP12;
-                    soapNS = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-                    processContentTypeForAction(contentType, msgContext);
-                } else if (contentType
-                        .indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
-                    soapVersion = VERSION_SOAP11;
-                    soapNS = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-                } else if (isRESTRequest(contentType)) {
+				if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
+					soapVersion = VERSION_SOAP12;
+					processContentTypeForAction(contentType, msgContext);
+				} else if (contentType
+						.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
+					soapVersion = VERSION_SOAP11;
+				} else if (isRESTRequest(contentType)) {
                     // If REST, construct a SOAP11 envelope to hold the rest message and
                     // indicate that this is a REST message.
                     soapVersion = VERSION_SOAP11; 
-                    soapNS = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                     msgContext.setDoingREST(true);
                 }
-                if (JavaUtils.indexOfIgnoreCase(contentType,
-                        HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
-                    // It is MIME (MTOM or SwA)
-                    isMIME = true;
-                } else if (soapVersion == VERSION_SOAP11) {
-                    // Deployment configuration parameter
-                    Parameter enableREST = msgContext
-                            .getParameter(Constants.Configuration.ENABLE_REST);
-                    if ((soapActionHeader == null) && (enableREST != null)) {
-                        if (Constants.VALUE_TRUE.equals(enableREST.getValue())) {
-                            // If the content Type is text/xml (BTW which is the
-                            // SOAP 1.1 Content type ) and the SOAP Action is
-                            // absent it is rest !!
-                            msgContext.setDoingREST(true);
-                        }
-                    }
-                }
-            }
-            envelope = TransportUtils.createSOAPMessage(msgContext,in,soapNS,isMIME,contentType,charSetEnc);
+				if (soapVersion == VERSION_SOAP11) {
+					// TODO Keith : Do we need this anymore
+					// Deployment configuration parameter
+					Parameter enableREST = msgContext
+							.getParameter(Constants.Configuration.ENABLE_REST);
+					if ((soapActionHeader == null) && (enableREST != null)) {
+						if (Constants.VALUE_TRUE.equals(enableREST.getValue())) {
+							// If the content Type is text/xml (BTW which is the
+							// SOAP 1.1 Content type ) and the SOAP Action is
+							// absent it is rest !!
+							msgContext.setDoingREST(true);
+						}
+					}
+				}
+			}
+            envelope = TransportUtils.createSOAPMessage(msgContext,in,contentType);
             msgContext.setEnvelope(envelope);
             AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());
 

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java Sun Feb 25 22:58:06 2007
@@ -214,6 +214,7 @@
             if (inentity.getContentType() != null) {
                 contenttype = inentity.getContentType().getValue();
             }
+            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE,contenttype);
             InvocationResponse pi = HTTPTransportUtils.processHTTPPostRequest(
                     msgContext,
                     inentity.getContent(),

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/RESTUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/RESTUtil.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/RESTUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/RESTUtil.java Sun Feb 25 22:58:06 2007
@@ -15,6 +15,15 @@
  */
 package org.apache.axis2.transport.http.util;
 
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.zip.GZIPInputStream;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
@@ -23,6 +32,7 @@
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisBindingOperation;
@@ -37,19 +47,10 @@
 import org.apache.axis2.engine.RequestURIOperationDispatcher;
 import org.apache.axis2.engine.SOAPActionBasedDispatcher;
 import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.SchemaUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
 /**
  *
  */
@@ -108,7 +109,7 @@
             msgContext.setEnvelope(soapEnvelope);
             msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD,
                                    org.apache.axis2.transport.http.HTTPConstants.HTTP_METHOD_POST);
-            msgContext.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONTENT_TYPE,
+            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE,
                                    contentType);
             msgContext.setDoingREST(true);
             msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
@@ -267,7 +268,7 @@
             if (checkContentType(
                     org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED,
                     contentType)) {
-                body.addChild(Builder.getAttachmentsBuilder(msgCtxt,
+                body.addChild(BuilderUtil.getAttachmentsBuilder(msgCtxt,
                                                             inputStream,
                                                             contentType,
                                                             false).getDocumentElement());
@@ -278,7 +279,7 @@
                             org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_APPLICATION_XML,
                             contentType)) {
 
-                String charSetEnc = Builder.getCharSetEncoding(contentType);
+                String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
                 if (charSetEnc == null) {
                     // If charset is not specified
                     charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
@@ -288,7 +289,7 @@
 
                 // Create documentElement only if the content length is greator than 0
                 if (request.getContentLength() != 0) {
-                    StAXBuilder builder = Builder.getPOXBuilder(inputStream, charSetEnc, null);
+                    StAXBuilder builder = BuilderUtil.getPOXBuilder(inputStream, charSetEnc);
                     OMNodeEx documentElement = (OMNodeEx) builder.getDocumentElement();
                     documentElement.setParent(null);
                     body.addChild(documentElement);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java Sun Feb 25 22:58:06 2007
@@ -59,6 +59,7 @@
                 response.setHeader("Server",server(msgContext));
             }
             String soapAction = request.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
+            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE,request.getContentType());
             HTTPTransportUtils.processHTTPPostRequest(msgContext,
                                                       request.getInputStream(),
                                                       response.getOutputStream(),

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSUtils.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSUtils.java Sun Feb 25 22:58:06 2007
@@ -15,6 +15,20 @@
 */
 package org.apache.axis2.transport.jms;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.TextMessage;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAP11Constants;
@@ -22,30 +36,17 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.TextMessage;
-import javax.xml.stream.XMLStreamException;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.StringTokenizer;
-
 public class JMSUtils {
 
     private static final Log log = LogFactory.getLog(JMSUtils.class);
@@ -165,7 +166,7 @@
                     return
                         new ByteArrayInputStream(
                             txtMsg.getText().getBytes(
-                            Builder.getCharSetEncoding(contentType)));
+                            BuilderUtil.getCharSetEncoding(contentType)));
                 } else {
                     return
                         new ByteArrayInputStream(txtMsg.getText().getBytes());
@@ -307,13 +308,13 @@
 
         if (contentType != null && contentType.indexOf(
                 HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
-            builder = Builder.getAttachmentsBuilder(
+            builder = BuilderUtil.getAttachmentsBuilder(
                     msgContext, in, contentType, true);
             envelope = (SOAPEnvelope) builder.getDocumentElement();
         } else {
-            String charSetEnc = Builder.getCharSetEncoding(contentType);
-            String soapNS = Builder.getEnvelopeNamespace(contentType);
-            builder = Builder.getSOAPBuilder(in, charSetEnc, soapNS);
+            String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
+            String soapNS = BuilderUtil.getEnvelopeNamespace(contentType);
+            builder = BuilderUtil.getSOAPBuilder(in, charSetEnc);
 
             // Set the encoding scheme in the message context
             msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportReceiver.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/local/LocalTransportReceiver.java Sun Feb 25 22:58:06 2007
@@ -22,13 +22,13 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ContextFactory;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.util.Builder;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.FactoryConfigurationError;
@@ -68,7 +68,7 @@
             msgCtx.setProperty(MessageContext.TRANSPORT_OUT, sender.getResponse());
 
             InputStreamReader streamReader = new InputStreamReader(in);
-            OMXMLParserWrapper builder = Builder.getBuilder(streamReader);
+            OMXMLParserWrapper builder = BuilderUtil.getBuilder(streamReader);
             SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
 
             msgCtx.setEnvelope(envelope);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/Constants.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/Constants.java Sun Feb 25 22:58:06 2007
@@ -71,4 +71,8 @@
     public final static String NOOP = "NOOP";
     public final static String LIST = "LIST";
     public final static String DELE = "DELE";
+
+	public static final String MAIL_SMTP = "_MAIL_SMTP_";
+
+	public static final String MAIL_POP3 = "_MAIL_POP3_";
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailTransportSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailTransportSender.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/MailTransportSender.java Sun Feb 25 22:58:06 2007
@@ -30,7 +30,6 @@
 import org.apache.axis2.handlers.AbstractHandler;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPTransportUtils;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.apache.axis2.util.Utils;
@@ -165,7 +164,7 @@
     }
 
     private void runtimeMailParameterSetting(MessageContext msgContext) {
-        Object obj = msgContext.getProperty(HTTPConstants.MAIL_SMTP);
+        Object obj = msgContext.getProperty(Constants.MAIL_SMTP);
         if (obj != null) {
             // Overide the axis2.xml cofiguration setting
             if (obj instanceof HttpTransportProperties.MailProperties) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java?view=diff&rev=511738&r1=511737&r2=511738
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/mail/SimpleMailListener.java Sun Feb 25 22:58:06 2007
@@ -17,10 +17,23 @@
 
 package org.apache.axis2.transport.mail;
 
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
-import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.mail.Flags;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.URLName;
+import javax.mail.internet.MimeMessage;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
@@ -28,6 +41,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.builder.BuilderUtil;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.ContextFactory;
@@ -38,27 +52,15 @@
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.util.Builder;
 import org.apache.axis2.util.Utils;
 import org.apache.axis2.util.threadpool.DefaultThreadFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.mail.Flags;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Multipart;
-import javax.mail.Part;
-import javax.mail.URLName;
-import javax.mail.internet.MimeMessage;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Properties;
+import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
 
 /**
  * This is the implementation for Mail Listener in Axis2. It has the full capability
@@ -298,10 +300,10 @@
                         String soapNamespaceURI = "";
 
                         /* Set the Charactorset Encoding */
-                        if (Builder.getCharSetEncoding(part.getContentType()) != null) {
+                        if (BuilderUtil.getCharSetEncoding(part.getContentType()) != null) {
                             msgContext.setProperty(
                                     org.apache.axis2.Constants.Configuration.CHARACTER_SET_ENCODING,
-                                    Builder.getCharSetEncoding(
+                                    BuilderUtil.getCharSetEncoding(
                                             part.getContentType()));
                         } else {
                             msgContext.setProperty(
@@ -358,7 +360,7 @@
                         }
 
                         InputStream inputStream = part.getInputStream();
-                        StAXBuilder builder = Builder.getSOAPBuilder(inputStream, soapNamespaceURI);
+                        StAXBuilder builder = BuilderUtil.getSOAPBuilder(inputStream, soapNamespaceURI);
                         SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
                         msgContext.setEnvelope(envelope);
                     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org