Index: /pjproject/trunk/pjsip/include/pjsip/sip_msg.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsip/sip_msg.h	(revision 265)
+++ /pjproject/trunk/pjsip/include/pjsip/sip_msg.h	(revision 266)
@@ -611,8 +611,40 @@
  * @return		PJ_SUCCESS on success.
  */
-PJ_DECL(pj_status_t) pjsip_msg_body_clone(pj_pool_t *pool,
+PJ_DECL(pj_status_t) pjsip_msg_body_copy( pj_pool_t *pool,
 					  pjsip_msg_body *dst_body,
 					  const pjsip_msg_body *src_body );
 					   
+
+/**
+ * Create cloned message body. This will duplicate the contents of the message
+ * body using the \a clone_data member of the source message body.
+ *
+ * @param pool		Pool to use to duplicate the message body.
+ * @param body		Source message body to duplicate.
+ *
+ * @return		The cloned message body on successfull.
+ */
+PJ_DECL(pjsip_msg_body*) pjsip_msg_body_clone( pj_pool_t *pool,
+					       const pjsip_msg_body *body );
+					   
+
+/**
+ * Create a text message body. Use this function to create message body when
+ * the content is a simple text. For non-text message body (e.g. 
+ * pjmedia_sdp_session or pj_xml_node), application must construct the message
+ * manually.
+ *
+ * @param pool		Pool to allocate message body and its contents.
+ * @param type		MIME type (e.g. "text").
+ * @param subtype	MIME subtype (e.g. "plain").
+ * @param text		The text content to be put in the message body.
+ *
+ * @return		A new message body with the specified Content-Type and
+ *			text.
+ */
+PJ_DECL(pjsip_msg_body*) pjsip_msg_body_create( pj_pool_t *pool,
+					        const pj_str_t *type,
+						const pj_str_t *subtype,
+						const pj_str_t *text );
 
 /**
Index: /pjproject/trunk/pjsip/src/pjsip/sip_msg.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 265)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_msg.c	(revision 266)
@@ -1759,7 +1759,7 @@
 }
 
-PJ_DEF(pj_status_t) pjsip_msg_body_clone( pj_pool_t *pool,
-					  pjsip_msg_body *dst_body,
-					  const pjsip_msg_body *src_body )
+PJ_DEF(pj_status_t) pjsip_msg_body_copy( pj_pool_t *pool,
+					 pjsip_msg_body *dst_body,
+					 const pjsip_msg_body *src_body )
 {
     /* First check if clone_data field is initialized. */
@@ -1788,2 +1788,44 @@
 }
 
+
+PJ_DEF(pjsip_msg_body*) pjsip_msg_body_clone( pj_pool_t *pool,
+					      const pjsip_msg_body *body )
+{
+    pjsip_msg_body *new_body;
+    pj_status_t status;
+
+    new_body = pj_pool_alloc(pool, sizeof(pjsip_msg_body));
+    PJ_ASSERT_RETURN(new_body, NULL);
+
+    status = pjsip_msg_body_copy(pool, new_body, body);
+
+    return (status==PJ_SUCCESS) ? new_body : NULL;
+}
+
+
+PJ_DEF(pjsip_msg_body*) pjsip_msg_body_create( pj_pool_t *pool,
+					       const pj_str_t *type,
+					       const pj_str_t *subtype,
+					       const pj_str_t *text )
+{
+    pjsip_msg_body *body;
+
+    PJ_ASSERT_RETURN(pool && type && subtype && text, NULL);
+
+    body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body));
+    PJ_ASSERT_RETURN(body != NULL, NULL);
+
+    pj_strdup(pool, &body->content_type.type, type);
+    pj_strdup(pool, &body->content_type.subtype, subtype);
+    body->content_type.param.slen = 0;
+
+    body->data = pj_pool_alloc(pool, text->slen);
+    pj_memcpy(body->data, text->ptr, text->slen);
+    body->len = text->slen;
+
+    body->clone_data = &pjsip_clone_text_data;
+    body->print_body = &pjsip_print_text_body;
+
+    return body;
+}
+
Index: /pjproject/trunk/pjsip/src/pjsip/sip_util.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsip/sip_util.c	(revision 265)
+++ /pjproject/trunk/pjsip/src/pjsip/sip_util.c	(revision 266)
@@ -1236,7 +1236,6 @@
     /* Add the message body, if any. */
     if (body) {
-	tdata->msg->body = pj_pool_alloc(tdata->pool, sizeof(pjsip_msg_body));
-	status = pjsip_msg_body_clone( tdata->pool, tdata->msg->body, body );
-	if (status != PJ_SUCCESS) {
+	tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body );
+	if (tdata->msg->body == NULL) {
 	    pjsip_tx_data_dec_ref(tdata);
 	    return status;
@@ -1296,7 +1295,6 @@
     /* Add the message body, if any. */
     if (body) {
-	tdata->msg->body = pj_pool_alloc(tdata->pool, sizeof(pjsip_msg_body));
-	status = pjsip_msg_body_clone( tdata->pool, tdata->msg->body, body );
-	if (status != PJ_SUCCESS) {
+	tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body );
+	if (tdata->msg->body == NULL) {
 	    pjsip_tx_data_dec_ref(tdata);
 	    return status;
@@ -1318,5 +1316,5 @@
     if (status != PJ_SUCCESS) {
 	pjsip_tx_data_dec_ref(tdata);
-    } else {
+    } else if (p_tsx) {
 	*p_tsx = tsx;
     }
