/*
 * Portions of this file Copyright 1999-2005 University of Chicago
 * Portions of this file Copyright 1999-2005 The University of Southern California.
 *
 * This file or a portion of this file is licensed under the
 * terms of the Globus Toolkit Public License, found at
 * http://www.globus.org/toolkit/download/license.html.
 * If you redistribute this file, with or without
 * modifications, you must include this notice in the file.
 */

#ifndef _GLOBUS_SOAP_MESSAGE_H_
#define _GLOBUS_SOAP_MESSAGE_H_

#include "globus_common.h"
#include "globus_xio.h"
#include "libxml/xmlreader.h"
#include "libxml/xmlwriter.h"
#include "xsd_QName.h"

#include "globus_soap_message_handle.h"
#include "globus_soap_message_utils.h"
#include "globus_handler.h"

EXTERN_C_BEGIN

extern globus_xsd_type_registry_t       GLOBUS_XSD_BASE_REGISTRY;

/* all services register their types here */
extern globus_xsd_type_registry_t       GLOBUS_GLOBAL_TYPE_REGISTRY;

extern globus_module_descriptor_t       globus_i_soap_message_module;
#define GLOBUS_SOAP_MESSAGE_MODULE      &globus_i_soap_message_module

typedef void (* globus_soap_message_callback_func_t) (
    globus_result_t                     result,
    void *                              args);

typedef enum
{
    GLOBUS_SOAP_MESSAGE_CALLOUT_BEGIN     = 0x01,
    GLOBUS_SOAP_MESSAGE_CALLOUT_END       = 0x02,
    GLOBUS_SOAP_MESSAGE_CALLOUT_ATTR      = 0x03,
    GLOBUS_SOAP_MESSAGE_CALLOUT_NS_SET    = 0x04,
    GLOBUS_SOAP_MESSAGE_CALLOUT_NS_ADD    = 0x05,
    GLOBUS_SOAP_MESSAGE_CALLOUT_NS_REMOVE = 0x06
} globus_soap_message_callout_type_t;

void
globus_soap_message_serialize_start_c14n_subset(
    globus_soap_message_handle_t        handle);

void
globus_soap_message_serialize_end_c14n_subset(
    globus_soap_message_handle_t        handle);

globus_bool_t
globus_soap_message_serialize_is_c14n_subset(
    globus_soap_message_handle_t        handle);

char *
globus_soap_message_serialize_lookup_prefix(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    int *                               created);

char *
globus_soap_message_serialize_lookup_prefix(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    int *                               created);

