Index: modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2MessageBuilder.java
===================================================================
--- modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2MessageBuilder.java	(revision 0)
+++ modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2MessageBuilder.java	(revision 0)
@@ -0,0 +1,120 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.synapse.format.as2;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.builder.Builder;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.*;
+
+/**
+ * Enables a message encoded using the AS2 specification to be received by synapse
+ */
+public class AS2MessageBuilder implements Builder {
+
+    private static final Log log = LogFactory.getLog(AS2MessageBuilder.class);
+
+    /**
+     * Returns an OMElement from a AS2 message
+     *
+     * @param inputStream    stream containing the AS2 message to be built
+     * @param contentType    content type of the message
+     * @param messageContext message to which the as2 message has to be attached
+     * @return OMElement containing the AS2 message
+     * @throws org.apache.axis2.AxisFault in case of a failure in building the as2 message
+     */
+    public OMElement processDocument(final InputStream inputStream, final String contentType,
+                                     final MessageContext messageContext) throws AxisFault {
+
+        if (log.isDebugEnabled()) {
+            log.debug("Start building the as2 message");
+        }
+
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+        SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
+
+        OMElement element = null;
+        if (contentType.equalsIgnoreCase(AS2Constants.AS2_CONTENT_EDI_OTHER)) {
+            element = processEdiOther(inputStream);
+        }
+        if (element != null) {
+            SOAPBody body = soapEnvelope.getBody();
+            body.addChild(element);
+        }
+
+        return soapEnvelope;
+    }
+
+    /**
+     * Returns am OMElements given an input stream for edi-consent
+     *
+     * @param inputStream stream that has the contents of the MIME attachment
+     * @return OMElement containing the attachment contents
+     * @throws org.apache.axis2.AxisFault in case of a failure
+     */
+    private OMElement processEdiOther(InputStream inputStream) throws AxisFault {
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+
+        OMElement element = factory.createOMElement(
+                AS2Constants.AS2_ELEMENT_LOCAL_NAME, null);
+
+        if (inputStream != null) {
+            try {
+                PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
+                int b;
+                StringBuilder sb = new StringBuilder();
+                if ((b = pushbackInputStream.read()) > 0) {
+                    pushbackInputStream.unread(b);
+                    BufferedReader in = new BufferedReader(new InputStreamReader(
+                            pushbackInputStream));
+
+                    String inputLine;
+                    while ((inputLine = in.readLine()) != null) {
+                        sb.append(inputLine);
+                    }
+                    in.close();
+                    if (log.isDebugEnabled()) {
+                        log.debug("Building the as2 message is successful");
+                    }
+
+                    element.setText(sb.toString());
+                }
+
+            } catch (IOException e) {
+                log.error("Building the as2 message failed");
+                throw AxisFault.makeFault(e);
+            }
+        } else {
+            log.error("Building the as2 message failed: input stream is null");
+        }
+        return element;
+    }
+
+}
Index: modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2Constants.java
===================================================================
--- modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2Constants.java	(revision 0)
+++ modules/extensions/src/main/java/org/apache/synapse/format/as2/AS2Constants.java	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.synapse.format.as2;
+
+/**
+ * Constants related to AS2 message builder and formatter pair
+ */
+public final class AS2Constants {
+
+    /** AS2 element local name inside the SOAP payload */
+    public static final String AS2_ELEMENT_LOCAL_NAME = "as2Message";
+
+    /** AS2 content types */
+    public static final String AS2_CONTENT_EDI_OTHER = "application/edi-consent";
+    public static final String AS2_CONTENT_EDIFACT = "application/EDIFACT";
+    public static final String AS2_CONTENT_MULTIPART = "multipart/signed";
+    public static final String AS2_CONTENT_CMS = "application/PKCS7-mime";
+
+}
