You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/12/28 03:30:02 UTC

svn commit: r359350 - in /webservices/axis2/trunk/c: include/axis2_soap_envelope.h modules/xml/soap/src/Makefile.am modules/xml/soap/src/soap_envelope.c

Author: samisa
Date: Tue Dec 27 18:29:54 2005
New Revision: 359350

URL: http://svn.apache.org/viewcvs?rev=359350&view=rev
Log:
Added implementation for SOAP envelope

Added:
    webservices/axis2/trunk/c/modules/xml/soap/src/soap_envelope.c
Modified:
    webservices/axis2/trunk/c/include/axis2_soap_envelope.h
    webservices/axis2/trunk/c/modules/xml/soap/src/Makefile.am

Modified: webservices/axis2/trunk/c/include/axis2_soap_envelope.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_soap_envelope.h?rev=359350&r1=359349&r2=359350&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_soap_envelope.h (original)
+++ webservices/axis2/trunk/c/include/axis2_soap_envelope.h Tue Dec 27 18:29:54 2005
@@ -37,6 +37,7 @@
     
     struct axis2_soap_body;
     struct axis2_soap_header;
+    struct axis2_soap_header_block;
     
 /**
  * @defgroup axis2_soap_envelope
@@ -50,43 +51,63 @@
  */
  AXIS2_DECLARE_DATA   struct axis2_soap_envelope_ops
     {
-      /**
-        * Free an axis2_soap_envelope
-        * @param  body pointer to soap_envelope struct
-        * @param  env Environment. MUST NOT be NULL
-        * @return satus of the op. AXIS2_SUCCESS on success 
-        *         else AXIS2_FAILURE
-        */
+        /**
+         * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+         * SOAPEnvelope</CODE> object. <P> This SOAPHeader will just be a container
+         * for all the headers in the <CODE>OMMessage</CODE> </P>
+         *
+         * @return the <CODE>SOAPHeader</CODE> object or <CODE> null</CODE> if there
+         *         is none
+         * @throws org.apache.axis2.om.OMException
+         *                     if there is a problem obtaining
+         *                     the <CODE>SOAPHeader</CODE>
+         *                     object
+         * @throws OMException
+         */
+        struct axis2_soap_header* (AXIS2_CALL *get_header)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env);
+        /**
+         * Convenience method to add a SOAP header to this envelope
+         *
+         * @param namespaceURI
+         * @param name
+         */
+        struct axis2_soap_header_block* (AXIS2_CALL *add_header)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env,
+            axis2_char_t *namespace_uri, 
+            axis2_char_t *name);
+        /**
+         * Returns the <CODE>SOAPBody</CODE> object associated with this
+         * <CODE>SOAPEnvelope</CODE> object. <P> This SOAPBody will just be a
+         * container for all the BodyElements in the <CODE>OMMessage</CODE> </P>
+         *
+         * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+         *         SOAPEnvelope</CODE> object or <CODE>null</CODE> if there is none
+         * @throws org.apache.axis2.om.OMException
+         *                     if there is a problem obtaining
+         *                     the <CODE>SOAPBody</CODE> object
+         * @throws OMException
+         */
+        struct axis2_soap_body* (AXIS2_CALL *get_body)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env);
+        axis2_status_t (AXIS2_CALL *serialize)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env,
+            axis2_om_output_t *om_output, 
+            axis2_bool_t cache);
+        axis2_status_t (AXIS2_CALL *free)(axis2_soap_envelope_t *envelope,
+                               axis2_env_t **env);
+        axis2_om_node_t* (AXIS2_CALL *get_base)(axis2_soap_envelope_t *envelope,
+                                        axis2_env_t **env);
+        int (AXIS2_CALL *get_soap_version)(axis2_soap_envelope_t *envelope,
+                                           axis2_env_t **env);
+        axis2_status_t (AXIS2_CALL *set_soap_version)(axis2_soap_envelope_t *envelope,
+                                           axis2_env_t **env,
+                                           int soap_version);
+        axis2_status_t (AXIS2_CALL *set_body)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env, struct axis2_soap_body *body);
+        axis2_status_t (AXIS2_CALL *set_header)(axis2_soap_envelope_t *envelope,
+            axis2_env_t **env, struct axis2_soap_header *header);
 