globus_result_t
globus_soap_message_element_ns_set(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_element_ns_add(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

void
globus_soap_message_element_ns_remove(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_attribute_ns_set(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_attribute_ns_add(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

void
globus_soap_message_attribute_ns_remove(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_subelement_ns_set(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_subelement_ns_add(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

void
globus_soap_message_subelement_ns_remove(
    globus_soap_message_handle_t        handle,
    const char *                        Namespace,
    globus_xsd_element_options_t *      options);

globus_result_t
globus_soap_message_serialize_envelope(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_envelope_end(
    globus_soap_message_handle_t             handle);

globus_result_t
globus_soap_message_deserialize_envelope_end(
    globus_soap_message_handle_t             handle);

globus_result_t
globus_soap_message_serialize_header(
   globus_soap_message_handle_t         handle);

globus_result_t
globus_soap_message_serialize_header_begin_close(
    globus_soap_message_handle_t        message);

globus_result_t
globus_soap_message_serialize_header_end(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_body(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_body_begin_close(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_body_end(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_element(
    globus_soap_message_handle_t        handle,
    xsd_QName *                         element_qname,
    globus_xsd_element_options_t        options,
    xsd_QName *                         type_qname);

/**
 * globus_result_t
 * globus_soap_message_deserialize_element_begin_close(
 *     globus_soap_message_handle_t             handle);
 */
#define globus_soap_message_deserialize_element_begin_close(HANDLE) GLOBUS_SUCCESS

globus_result_t
globus_soap_message_deserialize_element_end(
    globus_soap_message_handle_t        handle,
    xsd_QName *                         element);

globus_result_t
globus_soap_message_serialize_element_content_close(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_element_begin_close(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_serialize_element_end(
    globus_soap_message_handle_t        handle,
    xsd_QName *                         element,
    globus_xsd_element_options_t        options,
    xsd_QName *                         type);

#include "xsd_anyURI.h"
#include "xsd_base64Binary.h"
#include "xsd_boolean.h"
#include "xsd_byte.h"
#include "xsd_date.h"
#include "xsd_dateTime.h"
#include "xsd_decimal.h"
#include "xsd_double.h"
#include "xsd_duration.h"
#include "xsd_float.h"
#include "xsd_hexBinary.h"
#include "xsd_int.h"
#include "xsd_integer.h"
#include "xsd_long.h"
#include "xsd_negativeInteger.h"
#include "xsd_nonNegativeInteger.h"
#include "xsd_nonPositiveInteger.h"
#include "xsd_positiveInteger.h"
#include "xsd_short.h"
#include "xsd_string.h"
#include "xsd_time.h"
#include "xsd_unsignedByte.h"
#include "xsd_unsignedInt.h"
#include "xsd_unsignedLong.h"
#include "xsd_unsignedShort.h"

globus_result_t
globus_soap_message_serialize_string(
    globus_soap_message_handle_t        handle,
    const xsd_string *                  str);

globus_result_t
globus_soap_message_serialize_string_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_string *                  str);

globus_result_t
globus_soap_message_serialize_duration_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_duration *                duration);

globus_result_t
globus_soap_message_serialize_dateTime_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_dateTime *                dt);

globus_result_t
globus_soap_message_serialize_date_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_date *                    dt);

globus_result_t
globus_soap_message_serialize_long_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_long *                    val);

globus_result_t
globus_soap_message_serialize_int_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_int *                     val);

globus_result_t
globus_soap_message_serialize_float_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_float *                   val);

globus_result_t
globus_soap_message_serialize_integer_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_integer *                 val);

globus_result_t
globus_soap_message_serialize_base64Binary_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_base64Binary *            val);

globus_result_t
globus_soap_message_serialize_boolean(
    globus_soap_message_handle_t        handle,
    const xsd_boolean *                 val);

globus_result_t
globus_soap_message_serialize_boolean_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_boolean *                 val);

/**
 * globus_result_t
 * globus_soap_message_serialize_negativeInteger(
 *     globus_soap_message_handle_t        handle,
 *     const xsd_negativeInteger *         val);
 */
#define globus_soap_message_serialize_negativeInteger(HANDLE, VAL) \
     globus_soap_message_serialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_nonNegativeInteger(
 *     globus_soap_message_handle_t        handle,
 *     const xsd_negativeInteger *         val);
 */
#define globus_soap_message_serialize_nonNegativeInteger(HANDLE, VAL) \
     globus_soap_message_serialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_nonPositiveInteger(
 *     globus_soap_message_handle_t        handle,
 *     const xsd_negativeInteger *         val);
 */
#define globus_soap_message_serialize_nonPositiveInteger(HANDLE, VAL) \
     globus_soap_message_serialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_positiiveInteger(
 *     globus_soap_message_handle_t        handle,
 *     const xsd_negativeInteger *         val);
 */
#define globus_soap_message_serialize_positiveInteger(HANDLE, VAL) \
     globus_soap_message_serialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_unsignedByte(
 *      globus_soap_message_handle_t        handle,
 *      const xsd_unsignedByte  *           val);
 */
#define globus_soap_message_serialize_unsignedByte(HANDLE, VAL) \
    globus_soap_message_serialize_byte(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_unsignedLong(
 *      globus_soap_message_handle_t        handle,
 *      const xsd_unsignedLong *            val);
 */
#define globus_soap_message_serialize_unsignedLong(HANDLE, VAL) \
    globus_soap_message_serialize_long(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_serialize_unsignedShort(
 *      globus_soap_message_handle_t        handle,
 *      const xsd_unsignedShort *           val);
 */
#define globus_soap_message_serialize_unsignedShort(HANDLE, VAL) \
    globus_soap_message_serialize_short(HANDLE, VAL)

globus_result_t
globus_soap_message_serialize_hexBinary(
    globus_soap_message_handle_t        handle,
    const xsd_hexBinary *               val);

globus_result_t
globus_soap_message_serialize_base64Binary(
    globus_soap_message_handle_t        handle,
    const xsd_base64Binary *            val);

globus_result_t
globus_soap_message_serialize_byte(
    globus_soap_message_handle_t        handle,
    const xsd_byte *                    val);

globus_result_t
globus_soap_message_serialize_int(
    globus_soap_message_handle_t        handle,
    const xsd_int *                     val);

globus_result_t
globus_soap_message_serialize_unsignedInt(
    globus_soap_message_handle_t        handle,
    const xsd_unsignedInt *             val);

globus_result_t
globus_soap_message_serialize_long(
    globus_soap_message_handle_t        handle,
    const xsd_long *                    val);

globus_result_t
globus_soap_message_serialize_short(
    globus_soap_message_handle_t        handle,
    const xsd_short *                   val);

globus_result_t
globus_soap_message_serialize_integer(
    globus_soap_message_handle_t        handle,
    const xsd_integer *                 val);

globus_result_t
globus_soap_message_serialize_decimal(
    globus_soap_message_handle_t        handle,
    const xsd_decimal *                 val);

globus_result_t
globus_soap_message_serialize_float(
    globus_soap_message_handle_t        handle,
    const xsd_float *                   val);

globus_result_t
globus_soap_message_serialize_double(
    globus_soap_message_handle_t        handle,
    const xsd_double *                  val);

globus_result_t
globus_soap_message_serialize_dateTime(
    globus_soap_message_handle_t        handle,
    const xsd_dateTime *                val);

globus_result_t
globus_soap_message_serialize_date(
    globus_soap_message_handle_t        handle,
    const xsd_date *                    val);

globus_result_t
globus_soap_message_serialize_time(
    globus_soap_message_handle_t        handle,
    const xsd_time *                    val);

globus_result_t
globus_soap_message_serialize_duration(
    globus_soap_message_handle_t        handle,
    const xsd_duration *                val);

globus_result_t
globus_soap_message_serialize_QName(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   val);

globus_result_t
globus_soap_message_serialize_QName_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_name,
    const xsd_QName *                   val);

void
globus_soap_message_deserialize_push_element(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_deserialize_envelope(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_deserialize_header(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_get_soap_header_node(
    globus_soap_message_handle_t        handle,
    void **                             soap_header);

globus_result_t
globus_soap_message_deserialize_header_end(
    globus_soap_message_handle_t             handle);

globus_result_t
globus_soap_message_add_required_header_element(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   qn);

globus_result_t
globus_soap_message_remove_required_header_element(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   qn);

globus_result_t
globus_soap_message_check_required_headers(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_deserialize_body(
    globus_soap_message_handle_t        handle);

/**
 * globus_result_t
 * globus_soap_message_deserialize_body_end(
 *     globus_soap_message_handle_t             handle);
 */
#define globus_soap_message_deserialize_body_end(HANDLE) \
    globus_soap_message_deserialize_element_end(HANDLE, &soap_env_qname)

globus_bool_t
globus_soap_message_deserialize_element_is_empty(
    globus_soap_message_handle_t        handle);

globus_bool_t
globus_soap_message_deserialize_element_is_nil(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_deserialize_element(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   qname);

globus_result_t
globus_soap_message_deserialize_element_unknown(
    globus_soap_message_handle_t        handle,
    xsd_QName *                         qname);

globus_result_t
globus_soap_message_deserialize_skip(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_deserialize_string(
    globus_soap_message_handle_t        handle,
    xsd_string *                        str);

globus_result_t
globus_soap_message_deserialize_string_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_string *                        str);

globus_result_t
globus_soap_message_deserialize_duration_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_duration *                      val);

globus_result_t
globus_soap_message_deserialize_dateTime_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_dateTime *                      val);

globus_result_t
globus_soap_message_deserialize_date_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_date *                          val);

globus_result_t
globus_soap_message_deserialize_long_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_long *                          val);

globus_result_t
globus_soap_message_deserialize_int_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_int *                           val);

globus_result_t
globus_soap_message_deserialize_float_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_float *                         val);

globus_result_t
globus_soap_message_deserialize_integer_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_integer *                       val);

globus_result_t
globus_soap_message_deserialize_base64Binary_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_base64Binary *                  val);

globus_result_t
globus_soap_message_deserialize_boolean(
    globus_soap_message_handle_t        handle,
    xsd_boolean *                       val);

globus_result_t
globus_soap_message_deserialize_boolean_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_boolean *                       val);

globus_result_t
globus_soap_message_deserialize_dateTime(
    globus_soap_message_handle_t        handle,
    xsd_dateTime *                      val);

globus_result_t
globus_soap_message_deserialize_date(
    globus_soap_message_handle_t        handle,
    xsd_date *                          val);

globus_result_t
globus_soap_message_deserialize_time(
    globus_soap_message_handle_t        handle,
    xsd_time *                          val);

globus_result_t
globus_soap_message_deserialize_duration(
    globus_soap_message_handle_t        handle,
    xsd_duration *                      val);

globus_result_t
globus_soap_message_deserialize_float(
    globus_soap_message_handle_t        handle,
    xsd_float *                         val);

globus_result_t
globus_soap_message_deserialize_double(
    globus_soap_message_handle_t        handle,
    xsd_double *                        val);

globus_result_t
globus_soap_message_deserialize_int(
    globus_soap_message_handle_t        handle,
    xsd_int *                           val);

globus_result_t
globus_soap_message_deserialize_long(
    globus_soap_message_handle_t        handle,
    xsd_long *                          val);

/**
 * globus_result_t
 * globus_soap_message_deserialize_short(
 *     globus_soap_message_handle_t        handle,
 *     xsd_short *                         val);
 */
#define globus_soap_message_deserialize_short(HANDLE, VAL) \
    globus_soap_message_deserialize_int(HANDLE, (int *)VAL)

globus_result_t
globus_soap_message_deserialize_decimal(
    globus_soap_message_handle_t        handle,
    xsd_decimal *                       val);

globus_result_t
globus_soap_message_deserialize_integer(
    globus_soap_message_handle_t        handle,
    xsd_integer *                       val);

globus_result_t
globus_soap_message_deserialize_byte(
    globus_soap_message_handle_t        handle,
    xsd_byte *                          val);

/**
 * globus_result_t
 * globus_soap_message_deserialize_negativeInteger(
 *     globus_soap_message_handle_t        handle,
 *     xsd_negativeInteger *               val);
 */
#define globus_soap_message_deserialize_negativeInteger(HANDLE, VAL) \
    globus_soap_message_deserialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_deserialize_nonNegativeInteger(
 *     globus_soap_message_handle_t        handle,
 *     xsd_nonNegativeInteger *            val);
 */
#define globus_soap_message_deserialize_nonNegativeInteger(HANDLE, VAL) \
    globus_soap_message_deserialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_deserialize_nonPositiveInteger(
 *     globus_soap_message_handle_t        handle,
 *     xsd_nonPositiveInteger *            val);
 */
#define globus_soap_message_deserialize_nonPositiveInteger(HANDLE, VAL) \
    globus_soap_message_deserialize_integer(HANDLE, VAL)

/**
 * globus_result_t
 * globus_soap_message_deserialize_positiveInteger(
 *     globus_soap_message_handle_t        handle,
 *     xsd_positiveInteger *               val);
 */
#define globus_soap_message_deserialize_positiveInteger(HANDLE, VAL) \
    globus_soap_message_deserialize_integer(HANDLE, VAL)

globus_result_t
globus_soap_message_deserialize_unsignedByte(
    globus_soap_message_handle_t        handle,
    xsd_unsignedByte *                  val);

globus_result_t
globus_soap_message_deserialize_unsignedLong(
    globus_soap_message_handle_t        handle,
    xsd_unsignedLong *                  val);

globus_result_t
globus_soap_message_deserialize_unsignedInt(
    globus_soap_message_handle_t        handle,
    xsd_unsignedInt *                   val);

globus_result_t
globus_soap_message_deserialize_unsignedShort(
    globus_soap_message_handle_t        handle,
    xsd_unsignedShort *                 val);

globus_result_t
globus_soap_message_deserialize_base64Binary(
    globus_soap_message_handle_t        handle,
    xsd_base64Binary *                  val);

globus_result_t
globus_soap_message_deserialize_hexBinary(
    globus_soap_message_handle_t        handle,
    xsd_hexBinary *                     val);

globus_result_t
globus_soap_message_deserialize_anyURI(
    globus_soap_message_handle_t        handle,
    xsd_anyURI *                        str);

globus_result_t
globus_soap_message_deserialize_QName(
    globus_soap_message_handle_t        handle,
    xsd_QName *                         val);

globus_result_t
globus_soap_message_deserialize_QName_attribute(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_QName *                         val);

globus_result_t
globus_soap_message_serialize_string_list(
    globus_soap_message_handle_t        handle,
    xsd_string_array *                  inst);

globus_result_t
globus_soap_message_deserialize_string_list(
    globus_soap_message_handle_t        handle,
    xsd_string_array *                  inst);

globus_result_t
globus_soap_message_serialize_string_attribute_list(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_string_array *                  val);

globus_result_t
globus_soap_message_deserialize_string_attribute_list(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_string_array *                  val);

globus_result_t
globus_soap_message_serialize_QName_list(
    globus_soap_message_handle_t        handle,
    xsd_QName_array *                   inst);

globus_result_t
globus_soap_message_deserialize_QName_list(
    globus_soap_message_handle_t        handle,
    xsd_QName_array *                   inst);

globus_result_t
globus_soap_message_serialize_QName_attribute_list(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_QName_array *                   inst);

globus_result_t
globus_soap_message_deserialize_QName_attribute_list(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   attr_qname,
    xsd_QName_array *                   inst);

globus_result_t
globus_soap_message_deserialize_mark(
    globus_soap_message_handle_t        handle,
    const char *                        mark);

globus_result_t
globus_soap_message_get_handler_chain(
    globus_soap_message_handle_t        handle,
    globus_handler_chain_t *            chain);

globus_result_t
globus_soap_message_set_handler_chain(
    globus_soap_message_handle_t        handle,
    globus_handler_chain_t              chain);

globus_result_t
globus_soap_message_register_open(
    globus_soap_message_handle_t        handle,
    char *                              endpoint,
    globus_soap_message_callback_func_t callback,
    void *                              args);

globus_result_t
globus_soap_message_register_write_request(
    globus_soap_message_handle_t        handle,
    globus_soap_message_callback_func_t callback,
    void *                              args,
    globus_bool_t                       response);

globus_result_t
globus_soap_message_register_read_request(
    globus_soap_message_handle_t        handle,
    globus_soap_message_callback_func_t callback,
    void *                              args);

globus_result_t
globus_soap_message_register_read_response(
    globus_soap_message_handle_t        handle,
    globus_soap_message_callback_func_t callback,
    void *                              args);

globus_result_t
globus_soap_message_register_write_response(
    globus_soap_message_handle_t        handle,
    globus_soap_message_callback_func_t callback,
    void *                              args);

globus_result_t
globus_soap_message_register_close(
    globus_soap_message_handle_t        handle,
    globus_soap_message_callback_func_t callback,
    void *                              args);

globus_bool_t
globus_soap_message_is_cancelled(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_cancel_message(
    globus_soap_message_handle_t        handle);

globus_result_t
globus_soap_message_setup_writer(
    globus_soap_message_handle_t        message);

globus_result_t
globus_soap_message_get_transport_handle(
    globus_soap_message_handle_t        message,
    globus_xio_handle_t *               handle);

char *
globus_soap_message_construct_id(
    const char *                        prefix);

globus_result_t
globus_soap_message_add_callout(
    globus_soap_message_handle_t        message,
    const xsd_QName *                   type,
    globus_soap_message_callout_func_t  begin_callout,
    globus_soap_message_callout_func_t  end_callout,
    globus_soap_message_callout_func_t  attr_callout);

globus_result_t
globus_soap_message_add_ns_callout(
    globus_soap_message_handle_t        message,
    const xsd_QName *                   type,
    globus_soap_message_callout_ns_func_t ns_set_callout,
    globus_soap_message_callout_ns_func_t ns_add_callout,
    globus_soap_message_callout_ns_func_t ns_remove_callout);

void
globus_soap_message_remove_callouts(
    globus_soap_message_handle_t        message,
    const xsd_QName *                   type);

globus_result_t
globus_soap_message_invoke_callouts(
    globus_soap_message_handle_t       handle,
    const xsd_QName *                  element_qname,
    globus_soap_message_callout_type_t type);

globus_result_t
globus_soap_message_invoke_ns_callouts(
    globus_soap_message_handle_t        handle,
    const xsd_QName *                   element_qname,
    globus_soap_message_callout_type_t  type,
    globus_xsd_element_options_t *      options);

EXTERN_C_END

#endif /* _GLOBUS_SOAP_MESSAGE_H_ */