-        axis2_status_t (AXIS2_CALL *free_fn)(axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env);
-       /**
-        *
-        * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
-        * SOAPEnvelope</CODE> object. <P> This SOAPHeader will just be a container
-        * for all the headers in the <CODE>OMMessage</CODE> </P> 
-        */
-        struct axis2_soap_header* (AXIS2_CALL *get_header)
-                                            (axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env);
-                                             
-        struct axis2_soap_header* (AXIS2_CALL *add_header_block)
-                                            (axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env,
-                                             axis2_char_t *localname,
-                                             axis2_om_namespace_t* ns);
-                                             
-        struct axis2_soap_body* (AXIS2_CALL *get_body)
-                                            (axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env);
-                                             
-        axis2_om_node_t* (AXIS2_CALL *get_base_node)
-                                            (axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env);
-        
-        axis2_status_t (AXIS2_CALL *set_base_node)
-                                            (axis2_soap_envelope_t *envelope,
-                                             axis2_env_t **env);
     };
 
   /**
@@ -104,34 +125,21 @@
     * creates a soap body struct 
     * @param env Environment. MUST NOT be NULL
     */
-AXIS2_DECLARE(axis2_soap_envelope_t *)
-axis2_soap_envelope_create (axis2_env_t **env);
-
-AXIS2_DECLARE(axis2_soap_envelope_t *)
-axis2_soap_envelope_create_with_namespace(axis2_env_t **env,
-                           axis2_om_namespace_t* ns);
+AXIS2_DECLARE(axis2_soap_envelope_t*)
+axis2_soap_envelope_create(axis2_env_t **env, axis2_om_namespace_t *ns);
                            
 /******************** Macros **************************************************/
-    
-    
-/** free soap_envelope */
-#define AXIS2_SOAP_ENVELOPE_FREE(envelope , env) \
-        ((envelope)->ops->free_fn(envelope, env))
-
-#define AXIS2_SOAP_ENVELOPE_GET_HEADDER(envelope , env) \
-        ((envelope)->ops->get_headder(envelope, env))
-
-#define AXIS2_SOAP_ENVELOPE_ADD_HEADDER_BLOCK(envelope , env, localname, ns) \
-        ((envelope)->ops->add_headder_block(envelope, env, localname, ns))
-
-#define AXIS2_SOAP_ENVELOPE_GET_BOBY(envelope , env) \
-        ((envelope)->ops->get_body(envelope, env))
-
-#define AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(envelope , env) \
-        ((envelope)->ops->get_base_node(envelope, env))
 
-#define AXIS2_SOAP_ENVELOPE_SET_BASE_NODE(envelope , env) \
-        ((envelope)->ops->set_base_node(envelope, env))                                
+#define AXIS2_SOAP_ENVELOPE_GET_HEADDER(envelope, env) ((envelope)->ops->get_header(envelope, env))
+#define AXIS2_SOAP_ENVELOPE_ADD_HEADER(envelope, env, namespace_uri, name) ((envelope)->ops->add_header(envelope, env, namespace_uri, name))
+#define AXIS2_SOAP_ENVELOPE_GET_BOBY(envelope, env) ((envelope)->ops->get_body(envelope, env))
+#define AXIS2_SOAP_ENVELOPE_SERIALIZE(envelope, env, om_output, cache) ((envelope)->ops->serialize(envelope, env, om_output, cache))
+#define AXIS2_SOAP_ENVELOPE_FREE(envelope, env) ((envelope)->ops->free(envelope, env))
+#define AXIS2_SOAP_ENVELOPE_GET_BASE(envelope, env) ((envelope)->ops->get_base(envelope, env))
+#define AXIS2_SOAP_ENVELOPE_GET_SOAP_VERSION(envelope, env) ((envelope)->ops->get_soap_version(envelope, env))
+#define AXIS2_SOAP_ENVELOPE_SET_SOAP_VERSION(envelope, env, soap_version) ((envelope)->ops->set_soap_version(envelope, env, soap_version))
+#define AXIS2_SOAP_ENVELOPE_SET_BODY(envelope, env, body) ((envelope)->ops->set_body(envelope, env, body))
+#define AXIS2_SOAP_ENVELOPE_SET_HEADER(envelope, env, header) ((envelope)->ops->set_header(envelope, env, header))
 
 /** @} */
 

Modified: webservices/axis2/trunk/c/modules/xml/soap/src/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/src/Makefile.am?rev=359350&r1=359349&r2=359350&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/src/Makefile.am Tue Dec 27 18:29:54 2005
@@ -12,7 +12,8 @@
                             axis2_soap_header_block.c \
                             axis2_soap_header.c \
                             axis2_soap_utils.c \
-                            soap_body.c
+                            soap_body.c \
+                            soap_envelope.c
 
 libaxis2_soap_la_LIBADD = 
 INCLUDES = -I$(top_builddir)/include -I$(top_builddir)/modules/xml/parser -I$(top_builddir)/modules/util/src 

Added: webservices/axis2/trunk/c/modules/xml/soap/src/soap_envelope.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/src/soap_envelope.c?rev=359350&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/src/soap_envelope.c (added)
+++ webservices/axis2/trunk/c/modules/xml/soap/src/soap_envelope.c Tue Dec 27 18:29:54 2005
@@ -0,0 +1,331 @@
+/*
+ * 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.
+ */
+ 
+ #include <axis2_soap_envelope.h>
+ #include <axis2_soap_body.h>
+ #include <axis2_soap_header.h>
+ #include <axis2_hash.h>
+ #include <axis2_soap.h>
+ 
+ /******************* impl struct *********************************************/
+ 
+ typedef struct axis2_soap_envelope_impl_t
+ {
+    axis2_soap_envelope_t soap_envelope;
+    
+    axis2_om_node_t *base;
+    
+    int soap_version;
+    
+    axis2_soap_header_t *header;
+     
+    axis2_soap_body_t *body;
+    
+ }axis2_soap_envelope_impl_t;
+ 
+ /****************** Macro ****************************************************/
+ 
+ #define AXIS2_INTF_TO_IMPL(envelope) ((axis2_soap_envelope_impl_t*)envelope)
+ 
+ /****************** Function prototypes **************************************/
+
+axis2_soap_header_t* AXIS2_CALL axis2_soap_envelope_get_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env);
+axis2_soap_header_block_t* AXIS2_CALL axis2_soap_envelope_add_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env,
+    axis2_char_t *namespace_uri, 
+    axis2_char_t *name);
+axis2_soap_body_t* AXIS2_CALL axis2_soap_envelope_get_body(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env);
+axis2_status_t AXIS2_CALL axis2_soap_envelope_serialize(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env,
+    axis2_om_output_t *om_output, 
+    axis2_bool_t cache);
+axis2_status_t AXIS2_CALL
+axis2_soap_envelope_free(axis2_soap_envelope_t *envelope,
+                       axis2_env_t **env);
+axis2_om_node_t* AXIS2_CALL 
+axis2_soap_envelope_get_base(axis2_soap_envelope_t *envelope,
+                                axis2_env_t **env);
+int AXIS2_CALL 
+axis2_soap_envelope_get_soap_version(axis2_soap_envelope_t *envelope,
+                                   axis2_env_t **env);
+axis2_status_t AXIS2_CALL 
+axis2_soap_envelope_set_soap_version(axis2_soap_envelope_t *envelope,
+                                   axis2_env_t **env,
+                                   int soap_version);
+axis2_status_t AXIS2_CALL axis2_soap_envelope_set_body(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env, axis2_soap_body_t *body);
+axis2_status_t AXIS2_CALL axis2_soap_envelope_set_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env, axis2_soap_header_t *header);
+
+                                   
+/*************** function implementations *************************************/
+
+axis2_soap_envelope_t* AXIS2_CALL
+axis2_soap_envelope_create(axis2_env_t **env, axis2_om_namespace_t *ns)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    axis2_om_element_t *ele = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+    envelope_impl = (axis2_soap_envelope_impl_t*)AXIS2_MALLOC(
+                    (*env)->allocator,
+                    sizeof(axis2_soap_envelope_impl_t));
+    if(!envelope_impl)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+    envelope_impl->soap_envelope.ops = NULL;
+    envelope_impl->base = NULL;
+    envelope_impl->soap_version = AXIS2_SOAP12;    
+    envelope_impl->header = NULL;
+    envelope_impl->body = NULL;
+    
+    ele = axis2_om_element_create(env, NULL, AXIS2_SOAP_ENVELOPE_LOCAL_NAME, ns, &(envelope_impl->base));
+    if (!ele)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        axis2_soap_envelope_free(&(envelope_impl->soap_envelope), env);
+        return NULL;
+    }
+    
+    envelope_impl->soap_envelope.ops  = AXIS2_MALLOC( (*env)->allocator, sizeof(axis2_soap_envelope_ops_t) );
+    if (!envelope_impl->soap_envelope.ops)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        axis2_soap_envelope_free(&(envelope_impl->soap_envelope), env);
+        return NULL;        
+    }
+    
+    envelope_impl->soap_envelope.ops->get_header = axis2_soap_envelope_get_header;
+    envelope_impl->soap_envelope.ops->add_header = axis2_soap_envelope_add_header;
+    envelope_impl->soap_envelope.ops->get_body = axis2_soap_envelope_get_body;
+    envelope_impl->soap_envelope.ops->serialize = axis2_soap_envelope_serialize;    
+    envelope_impl->soap_envelope.ops->free = axis2_soap_envelope_free;
+    envelope_impl->soap_envelope.ops->get_base = axis2_soap_envelope_get_base;
+    envelope_impl->soap_envelope.ops->get_soap_version = axis2_soap_envelope_get_soap_version;
+    envelope_impl->soap_envelope.ops->set_soap_version = axis2_soap_envelope_set_soap_version;
+    
+    return &(envelope_impl->soap_envelope);        
+}
+
+axis2_status_t AXIS2_CALL
+axis2_soap_envelope_free(axis2_soap_envelope_t *envelope,
+                       axis2_env_t **env)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    if(envelope->ops)
+    {
+        AXIS2_FREE((*env)->allocator, envelope->ops);
+        envelope->ops = NULL;
+    }
+    
+    if(envelope_impl->base)
+    {
+        AXIS2_OM_NODE_FREE_TREE(envelope_impl->base, env);
+        envelope_impl->base = NULL;
+    }
+    
+    AXIS2_FREE((*env)->allocator, envelope_impl);
+    envelope_impl = NULL;
+    return AXIS2_SUCCESS;
+}
+    
+axis2_om_node_t* AXIS2_CALL 
+axis2_soap_envelope_get_base(axis2_soap_envelope_t *envelope,
+                                axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    return AXIS2_INTF_TO_IMPL(envelope)->base;
+}
+                                             
+int AXIS2_CALL 
+axis2_soap_envelope_get_soap_version(axis2_soap_envelope_t *envelope,
+                                   axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    return AXIS2_INTF_TO_IMPL(envelope)->soap_version;    
+}
+                                             
+axis2_status_t AXIS2_CALL 
+axis2_soap_envelope_set_soap_version(axis2_soap_envelope_t *envelope,
+                                   axis2_env_t **env,
+                                   int soap_version)
+{
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(envelope)->soap_version = soap_version;
+    return AXIS2_SUCCESS;
+}
+
+/**
+ * Returns the <CODE>SOAPHeader</CODE> object for this <CODE>
+ * SOAPEnvelope</CODE> object. <P> This SOAPHeader will just be a container
+ * for all the headers in the <CODE>OMMessage</CODE> </P>
+ *
+ * @return the <CODE>SOAPHeader</CODE> object or <CODE> null</CODE> if there
+ *         is none
+ * @throws org.apache.axis2.om.OMException
+ *                     if there is a problem obtaining
+ *                     the <CODE>SOAPHeader</CODE>
+ *                     object
+ * @throws OMException
+ */
+axis2_soap_header_t* AXIS2_CALL axis2_soap_envelope_get_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    /* TODO axis2_soap_header_t *header =
+            (SOAPHeader)getFirstChildWithName(
+                    new QName(SOAPConstants.HEADER_LOCAL_NAME));
+    if (builder == null && header == null) {
+        header = factory.createSOAPHeader(this);
+        addChild(header);
+    }
+    */
+    return envelope_impl->header;
+}
+
+/**
+ * Convenience method to add a SOAP header to this envelope
+ *
+ * @param namespaceURI
+ * @param name
+ */
+axis2_soap_header_block_t* AXIS2_CALL axis2_soap_envelope_add_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env,
+    axis2_char_t *namespace_uri, 
+    axis2_char_t *name)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    axis2_om_namespace_t *ns = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    /* TODO : cache SOAP header and envelope instead of looking them up?*/
+
+    if (namespace_uri)
+    {
+        ns = axis2_om_namespace_create(env, namespace_uri, NULL);
+    }
+    
+    return axis2_soap_header_block_create_with_parent(env, name, ns, envelope_impl->header);
+}
+
+/**
+ * Returns the <CODE>SOAPBody</CODE> object associated with this
+ * <CODE>SOAPEnvelope</CODE> object. <P> This SOAPBody will just be a
+ * container for all the BodyElements in the <CODE>OMMessage</CODE> </P>
+ *
+ * @return the <CODE>SOAPBody</CODE> object for this <CODE>
+ *         SOAPEnvelope</CODE> object or <CODE>null</CODE> if there is none
+ * @throws org.apache.axis2.om.OMException
+ *                     if there is a problem obtaining
+ *                     the <CODE>SOAPBody</CODE> object
+ * @throws OMException
+ */
+axis2_soap_body_t* AXIS2_CALL axis2_soap_envelope_get_body(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    /* TODO //check for the first element
+    OMElement element = getFirstElement();
+    if (element != null) {
+        if (SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
+            return (SOAPBody) element;
+        } else {      // if not second element SHOULD be the envelope
+            OMNode node = element.getNextOMSibling();
+            while (node != null && node.getType() != OMNode.ELEMENT_NODE) {
+                node = node.getNextOMSibling();
+            }
+            element = (OMElement) node;
+
+            if (node != null &&
+                    SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
+                return (SOAPBody) element;
+            } else {
+                throw new OMException("SOAPEnvelope must contain a envelope element which is either first or second child element of the SOAPEnvelope.");
+            }
+        }
+    }*/
+    return envelope_impl->body;
+}
+
+axis2_status_t AXIS2_CALL axis2_soap_envelope_serialize(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env,
+    axis2_om_output_t *om_output, 
+    axis2_bool_t cache)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+
+    /* TODO
+    if (!omOutput.isIgnoreXMLDeclaration()) {
+        axis2_char_t *charSetEncoding = omOutput.getCharSetEncoding();
+        axis2_char_t *xmlVersion = omOutput.getXmlVersion();
+        omOutput.getXmlStreamWriter().writeStartDocument(charSetEncoding == null ?
+                OMConstants.DEFAULT_CHAR_SET_ENCODING : charSetEncoding,
+                xmlVersion == null ? OMConstants.DEFAULT_XML_VERSION : xmlVersion);
+    }*/
+    return AXIS2_OM_NODE_SERIALIZE(envelope_impl->base, env, om_output);
+}
+
+axis2_status_t AXIS2_CALL axis2_soap_envelope_set_body(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env, axis2_soap_body_t *body)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    if (!(envelope_impl->body))
+    {
+        envelope_impl->body = body;
+    }
+    else
+    {
+        /* TODO set an error here as there can be only one body */
+    }
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL axis2_soap_envelope_set_header(axis2_soap_envelope_t *envelope,
+    axis2_env_t **env, axis2_soap_header_t *header)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(envelope, env, AXIS2_FAILURE);
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    if (!(envelope_impl->header))
+    {
+        envelope_impl->header = header;
+    }
+    else
+    {
+        /* TODO set an error here as there can be only one header */
+    }
+    return AXIS2_SUCCESS;
+}