Example #1
0
//-----------------------------------------------------------------------------
// Reads a binary image from the file fp.
// The file should be composed of HTTP mime messages as received in the form of
// an HTTP response. fp is already positioned at the start of the image.
// The boundary is given by boundId.
//
char * rp_read_bin_mime_image(
    const axutil_env_t * env,
    FILE *fp,
    const char *boundId,
    int *len)
{
    char     *image_binary   = NULL;

    int      actual_filled   = 0;

    TmpStore             *ts = NULL;
    axutil_linked_list_t *ll = axutil_linked_list_create(env);

    *len = 0;

    Rp_cb_ctx fill_ctx;
    init_rp_cb_ctx(env, &fill_ctx);
    fill_ctx.fp    = fp;
    fill_ctx.bound = boundId;

    while (!fill_ctx.done)
    {
        ts = (TmpStore *)AXIS2_MALLOC(env->allocator, sizeof(TmpStore));
        actual_filled = rp_fill_buff_CB(ts->buf, SP_IMG_BUF_SIZE, &fill_ctx);
        if (0 == actual_filled)
        {
            AXIS2_FREE(env->allocator, ts);
            break;
        }
        ts->size = actual_filled;
        *len    += actual_filled;
        axutil_linked_list_add (ll, env, (void *)ts);
    }

    image_binary = compose_buffer(env, *len, ll);
    axutil_linked_list_free(ll, env);
    return image_binary;
}
Example #2
0
/* build SOAP request message content using OM (for java interop)*/
axiom_node_t *
build_om_payload_for_echo_svc_interop(
    const axutil_env_t *env)
{
    axiom_node_t *ping_request_om_node = NULL;
    axiom_element_t* ping_request_om_ele = NULL;
    axiom_node_t *ping_om_node = NULL;
    axiom_element_t* ping_om_ele = NULL;
    axiom_node_t* text_om_node = NULL;
    axiom_element_t * text_om_ele = NULL;
    axiom_namespace_t *ns1 = NULL;
    axiom_namespace_t *ns0 = NULL;
    axis2_char_t *om_str = NULL;

    ns0 = axiom_namespace_create(env, "http://InteropBaseAddress/interop", "ns0");
    ns1 = axiom_namespace_create(env, "http://xmlsoap.org/Ping", "ns1");
    ping_request_om_ele
        = axiom_element_create(env, NULL, "PingRequest", ns0, &ping_request_om_node);
    ping_om_ele = axiom_element_create(env, ping_request_om_node, "Ping", ns1, &ping_om_node);

    text_om_ele = axiom_element_create(env, ping_om_node, "scenario", ns1, &text_om_node);
    axiom_element_set_text(text_om_ele, env, "scenario", text_om_node);
    text_om_node = NULL;
    text_om_ele = axiom_element_create(env, ping_om_node, "origin", ns1, &text_om_node);
    axiom_element_set_text(text_om_ele, env, "origin", text_om_node);
    text_om_node = NULL;
    text_om_ele = axiom_element_create(env, ping_om_node, "text", ns1, &text_om_node);
    axiom_element_set_text(text_om_ele, env, "text", text_om_node);

    om_str = axiom_node_to_string(ping_request_om_node, env);
    if(om_str)
    {
        printf("\nSending OM : %s\n", om_str);
        AXIS2_FREE(env->allocator, om_str);
        om_str = NULL;
    }
    return ping_request_om_node;
}
Example #3
0
int AXIS2_CALL
axutil_stream_write_basic(
    axutil_stream_t *stream,
    const axutil_env_t *env,
    const void *buffer,
    size_t count)
{
    int new_len = 0;

    if(!buffer)
        return -1;

    new_len = (int)(stream->len + count);
    /* We are sure that the difference lies within the int range */
    if(new_len > stream->max_len)
    {
        axis2_char_t *tmp = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t)
            * (new_len + AXIS2_STREAM_DEFAULT_BUF_SIZE));
        if(!tmp)
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
            return -1;
        }
        /*
         * pre allocation: extra AXIS2_STREAM_DEFAULT_BUF_SIZE more bytes 
         * allocated 
         */
        stream->max_len = new_len + AXIS2_STREAM_DEFAULT_BUF_SIZE;
        memcpy(tmp, stream->buffer, sizeof(axis2_char_t) * stream->len);
        AXIS2_FREE(env->allocator, stream->buffer_head);
        stream->buffer = tmp;
        stream->buffer_head = tmp;
    }
    memcpy(stream->buffer + (stream->len * sizeof(axis2_char_t)), buffer, count);
    stream->len += (int)count;
    /* We are sure that the difference lies within the int range */
    return (int)count;
}
Example #4
0
void AXIS2_CALL
service_admin_counter_set_last_count (
    const axutil_env_t *env,
    axis2_msg_ctx_t *msg_ctx,
    axis2_char_t *svc_name,
    axis2_char_t *op_name,
    int last_count)
{
    int *count = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axutil_property_t *property = NULL;
    axutil_hash_t *last_counts = NULL;
   
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    if(svc_name && op_name)
    {
        axis2_char_t *key = NULL;
        key = axutil_strcat(env, svc_name, "-", op_name, NULL);
        property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT);
        /* set_last_count is always called after get_last_count. So checking for existence of property
         * is not necessary here 
         */
        last_counts = axutil_property_get_value(property, env);
        count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING);
        *count = last_count;
        AXIS2_FREE(env->allocator, key);
    }
    else if(svc_name)
    {
        property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); 
        /* set_last_count is always called after get_last_count. So checking for existence of property
         * is not necessary here 
         */
        last_counts = axutil_property_get_value(property, env);
        count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING);
        *count = last_count;
    }
}
Example #5
0
/* build SOAP request message content using OM */
axiom_node_t *
build_om_programatically(
    const axutil_env_t * env)
{
    axiom_node_t *notify_om_node = NULL;
    axiom_element_t *notify_om_ele = NULL;
    axiom_namespace_t *ns1 = NULL;
    axis2_char_t *buffer = NULL;

    ns1 = axiom_namespace_create(env, "http://example.org/notify", "m");
    notify_om_ele =
        axiom_element_create(env, NULL, "notify", ns1, &notify_om_node);
    axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node);

    buffer = axiom_node_to_string(notify_om_node, env);
    if (buffer)
    {
        printf("\nSending OM node in XML : %s \n", buffer);
        AXIS2_FREE(env->allocator, buffer);
    }

    return notify_om_node;
}
Example #6
0
/* build SOAP request message content using OM */
axiom_node_t *
build_om_payload_for_echo_svc(const axutil_env_t *env)
{
    axiom_node_t *echo_om_node = NULL;
    axiom_element_t* echo_om_ele = NULL;
    axiom_node_t* text_om_node = NULL;
    axiom_element_t * text_om_ele = NULL;
    axiom_namespace_t *ns1 = NULL;
    axis2_char_t *om_str = NULL;

    ns1 = axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", "ns1");
    echo_om_ele = axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node);
    text_om_ele = axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node);
    axiom_element_set_text(text_om_ele, env, "echo5", text_om_node);

    om_str = axiom_node_to_string(echo_om_node, env);
    if (om_str)
    {
        AXIS2_FREE(env->allocator, om_str);
        om_str =  NULL;
    }
    return echo_om_node;
}
Example #7
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axutil_dll_desc_create_platform_specific_dll_name(
    axutil_dll_desc_t *dll_desc,
    const axutil_env_t *env,
    const axis2_char_t *class_name)
{
    axis2_char_t *temp_name = NULL;

    AXIS2_ENV_CHECK(env, NULL);

    /* allow config to give a literal lib name since it may want a 
     * versioned lib like "libfoo.so.0" */
    if (axutil_strstr(class_name, AXIS2_LIB_SUFFIX)) {
            /* assume the class_name is the literal lib file name */
            dll_desc->dll_name = axutil_strdup(env,class_name);
            return dll_desc->dll_name;
    }

    temp_name = axutil_stracat(env, AXIS2_LIB_PREFIX, class_name);
    dll_desc->dll_name = axutil_stracat(env, temp_name, AXIS2_LIB_SUFFIX);
    AXIS2_FREE(env->allocator, temp_name);
    return dll_desc->dll_name;
}
Example #8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_output_set_xml_version(
    axiom_output_t * om_output,
    const axutil_env_t * env,
    axis2_char_t * xml_version)
{
    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);

    AXIS2_PARAM_CHECK(env->error, xml_version, AXIS2_FAILURE);

    if(om_output->xml_version)
    {
        AXIS2_FREE(env->allocator, om_output->xml_version);
        om_output->xml_version = NULL;
    }

    om_output->xml_version = axutil_strdup(env, xml_version);
    if(!om_output->xml_version)
    {
        return AXIS2_FAILURE;
    }
    return AXIS2_SUCCESS;
}
Example #9
0
  static int AXIS2_CALL Axis2Service_free(axis2_svc_skeleton_t *pSvcSkeleton, const axutil_env_t *pEnv)
  {
    staff::LogDebug() << "stopping StaffService";

#if !defined WIN32
    m_bShuttingDown = true;
    staff::ServiceDispatcher::Inst().Deinit();
#endif

#ifndef WITHOUT_SECURITY
    staff_security_free();
#endif

    if (pSvcSkeleton)
    {
      AXIS2_FREE(pEnv->allocator, pSvcSkeleton);
      pSvcSkeleton = NULL;
    }

    staff::CrashHandler::Disable();

    return AXIS2_SUCCESS; 
  }
Example #10
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_handler_desc_set_class_name(
    axis2_handler_desc_t * handler_desc,
    const axutil_env_t * env,
    const axis2_char_t * class_name)
{
    if(handler_desc->class_name)
    {
        AXIS2_FREE(env->allocator, handler_desc->class_name);
    }

    if(class_name)
    {
        handler_desc->class_name = axutil_strdup(env, class_name);
        if(!handler_desc->class_name)
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
            return AXIS2_FAILURE;
        }
    }

    return AXIS2_SUCCESS;
}
        axis2_status_t AXIS2_CALL
        adb_getReservationStatusesResponse_free (
                adb_getReservationStatusesResponse_t* _getReservationStatusesResponse,
                const axutil_env_t *env)
        {
            
                int i = 0;
                int count = 0;
                void *element = NULL;
            

            AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
            AXIS2_PARAM_CHECK(env->error, _getReservationStatusesResponse, AXIS2_FAILURE);

            adb_getReservationStatusesResponse_reset_reservationStatuses(_getReservationStatusesResponse, env);
            

            if(_getReservationStatusesResponse)
            {
                AXIS2_FREE(env->allocator, _getReservationStatusesResponse);
                _getReservationStatusesResponse = NULL;
            }
            return AXIS2_SUCCESS;
        }
Example #12
0
AXIS2_EXTERN void AXIS2_CALL
axiom_output_free(
    axiom_output_t * om_output,
    const axutil_env_t * env)
{
    AXIS2_ENV_CHECK_VOID(env);

    if(om_output->xml_version)
    {
        AXIS2_FREE(env->allocator, om_output->xml_version);
    }
    if(om_output->mime_boundary)
    {
        AXIS2_FREE(env->allocator, om_output->mime_boundary);
    }
    if(om_output->next_content_id)
    {
        AXIS2_FREE(env->allocator, om_output->next_content_id);
    }
    if(om_output->root_content_id)
    {
        AXIS2_FREE(env->allocator, om_output->root_content_id);
    }

    if(om_output->xml_writer)
    {
        axiom_xml_writer_free(om_output->xml_writer, env);
    }

    if(om_output->binary_node_list)
    {
        axutil_array_list_free(om_output->binary_node_list, env);
    }

    if(om_output->content_type)
    {
        AXIS2_FREE(env->allocator, om_output->content_type);
    }

    AXIS2_FREE(env->allocator, om_output);
    return;
}
        axiom_node_t* AXIS2_CALL
        adb_UAKType_serialize_obj(
                adb_UAKType_t* _UAKType,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
               axiom_attribute_t *text_attri = NULL;
             
             axis2_char_t *string_to_stream;
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
         axis2_char_t* type_attrib = NULL;
         
            axiom_data_source_t *data_source = NULL;
            axutil_stream_t *stream = NULL;
            axis2_char_t *text_value;
             
               axiom_namespace_t *ns1 = NULL;
               axis2_char_t *p_prefix = NULL;
              
                    current_node = parent;
                    data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env);
                    if (!data_source)
                        return NULL;
                    stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */
                    if (!stream)
                        return NULL;
                  
            if(!parent_tag_closed)
            {
            
                if(_UAKType->is_valid_issuerID)
                {
                
                        p_prefix = NULL;
                      
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * 
                                                            (5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT +
                                                             axutil_strlen(_UAKType->property_issuerID) + 
                                                                axutil_strlen("issuerID")));
                           sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "issuerID", _UAKType->property_issuerID);
                           axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                           AXIS2_FREE(env-> allocator, text_value);
                        
                   }
                   
                   else
                   {
                      AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute issuerID");
                      return NULL;
                   }
                   
                if(_UAKType->is_valid_collectionID)
                {
                
                        p_prefix = NULL;
                      
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * 
                                                            (5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT +
                                                             axutil_strlen(_UAKType->property_collectionID) + 
                                                                axutil_strlen("collectionID")));
                           sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "collectionID", _UAKType->property_collectionID);
                           axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                           AXIS2_FREE(env-> allocator, text_value);
                        
                   }
                   
                   else
                   {
                      AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute collectionID");
                      return NULL;
                   }
                   
              string_to_stream = ">"; 
              axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
              tag_closed = 1;
            
            }
        
               if(!parent_tag_closed && !tag_closed)
               {
                  text_value = ">"; 
                  axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
               }
               
               text_value = adb_UAKType_serialize_to_string(_UAKType, env, namespaces);
               if(text_value)
               {
                    axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                    AXIS2_FREE(env->allocator, text_value);
               }
            
                    
                    if(parent_tag_closed)
                    {
                       if(_UAKType->is_valid_issuerID)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = _UAKType->property_issuerID;
                           text_attri = axiom_attribute_create (env, "issuerID", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                        
                      }
                      
                      else
                      {
                         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute issuerID");
                         return NULL;
                      }
                       
                  }
                
                    
                    if(parent_tag_closed)
                    {
                       if(_UAKType->is_valid_collectionID)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = _UAKType->property_collectionID;
                           text_attri = axiom_attribute_create (env, "collectionID", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                        
                      }
                      
                      else
                      {
                         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute collectionID");
                         return NULL;
                      }
                       
                  }
                

            return parent;
        }
        axis2_status_t AXIS2_CALL
        adb_UAKType_deserialize_obj(
                adb_UAKType_t* _UAKType,
                const axutil_env_t *env,
                axiom_node_t **dp_parent,
                axis2_bool_t *dp_is_early_node_valid,
                axis2_bool_t dont_care_minoccurs)
        {
          axiom_node_t *parent = *dp_parent;
          
          axis2_status_t status = AXIS2_SUCCESS;
          
              axiom_attribute_t *parent_attri = NULL;
              axiom_element_t *parent_element = NULL;
              axis2_char_t *attrib_text = NULL;

              axutil_hash_t *attribute_hash = NULL;

          
              void *element = NULL;
           
             const axis2_char_t* text_value = NULL;
             axutil_qname_t *qname = NULL;
          
            
            status = AXIS2_FAILURE;
            if(parent)
            {
                axis2_char_t *attrib_text = NULL;
                attrib_text = axiom_element_get_attribute_value_by_name(axiom_node_get_data_element(parent, env), env, "nil");
                if (attrib_text != NULL && !axutil_strcasecmp(attrib_text, "true"))
                {
                  
                   /* but the wsdl says that, this is non nillable */
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element UAKType");
                    status = AXIS2_FAILURE;
                   
                }
                else
                {
                    axiom_node_t *text_node = NULL;
                    axiom_text_t *text_element = NULL;
                    text_node = axiom_node_get_first_child(parent, env);
                    if (text_node &&
                            axiom_node_get_node_type(text_node, env) == AXIOM_TEXT)
                        text_element = (axiom_text_t*)axiom_node_get_data_element(text_node, env);
                    text_value = "";
                    if(text_element && axiom_text_get_value(text_element, env))
                    {
                        text_value = (axis2_char_t*)axiom_text_get_value(text_element, env);
                    }
                    status = adb_UAKType_deserialize_from_string(_UAKType, env, text_value, parent);
                }
            }
            
                 parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env);
                 attribute_hash = axiom_element_get_all_attributes(parent_element, env);
              
                
                
                  parent_attri = NULL;
                  attrib_text = NULL;
                  if(attribute_hash)
                  {
                       axutil_hash_index_t *hi;
                       void *val;
                       const void *key;

                       for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, &key, NULL, &val);
                           
                           
                               if(!strcmp((axis2_char_t*)key, "issuerID"))
                             
                               {
                                   parent_attri = (axiom_attribute_t*)val;
                                   AXIS2_FREE(env->allocator, hi);
                                   break;
                               }
                       }
                  }

                  if(parent_attri)
                  {
                    attrib_text = axiom_attribute_get_value(parent_attri, env);
                  }
                  else
                  {
                    /* this is hoping that attribute is stored in "issuerID", this happnes when name is in default namespace */
                    attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "issuerID");
                  }

                  if(attrib_text != NULL)
                  {
                      
                      adb_UAKType_set_issuerID(_UAKType,
                                                          env, attrib_text);
                        
                    }
                  
                    else if(!dont_care_minoccurs)
                    {
                        /*
                        if(element_qname)
                        {
                            axutil_qname_free(element_qname, env);
                        }
                        */
                        /* this is not a nillable element*/
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute issuerID missing");
                        return AXIS2_FAILURE;
                    }
                  
                
                
                  parent_attri = NULL;
                  attrib_text = NULL;
                  if(attribute_hash)
                  {
                       axutil_hash_index_t *hi;
                       void *val;
                       const void *key;

                       for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, &key, NULL, &val);
                           
                           
                               if(!strcmp((axis2_char_t*)key, "collectionID"))
                             
                               {
                                   parent_attri = (axiom_attribute_t*)val;
                                   AXIS2_FREE(env->allocator, hi);
                                   break;
                               }
                       }
                  }

                  if(parent_attri)
                  {
                    attrib_text = axiom_attribute_get_value(parent_attri, env);
                  }
                  else
                  {
                    /* this is hoping that attribute is stored in "collectionID", this happnes when name is in default namespace */
                    attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "collectionID");
                  }

                  if(attrib_text != NULL)
                  {
                      
                      adb_UAKType_set_collectionID(_UAKType,
                                                          env, attrib_text);
                        
                    }
                  
                    else if(!dont_care_minoccurs)
                    {
                        /*
                        if(element_qname)
                        {
                            axutil_qname_free(element_qname, env);
                        }
                        */
                        /* this is not a nillable element*/
                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute collectionID missing");
                        return AXIS2_FAILURE;
                    }
                  
          return status;
       }
        axiom_node_t* AXIS2_CALL
        adb_TransformTypeChoice_serialize_obj(
                adb_TransformTypeChoice_t* _TransformTypeChoice,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
             axis2_char_t *string_to_stream;
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
         axis2_char_t* type_attrib = NULL;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t *text_value_1;
                    axis2_char_t *text_value_1_temp;
                    
                    axis2_char_t *text_value_2;
                    axis2_char_t *text_value_2_temp;
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _TransformTypeChoice, NULL);
            
            
                    current_node = parent;
                    data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env);
                    if (!data_source)
                        return NULL;
                    stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */
                    if (!stream)
                        return NULL;
                  
            if(!parent_tag_closed)
            {
            
              
 
              if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING)))
              {
                  /* it is better to stick with the standard prefix */
                  xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi");
                  
                  axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix);

                  if(parent_element)
                  {
                        axiom_namespace_t *element_ns = NULL;
                        element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance",
                                                            xsi_prefix);
                        axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns);
                        if(element_ns)
                        {
                            axiom_namespace_free(element_ns, env);
                        }
                  }
              }
              type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"TransformTypeChoice\"", NULL);
              axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib));

              AXIS2_FREE(env->allocator, type_attrib);
                
              string_to_stream = ">"; 
              axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
              tag_closed = 1;
            
            }
            else {
              /* if the parent tag closed we would be able to declare the type directly on the parent element */ 
              if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING)))
              {
                  /* it is better to stick with the standard prefix */
                  xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi");
                  
                  axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix);

                  if(parent_element)
                  {
                        axiom_namespace_t *element_ns = NULL;
                        element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance",
                                                            xsi_prefix);
                        axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns);
                        if(element_ns)
                        {
                            axiom_namespace_free(element_ns, env);
                        }
                  }
              }
            }
            xsi_ns = axiom_namespace_create (env,
                                 "http://www.w3.org/2000/09/xmldsig#",
                                 xsi_prefix);
            xsi_type_attri = axiom_attribute_create (env, "type", "TransformTypeChoice", xsi_ns);
            
            axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent);
        
                if(0 == axutil_strcmp(_TransformTypeChoice->current_choice, ":extraElement"))
                {
                
                       p_prefix = NULL;
                      

                   if (!_TransformTypeChoice->is_valid_extraElement)
                   {
                      
                            
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property extraElement");
                            return NULL;
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("extraElement"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("extraElement")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing extraElement element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%sextraElement>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%sextraElement>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                                text_value_1 = axiom_node_to_string(_TransformTypeChoice->property_extraElement, env);
                                
                                axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
                                
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                 }
                 
                if(0 == axutil_strcmp(_TransformTypeChoice->current_choice, "http://www.w3.org/2000/09/xmldsig#:XPath"))
                {
                
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://www.w3.org/2000/09/xmldsig#",
                                            p_prefix));
                       }
                      

                   if (!_TransformTypeChoice->is_valid_XPath)
                   {
                      
                            
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property XPath");
                            return NULL;
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("XPath"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("XPath")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing XPath element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%sXPath>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%sXPath>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                           text_value_2 = _TransformTypeChoice->property_XPath;
                           
                           axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                           
                            
                           text_value_2_temp = axutil_xml_quote_string(env, text_value_2, AXIS2_TRUE);
                           if (text_value_2_temp)
                           {
                               axutil_stream_write(stream, env, text_value_2_temp, axutil_strlen(text_value_2_temp));
                               AXIS2_FREE(env->allocator, text_value_2_temp);
                           }
                           else
                           {
                               axutil_stream_write(stream, env, text_value_2, axutil_strlen(text_value_2));
                           }
                           
                           axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                           
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                 }
                 

            return parent;
        }
        axis2_status_t AXIS2_CALL axis2_stub_on_complete_IIp2Location_get(axis2_callback_t *callback, const axutil_env_t *env)
        {
            axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, adb_getResponse_t* _getResponse, void *data);
            struct axis2_stub_IIp2Location_get_callback_data* callback_data = NULL;
            void *user_data = NULL;
            axis2_status_t status = AXIS2_SUCCESS;
            adb_getResponse_t* ret_val;
            

            axiom_node_t *ret_node = NULL;
            axiom_soap_envelope_t *soap_envelope = NULL;

            

            callback_data = (struct axis2_stub_IIp2Location_get_callback_data*)axis2_callback_get_data(callback);

            
            soap_envelope = axis2_callback_get_envelope(callback, env);
            if(soap_envelope)
            {
                axiom_soap_body_t *soap_body;
                soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
                if(soap_body)
                {
                    axiom_soap_fault_t *soap_fault = NULL;
                    axiom_node_t *body_node = axiom_soap_body_get_base_node(soap_body, env);

                      if(body_node)
                    {
                        ret_node = axiom_node_get_first_child(body_node, env);
                    }
                }
                
                
            }

            user_data = callback_data->data;
            on_complete = callback_data->on_complete;

            
                    if(ret_node != NULL)
                    {
                        ret_val = adb_getResponse_create(env);
     
                        if(adb_getResponse_deserialize(ret_val, env, &ret_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
                        {
                            AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the LendResponse_deserialize: "
                                                                    "This should be due to an invalid XML");
                            adb_getResponse_free(ret_val, env);
                            ret_val = NULL;
                        }
                     }
                     else
                     {
                         ret_val = NULL; 
                     }

                     
                         status = on_complete(env, ret_val, user_data);
                         
 
            if(callback_data)
            {
                AXIS2_FREE(env->allocator, callback_data);
            }
            return status;
        }
Example #17
0
int add_subscriber()
{
    remote_registry_t *remote_registry = NULL;
    const axutil_env_t *env = NULL;
    axis2_char_t *subscription_id = NULL;
    axis2_char_t *id = NULL;
    axis2_char_t *path = NULL; 
    axis2_char_t *index_path = NULL; 
    remote_registry_resource_t *res = NULL;
    axutil_hash_t *properties = NULL;
	
    char *content = (char *) strdup("<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>");

    axis2_char_t *epr_type = "application/vnd.epr";
    axis2_char_t *filter = "/weather/4/";
    axis2_char_t *reg_url = "http://localhost:9762/registry";

    env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE);
    subscription_id = axutil_strcat(env, "urn:uuid:", axutil_uuid_gen(env), NULL);
    path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL);
    id = axutil_strcat(env, reg_url, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL);
    remote_registry = remote_registry_create(env, reg_url, "admin", "admin");

    topic_index_init();
    res = remote_registry_resource_create(env);
    remote_registry_resource_set_content(res, env, content);
    remote_registry_resource_set_content_len(res, env, axutil_strlen(content));
    remote_registry_resource_set_media_type(res, env, epr_type);
    remote_registry_resource_set_description(res, env, "");

    properties = axutil_hash_make(env);
    if(properties)
    {
        axutil_hash_set(properties, axutil_strdup(env, "expires"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "*"));
        axutil_hash_set(properties, axutil_strdup(env, "staticFlag"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "false"));
        axutil_hash_set(properties, axutil_strdup(env, "filterValue"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, filter));
        axutil_hash_set(properties, axutil_strdup(env, "subManagerURI"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://10.100.1.44:8280/services/SampleEventSource"));
        axutil_hash_set(properties, axutil_strdup(env, "filterDialect"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://synapse.apache.org/eventing/dialect/topicFilter"));
        remote_registry_resource_set_properties(res, env, properties);
    }

    remote_registry_put(remote_registry, env, path, res);
    if(id)
    {
        AXIS2_FREE(env->allocator, id);
    }
    if(path)
    {
        AXIS2_FREE(env->allocator, path);
        path = NULL;
    }
    if(res)
    {
        remote_registry_resource_free(res, env);
        res = NULL;
    }

    res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL);
    if(!res)
    {
        return 0;
    }
    id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL);
    properties = remote_registry_resource_get_properties(res, env);
    if(properties)
    {
        path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, NULL);
        axutil_hash_set(properties, subscription_id, AXIS2_HASH_KEY_STRING, path);
        remote_registry_resource_set_properties(res, env, properties);
    }

    remote_registry_resource_set_content(res, env, NULL);
    remote_registry_resource_set_content_len(res, env, 0);
    index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL);
    remote_registry_put(remote_registry, env, TOPIC_INDEX, res);

    if(id)
    {
        AXIS2_FREE(env->allocator, id);
    }
    if(res)
    {
        remote_registry_resource_free(res, env);
        res = NULL;
    }
    printf("\n");

    return 0;
}
Example #18
0
AXIS2_EXTERN axutil_url_t *AXIS2_CALL
axutil_url_create(
    const axutil_env_t *env,
    const axis2_char_t *protocol,
    const axis2_char_t *host,
    const int port,
    const axis2_char_t *path)
{
    axutil_url_t *url = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, protocol, NULL);

    if(!protocol || !*protocol || strstr(protocol, "://") || (host && strchr(host, '/')))
    {
        return NULL;
    }

    url = (axutil_url_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_url_t));

    if(!url)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
        return NULL;
    }
    url->protocol = axutil_strdup(env, protocol);
    url->host = NULL;
    url->path = NULL;
    url->server = NULL;
    url->query = NULL;

    if(host)
    {
        url->host = (axis2_char_t *)axutil_strdup(env, host);
        url->port = port;
    }
    else
    {
        url->port = 0;
    }

    /** if the path is not starting with / we have to make it so
     */
    if(path)
    {
        axis2_char_t *params = NULL;
        axis2_char_t *temp = NULL;
        if(path[0] == '/')
        {
            temp = (axis2_char_t *)axutil_strdup(env, path);
        }
        else
        {
            temp = axutil_stracat(env, "/", path);
        }
        params = strchr(temp, '?');
        if(!params)
        {
            params = strchr(temp, '#');
        }
        if(params)
        {
            url->query = (axis2_char_t *)axutil_strdup(env, params);
            *params = '\0';
        }
        url->path = (axis2_char_t *)axutil_strdup(env, temp);
        AXIS2_FREE(env->allocator, temp);
    }

    return url;
}
        axiom_node_t* AXIS2_CALL
        prf_logOnResponseType_serialize_obj(
                prf_logOnResponseType_t* _logOnResponseType,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
             axis2_char_t *string_to_stream;
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
         axis2_char_t* type_attrib = NULL;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t text_value_1[PRF_DEFAULT_DIGIT_LIMIT];
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _logOnResponseType, NULL);
            
            
                    current_node = parent;
                    data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env);
                    if (!data_source)
                        return NULL;
                    stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */
                    if (!stream)
                        return NULL;
                  
            if(!parent_tag_closed)
            {
            
              
 
              if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING)))
              {
                  /* it is better to stick with the standard prefix */
                  xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi");
                  
                  axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix);

                  if(parent_element)
                  {
                        axiom_namespace_t *element_ns = NULL;
                        element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance",
                                                            xsi_prefix);
                        axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns);
                        if(element_ns)
                        {
                            axiom_namespace_free(element_ns, env);
                        }
                  }
              }
              type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"logOnResponseType\"", NULL);
              axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib));

              AXIS2_FREE(env->allocator, type_attrib);
                
              string_to_stream = ">"; 
              axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
              tag_closed = 1;
            
            }
            else {
              /* if the parent tag closed we would be able to declare the type directly on the parent element */ 
              if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING)))
              {
                  /* it is better to stick with the standard prefix */
                  xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi");
                  
                  axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix);

                  if(parent_element)
                  {
                        axiom_namespace_t *element_ns = NULL;
                        element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance",
                                                            xsi_prefix);
                        axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns);
                        if(element_ns)
                        {
                            axiom_namespace_free(element_ns, env);
                        }
                  }
              }
            }
            xsi_ns = axiom_namespace_create (env,
                                 "http://www.pratsam.org/ns/profile/",
                                 xsi_prefix);
            xsi_type_attri = axiom_attribute_create (env, "type", "logOnResponseType", xsi_ns);
            
            axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent);
        
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * PRF_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://www.pratsam.org/ns/profile/",
                                            p_prefix));
                       }
                      

                   if (!_logOnResponseType->is_valid_logOnResult)
                   {
                      
                            
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property logOnResult");
                            return NULL;
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("logOnResult"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("logOnResult")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing logOnResult element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%slogOnResult>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%slogOnResult>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                           strcpy(text_value_1, (_logOnResponseType->property_logOnResult)?"true":"false");
                           
                           axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                           
                           axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
                           
                           axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                           
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 

            return parent;
        }
Example #20
0
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL 
wsf_wsdl_request(
    const axutil_env_t* env,
    axis2_char_t* wsdl_file_name,
    const axis2_char_t* operation_name,	
    wsf_wsdl_data_t* parameters,
    axis2_char_t* script_binding_home,
    axis2_svc_client_t* svc_client,
    axutil_hash_t* svc_client_user_options,
    axis2_char_t* service_name,
    axis2_char_t* port_name,
    wsf_wsdl_data_t** response)
{
    int soap_version = 2; 
    int has_fault = AXIS2_FALSE;
    int binding_style = WSDL_BINDING_STYLE_DOC_LIT_W;
    axis2_char_t* payload = NULL;	
    axiom_node_t* payload_node = NULL;
    axis2_char_t* request_buffer = NULL;	
    axiom_node_t* type_map = NULL;	
    axis2_char_t *res_text = NULL;	
    axiom_node_t* sig_axiom = NULL;	
    axiom_node_t *fault_node = NULL;	
    axiom_node_t* wsdl_axiom = NULL;	
    axiom_node_t* params_node = NULL;	
    axiom_node_t* returns_node = NULL;	
    axiom_soap_body_t *soap_body = NULL;	
    axiom_node_t *body_base_node = NULL;	
    /*axis2_char_t *wrapper_element = NULL;*/	
    axiom_node_t* operation_axiom = NULL;	
    axiom_soap_fault_t *soap_fault = NULL;	
    axis2_options_t *client_options = NULL;	
    /*axis2_char_t *wrapper_element_ns = NULL;*/	
    /*axiom_node_t *axiom_soap_base_node = NULL;	*/
    axiom_soap_envelope_t *response_envelope = NULL;	
    wsf_wsdl_data_template_t* input_template = NULL;	
    wsf_wsdl_data_template_t* output_template = NULL;	
    axis2_bool_t is_version1_wsdl = AXIS2_FALSE;
    axis2_char_t* xslt_location = NULL;
    axis2_char_t* type_map_file = NULL;

    AXIS2_LOG_TRACE_MSG(env->log, "Starting execution of wsf_wsdl_request..."); 

    xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL);
    type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL);

    client_options = (axis2_options_t *)axis2_svc_client_get_options(svc_client, env);

    axis2_options_set_xml_parser_reset(client_options, env, AXIS2_FALSE);

    if (!wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_FALSE))
        return AXIS2_FALSE;

    wsdl_util_create_type_map(env, type_map_file, &type_map);

    wsdl_util_manage_client_options(env, 
        svc_client, 
        svc_client_user_options, 
        client_options, 
        operation_name, 
        wsdl_axiom, 
        is_version1_wsdl, 
        sig_axiom, 
        service_name,
        port_name,
        &operation_axiom, 
        &soap_version);

    wsdl_util_identify_binding_style(env, operation_axiom, &binding_style);

    if (!operation_axiom)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Operation axiom is NULL");

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE;
    }

    wsdl_util_get_params_node(env, operation_axiom, &params_node);
    wsdl_util_get_returns_node(env, operation_axiom, &returns_node);

    wsdl_data_util_axiom_to_template(env, params_node, &input_template);
    wsdl_data_util_axiom_to_template(env, returns_node, &output_template);

#ifdef WSDL_DEBUG_MODE
    {
        axis2_char_t* buffer = NULL;
        wsdl_data_util_serialize_data(env, parameters, &buffer);
        AXIS2_LOG_DEBUG_MSG(env->log, buffer);
        AXIS2_FREE(env->allocator, buffer);
        wsdl_data_util_serialize_template(env, input_template, &buffer);
        AXIS2_LOG_DEBUG_MSG(env->log, buffer);
        AXIS2_FREE(env->allocator, buffer);
        buffer = NULL;
    }
#endif

    if (wsdl_data_util_validate_data(env, type_map, input_template, parameters, VALIDATION_CRITERIA_REQUEST_MODE_TYPE) == AXIS2_TRUE)
    {
        payload_node = wsdl_data_util_create_payload(env, parameters, binding_style);
        payload = payload_node? axiom_node_to_string(payload_node, env) : NULL;
        // axiom_node_free_tree(payload_node, env);
    }
    else
    {
        AXIS2_LOG_ERROR_MSG(env->log, "User data is not valid or not in proper format");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE;
    }

    if (!payload_node)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Request payload is not found");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);
        return AXIS2_FALSE; 
    }

    request_buffer = (axis2_char_t*)wsdl_util_create_request_envelope(env, payload_node, soap_version);

    if (!request_buffer)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Error in creating request payload dom");

        if (input_template)
            wsdl_data_template_free(env, input_template);
        if (output_template)
            wsdl_data_template_free(env, output_template);

        if (wsdl_axiom) 
            axiom_node_free_tree(wsdl_axiom, env);
        if (sig_axiom)
            axiom_node_free_tree(sig_axiom, env);
        if (type_map)
            axiom_node_free_tree(type_map, env);

        return AXIS2_FALSE;
    }

    response_envelope = (axiom_soap_envelope_t*)wsdl_util_send_receive_soap_envelope_with_op_client(env, 
        svc_client, 
        client_options, 
        request_buffer);
    if (response_envelope) 
    {
        has_fault = AXIS2_TRUE;
        soap_body = axiom_soap_envelope_get_body (response_envelope, env);

        if (soap_body)
        {
            soap_fault = axiom_soap_body_get_fault (soap_body, env);
        }

        if (soap_fault) 
        {
            soap_version = axis2_options_get_soap_version(client_options, env);
            fault_node = axiom_soap_fault_get_base_node(soap_fault, env);
            if (fault_node)
            {
                res_text = axiom_node_to_string(fault_node, env);
                AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Fault payload is %s", res_text);

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_FALSE;
            }    
        }

        if (soap_body)
        {
            body_base_node = axiom_soap_body_get_base_node(soap_body, env);
        }

        if (body_base_node && !soap_fault)
        {
            axis2_char_t *response_buffer = NULL;	
            wsf_wsdl_data_t *response_data = NULL;

            response_buffer = axiom_node_to_string(body_base_node, env);
            AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                "Response buffer is %s", response_buffer);

            AXIS2_FREE(env->allocator, response_buffer);

            wsdl_data_util_axiom_to_data(env, body_base_node, &response_data);

#ifdef WSDL_DEBUG_MODE
            {
                axis2_char_t* buffer = NULL;
                wsdl_data_util_serialize_data(env, response_data, &buffer);
                AXIS2_LOG_DEBUG_MSG(env->log, buffer);
                AXIS2_FREE(env->allocator, buffer);
                wsdl_data_util_serialize_template(env, output_template, &buffer);
                AXIS2_LOG_DEBUG_MSG(env->log, buffer);
                AXIS2_FREE(env->allocator, buffer);
                buffer = NULL;
            }
#endif

            if (wsdl_data_util_validate_data(env, type_map, output_template, response_data, VALIDATION_CRITERIA_RESPONSE_MODE) == AXIS2_TRUE)
            {
                AXIS2_LOG_DEBUG_MSG(env->log, "Valid response!!!");
                *response = response_data;

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_TRUE;
            }
            else
            {
                AXIS2_LOG_ERROR_MSG(env->log, "Response data is not valid or not in proper format");

                if (input_template)
                    wsdl_data_template_free(env, input_template);
                if (output_template)
                    wsdl_data_template_free(env, output_template);
                if (wsdl_axiom) 
                    axiom_node_free_tree(wsdl_axiom, env);
                if (sig_axiom)
                    axiom_node_free_tree(sig_axiom, env);
                if (type_map)
                    axiom_node_free_tree(type_map, env);

                return AXIS2_FALSE;
            }
        }
    }
    else  /* response_envelope == NULL */
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Response envelope not found");
    }

    if (input_template)
        wsdl_data_template_free(env, input_template);
    if (output_template)
        wsdl_data_template_free(env, output_template);

    if (wsdl_axiom) 
        axiom_node_free_tree(wsdl_axiom, env);
    if (sig_axiom)
        axiom_node_free_tree(sig_axiom, env);
    if (type_map)
        axiom_node_free_tree(type_map, env);

    return AXIS2_FALSE;
}
Example #21
0
/** 
* initializes the service and create the wsdl_info_t structure */
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL
wsf_wsdl_mode_initialize_for_service(
    const axutil_env_t* env,
    axis2_char_t* wsdl_file_name,
    axis2_char_t* script_binding_home,
    axis2_svc_t* service,
    axis2_conf_ctx_t* worker_conf_ctx,
    axutil_hash_t* script_service_user_options,
    axis2_char_t* service_name,
    axis2_char_t* port_name,
    wsf_wsdl_info_t** wsdl_info)
{
    axiom_node_t* type_map = NULL;	
    axiom_node_t* sig_axiom = NULL;	
    axiom_node_t* wsdl_axiom = NULL;	
    axutil_hash_t* operations = NULL;
    axis2_bool_t success = AXIS2_FAILURE;
    wsf_wsdl_info_t* info = NULL;
    axis2_bool_t is_version1_wsdl = AXIS2_FALSE;
    axis2_char_t* xslt_location = NULL;
    axis2_char_t* type_map_file = NULL;

    xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL);
    type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL);

    if (wsf_wsdl_parser_load_wsdl(env, 
                                  wsdl_file_name, 
                                  xslt_location, 
                                  &wsdl_axiom, 
                                  &sig_axiom, 
                                  &is_version1_wsdl, 
                                  AXIS2_TRUE))
    {

        wsf_wsdl_util_handle_service_security(env,
                                              service,
                                              worker_conf_ctx,
                                              script_service_user_options,
                                              service_name,
                                              port_name,
                                              wsdl_axiom,
                                              is_version1_wsdl);
                                          

        wsdl_util_create_type_map(env, type_map_file, &type_map);
        wsdl_util_get_operations(env, sig_axiom, &operations);

        if (wsdl_info)
        {
            if (*wsdl_info)
            {       
                AXIS2_FREE(env->allocator, *wsdl_info);
            }

            info = (wsf_wsdl_info_t*)AXIS2_MALLOC(env->allocator, sizeof(wsf_wsdl_info_t));

            info->type_map = type_map;
            info->operations = operations;

            *wsdl_info = info;

            success = AXIS2_SUCCESS;
        }
    }   

    return success;
}
Example #22
0
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axis2_bool_t method_get = AXIS2_FALSE;
    axis2_bool_t method_head = AXIS2_FALSE;
    axis2_bool_t method_put = AXIS2_FALSE;
    axis2_bool_t method_delete = AXIS2_FALSE;

    /* Set up the environment */
    env = axutil_env_create_all("echo_rest.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "http://localhost:9090/axis2/services/echo/echoString";
    if (argc > 1)
    {
        if (0 == strncmp(argv[1], "-mGET", 5))
        {
            method_get = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mHEAD", 6))
        {
            method_head = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mPUT", 5))
        {
            method_put = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mDELETE",8 ))
        {
            method_delete = AXIS2_TRUE;
        }
        else if (0 == axutil_strcmp(argv[1], "-h"))
        {
            printf("Usage : %s [endpoint_url] \n", argv[0]);
            printf("\nNOTE: You can test for other HTTP methods by changing the");
            printf(" services.xml of the echo service\n and providing the correct REST HTTP method");
            printf(" and the location to be used for operation.\n");
            printf(" Also note that you have to restart the server after changing the services.xml.\n");
            printf(" use %s -mGET for HTTP GET\n", argv[0]);
            printf(" use %s -mHEAD for HTTP HEAD\n", argv[0]);
            printf(" use %s -mDELETE for HTTP DELETE\n", argv[0]);
            printf(" use %s -mPUT for HTTP PUT\n", argv[0]);
            printf(" use -h for help\n");
            return 0;
        }
        else
        {
            address = argv[1];
        }
    }

    if (argc > 2)
    {
        if (0 == strncmp(argv[2], "-mGET", 5))
        {
            method_get = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mHEAD", 6))
        {
            method_head = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mPUT", 5))
        {
            method_put = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mDELETE",8 ))
        {
            method_delete = AXIS2_TRUE;
        }
        else
        {
            address = argv[2];
        }
    }

    printf("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    /* Enable REST at the client side */
    axis2_options_set_enable_rest(options, env, AXIS2_TRUE);

    if (AXIS2_TRUE == method_get)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_GET);
    }
    else if (AXIS2_TRUE == method_head)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_HEAD);
    }
    else if (AXIS2_TRUE == method_put)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_PUT);
    }
    else if (AXIS2_TRUE == method_delete)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_DELETE);
    }
    /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
     * be different from this folder on your system. For example, you may have a different folder 
     * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the 
     * modules that the client uses
     */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check WSFC_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Build the SOAP request message payload using OM API. */
    payload = build_om_payload_for_echo_svc(env);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (ret_node && 
        axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }
        printf("\necho client invoke FAILED!\n");
    }
    else if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
    }
    else if (method_head &&
        axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        /* HEAD request should probably be removed from this file,
         * and be relocated to transport unit tests.
         */
        printf("\necho client invoke FAILED!\n");
    }
    else if (method_head)
    {
        /* HEAD request should probably be removed from this file,
         * and be relocated to transport unit tests.
         */
        printf("\necho client invoke SUCCESSFUL!\n");
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("echo client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }
    return 0;
}
Example #23
0
        axiom_node_t* AXIS2_CALL
        adb_getPermissionsResponse_serialize_obj(
                adb_getPermissionsResponse_t* _getPermissionsResponse,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT];
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

             
                int next_ns_index_value = 0;
            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _getPermissionsResponse, NULL);
            
             
                    namespaces = axutil_hash_make(env);
                    next_ns_index = &next_ns_index_value;
                     
                           ns1 = axiom_namespace_create (env,
                                             "http://services.resource.ui.mgt.registry.carbon.wso2.org",
                                             "n"); 
                           axutil_hash_set(namespaces, "http://services.resource.ui.mgt.registry.carbon.wso2.org", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
                       
                     
                    parent_element = axiom_element_create (env, NULL, "getPermissionsResponse", ns1 , &parent);
                    
                    
                    axiom_element_set_namespace(parent_element, env, ns1, parent);


            
                    data_source = axiom_data_source_create(env, parent, &current_node);
                    stream = axiom_data_source_get_stream(data_source, env);
                  
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://services.resource.ui.mgt.registry.carbon.wso2.org", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://services.resource.ui.mgt.registry.carbon.wso2.org", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://services.resource.ui.mgt.registry.carbon.wso2.org",
                                            p_prefix));
                       }
                      

                   if (!_getPermissionsResponse->is_valid_return)
                   {
                      
                           /* no need to complain for minoccurs=0 element */
                            
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("return"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("return")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing return element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%sreturn",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); 
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%sreturn>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                     
                            if(!adb_PermissionBean_is_particle())
                            {
                                axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                            }
                            adb_PermissionBean_serialize(_getPermissionsResponse->property_return, 
                                                                                 env, current_node, parent_element,
                                                                                 adb_PermissionBean_is_particle() || AXIS2_FALSE, namespaces, next_ns_index);
                            
                            if(!adb_PermissionBean_is_particle())
                            {
                                axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                            }
                            
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                   if(namespaces)
                   {
                       axutil_hash_index_t *hi;
                       void *val;
                       for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, NULL, NULL, &val);
                           AXIS2_FREE(env->allocator, val);
                       }
                       axutil_hash_free(namespaces, env);
                   }
                

            return parent;
        }
Example #24
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_text_serialize(
    axiom_text_t * om_text,
    const axutil_env_t * env,
    axiom_output_t * om_output)
{
    int status = AXIS2_SUCCESS;
    axis2_char_t *attribute_value = NULL;
    const axis2_char_t *text = NULL;
    axiom_xml_writer_t *om_output_xml_writer = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE);

    if(!axiom_text_get_is_binary(om_text, env))
    {
        if(om_text->value)
        {
            status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, axutil_string_get_buffer(
                om_text->value, env));
        }
    }
    else
    {
        om_output_xml_writer = axiom_output_get_xml_writer(om_output, env);
        if(axiom_output_is_optimized(om_output, env) && om_text->optimize)
        {
            if(!(axiom_text_get_content_id(om_text, env)))
            {
                axis2_char_t *content_id = axiom_output_get_next_content_id(om_output, env);
                if(content_id)
                {
                    om_text->content_id = axutil_strdup(env, content_id);
                }
            }

            attribute_value = axutil_stracat(env, "cid:", om_text->content_id);

            /*send binary as MTOM optimised */
            if(om_text->om_attribute)
            {
                axiom_attribute_free(om_text->om_attribute, env);
                om_text->om_attribute = NULL;
            }

            om_text->om_attribute = axiom_attribute_create(env, "href", attribute_value, NULL);

            AXIS2_FREE(env->allocator, attribute_value);
            attribute_value = NULL;

            if(!om_text->is_swa) /* This is a hack to get SwA working */
            {
                axiom_text_serialize_start_part(om_text, env, om_output);
            }
            else
            {
                status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, om_text->content_id);
            }

            axiom_output_write_optimized(om_output, env, om_text);

            axiom_output_write(om_output, env, AXIOM_ELEMENT, 0);
        }
        else
        {
            text = axiom_text_get_text(om_text, env);
            axiom_xml_writer_write_characters(om_output_xml_writer, env, (axis2_char_t *)text);
        }
    }
    return status;
}
Example #25
0
AXIS2_EXTERN axutil_url_t *AXIS2_CALL
axutil_url_parse_string(
    const axutil_env_t *env,
    const axis2_char_t *str_url)
{
    /**
     * Only accepted format is : 
     * protocol://host:port/path
     * Added file:///path
     * port is optional and the default port is assumed
     * if path is not present / (root) is assumed
     */
    axis2_char_t *tmp_url_str = NULL;
    axutil_url_t *ret = NULL;
    const axis2_char_t *protocol = NULL;
    axis2_char_t *path = NULL;
    axis2_char_t *port_str = NULL;
    axis2_char_t *host = NULL;
    int port = 0;

    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, str_url, NULL);

    tmp_url_str = axutil_strdup(env, str_url);
    if(!tmp_url_str)
    {
        return NULL;
    }
    protocol = tmp_url_str;
    host = strstr(tmp_url_str, "://");
    if(!host)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);

        AXIS2_FREE(env->allocator, tmp_url_str);
        return NULL;
    }
    if(axutil_strlen(host) < 3 * sizeof(axis2_char_t))
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid IP or hostname");
        AXIS2_FREE(env->allocator, tmp_url_str);
        return NULL;
    }
    *host = '\0';
    host += 3 * sizeof(axis2_char_t); /* skip "://" part */
    if(axutil_strlen(host) <= 0)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid IP or hostname");
        AXIS2_FREE(env->allocator, tmp_url_str);
        return NULL;
    }
    /* if the url is file:// thing we need the protocol and
     * path only
     */
    if(0 == axutil_strcasecmp(protocol, (const axis2_char_t *)"file"))
    {
        ret = axutil_url_create(env, protocol, NULL, 0, host);
        AXIS2_FREE(env->allocator, tmp_url_str);
        return ret;
    }

    port_str = strchr(host, ':');
    if(!port_str)
    {
        path = strchr(host, '/');
        if(!path)
        {
            path = strchr(host, '?');
        }
        else
        {
            *path++ = '\0';
        }
        if(!path)
        {
            path = strchr(host, '#');
        }
        if(!path)
        {
            /* No path - assume def path ('/') */
            /* here we have protocol + host + def port + def path */
            ret = axutil_url_create(env, protocol, host, port, "/");
            AXIS2_FREE(env->allocator, tmp_url_str);
            return ret;
        }
        else
        {
            axis2_char_t *path_temp = NULL;

            path_temp = axutil_strdup(env, path);
            *path = '\0';
            /* here we have protocol + host + def port + path */
            ret = axutil_url_create(env, protocol, host, port, path_temp);
            AXIS2_FREE(env->allocator, tmp_url_str);
            AXIS2_FREE(env->allocator, path_temp);
            return ret;
        }
    }
    else
    {
        *port_str++ = '\0';
        path = strchr(port_str, '/');
        if(!path)
        {
            path = strchr(port_str, '?');
            if(path)
            {
                *path = '\0';
                port = AXIS2_ATOI(port_str);
                *path = '?';
            }
        }
        else
        {
            *path++ = '\0';
            port = AXIS2_ATOI(port_str);
        }
        if(!path)
        {
            path = strchr(port_str, '#');
            if(path)
            {
                *path = '\0';
                port = AXIS2_ATOI(port_str);
                *path = '#';
            }
        }
        if(!path)
        {
            port = AXIS2_ATOI(port_str);
            /* here we have protocol + host + port + def path */
            ret = axutil_url_create(env, protocol, host, port, "/");
            AXIS2_FREE(env->allocator, tmp_url_str);
            return ret;
        }
        else
        {
            if(axutil_strlen(path) > 0)
            {
                axis2_char_t *path_temp = NULL;

                path_temp = axutil_strdup(env, path);
                *path = '\0';
                /* here we have protocol + host + port + path */
                ret = axutil_url_create(env, protocol, host, port, path_temp);
                AXIS2_FREE(env->allocator, tmp_url_str);
                AXIS2_FREE(env->allocator, path_temp);
                return ret;
            }
            else
            {
                /* here we have protocol + host + port + def path */
                ret = axutil_url_create(env, protocol, host, port, "/");
                AXIS2_FREE(env->allocator, tmp_url_str);
                return ret;
            }
        }
    }
}
        axiom_node_t* AXIS2_CALL
        adb_CipherReference_serialize_obj(
                adb_CipherReference_t* _CipherReference,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT];
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

             
                int next_ns_index_value = 0;
            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _CipherReference, NULL);
            
             
                    namespaces = axutil_hash_make(env);
                    next_ns_index = &next_ns_index_value;
                     
                           ns1 = axiom_namespace_create (env,
                                             "http://www.w3.org/2001/04/xmlenc#",
                                             "n"); 
                           axutil_hash_set(namespaces, "http://www.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
                       
                     
                    parent_element = axiom_element_create (env, NULL, "CipherReference", ns1 , &parent);
                    
                    
                    axiom_element_set_namespace(parent_element, env, ns1, parent);


            
                    data_source = axiom_data_source_create(env, parent, &current_node);
                    stream = axiom_data_source_get_stream(data_source, env);
                  
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://www.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://www.w3.org/2001/04/xmlenc#",
                                            p_prefix));
                       }
                      

                   if (!_CipherReference->is_valid_CipherReference)
                   {
                      
                            
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property CipherReference");
                            return NULL;
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("CipherReference"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("CipherReference")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing CipherReference element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%sCipherReference",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); 
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%sCipherReference>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    adb_CipherReferenceType_serialize(_CipherReference->property_CipherReference, 
                                                                                 env, current_node, parent_element,
                                                                                 adb_CipherReferenceType_is_particle() || AXIS2_TRUE, namespaces, next_ns_index);
                            
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                   if(namespaces)
                   {
                       axutil_hash_index_t *hi;
                       void *val;
                       for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, NULL, NULL, &val);
                           AXIS2_FREE(env->allocator, val);
                       }
                       axutil_hash_free(namespaces, env);
                   }
                

            return parent;
        }
Example #27
0
        axiom_node_t* AXIS2_CALL
        adb_subscriberRequest_serialize_obj(
                adb_subscriberRequest_t* _subscriberRequest,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT];
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

             
                int next_ns_index_value = 0;
            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _subscriberRequest, NULL);
            
             
                    namespaces = axutil_hash_make(env);
                    next_ns_index = &next_ns_index_value;
                     
                           ns1 = axiom_namespace_create (env,
                                             "http://mopevm.ru/axis2/services/types",
                                             "n"); 
                           axutil_hash_set(namespaces, "http://mopevm.ru/axis2/services/types", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
                       
                     
                    parent_element = axiom_element_create (env, NULL, "subscriberRequest", ns1 , &parent);
                    
                    
                    axiom_element_set_namespace(parent_element, env, ns1, parent);


            
                    data_source = axiom_data_source_create(env, parent, &current_node);
                    stream = axiom_data_source_get_stream(data_source, env);
                  
                       p_prefix = NULL;
                      

                   if (!_subscriberRequest->is_valid_number)
                   {
                      
                            
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property number");
                            return NULL;
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("number"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("number")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing number element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%snumber>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%snumber>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                               sprintf (text_value_1, AXIS2_PRINTF_INT32_FORMAT_SPECIFIER, _subscriberRequest->property_number);
                             
                           axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                           
                           axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
                           
                           axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                           
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                   if(namespaces)
                   {
                       axutil_hash_index_t *hi;
                       void *val;
                       for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, NULL, NULL, &val);
                           AXIS2_FREE(env->allocator, val);
                       }
                       axutil_hash_free(namespaces, env);
                   }
                

            return parent;
        }
Example #28
0
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;

    const axis2_char_t *google_key = NULL;
    const axis2_char_t *word_to_spell = NULL;
    const axis2_char_t *operation = NULL;

    operation = "doSpellingSuggestion";
    google_key = "00000000000000000000000000000000";
    word_to_spell = "salvasion";

    /* Set up the environment */
    env = axutil_env_create_all("google_client.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of google service */
    address = "http://api.google.com/search/beta2";

    if ((argc > 1) && (axutil_strcmp("-h", argv[1]) == 0))
    {
        printf("\nUsage : %s [google_key] [word_to_spell] \n", argv[0]);
        printf
            ("\tgoogle_key Your Google license key. Default value won't work. You must use your key here.\n");
        printf
            ("\tword_to_spell Word to be spelled by Google service. Default is %s\n",
             word_to_spell);
        printf
            ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n");
        printf("\tUse -h for help\n");
        return 0;
    }

    if (argc > 1)
        google_key = argv[1];
    if (argc > 2)
        word_to_spell = argv[2];
    if (argc > 3)
        address = argv[3];

    printf("Using endpoint : %s\n", address);
    printf("\nInvoking operation %s with params %s and %s\n", operation,
           google_key, word_to_spell);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_soap_version(options, env, AXIOM_SOAP11);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check WSFC_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Build the SOAP request message payload using OM API. */
    payload =
        build_soap_body_content(env, operation, google_key, word_to_spell);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axiom_soap_envelope_t *soap_envelope = NULL;
        axiom_soap_body_t *soap_body = NULL;
        axiom_soap_fault_t *soap_fault = NULL;
        axis2_char_t *fault_string = NULL;

        printf("\nResponse has a SOAP fault\n");
        soap_envelope =
            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
        if (soap_envelope)
        {
            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
        }

        if (soap_body)
        {
            soap_fault = axiom_soap_body_get_fault(soap_body, env);
        }

        if (soap_fault)
        {
            fault_string = axiom_node_to_string(axiom_soap_fault_get_base_node
                                                (soap_fault, env), env);
            printf("\nReturned SOAP fault: %s\n", fault_string);
            AXIS2_FREE (env->allocator, fault_string);
        }

        if (svc_client)
        {
            axis2_svc_client_free(svc_client, env);
            svc_client = NULL;
        }

        if (env)
        {
            axutil_env_free((axutil_env_t *) env);
            env = NULL;
        }

        return -1;
    }

    if (ret_node)
    {
        if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
        {
            axis2_char_t *result = NULL;
            axiom_element_t *result_ele = NULL;
            axiom_node_t *ret_node1 = NULL;

            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
            if (axutil_strcmp
                (axiom_element_get_localname(result_ele, env),
                 "doSpellingSuggestionResponse") != 0)
            {
                print_invalid_om(env, ret_node);
                return AXIS2_FAILURE;
            }

            ret_node1 = axiom_node_get_first_element(ret_node, env);    /*return */
            if (!ret_node1)
            {
                print_invalid_om(env, ret_node);
                return AXIS2_FAILURE;
            }
            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node1, env);
            result = axiom_element_get_text(result_ele, env, ret_node1);
            printf("\nResult = %s\n", result);
        }
        else
        {
            print_invalid_om(env, ret_node);
            return AXIS2_FAILURE;
        }
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("Google client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return 0;
}
        axiom_node_t* AXIS2_CALL
        adb_getOperationRequestCount_serialize_obj(
                adb_getOperationRequestCount_t* _getOperationRequestCount,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t *text_value_1;
                    axis2_char_t *text_value_1_temp;
                    
                    axis2_char_t *text_value_2;
                    axis2_char_t *text_value_2_temp;
                    
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

             
                int next_ns_index_value = 0;
            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _getOperationRequestCount, NULL);
            
             
                    namespaces = axutil_hash_make(env);
                    next_ns_index = &next_ns_index_value;
                     
                           ns1 = axiom_namespace_create (env,
                                             "http://org.apache.axis2/xsd",
                                             "n"); 
                           axutil_hash_set(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n"));
                       
                     
                    parent_element = axiom_element_create (env, NULL, "getOperationRequestCount", ns1 , &parent);
                    
                    
                    axiom_element_set_namespace(parent_element, env, ns1, parent);


            
                    data_source = axiom_data_source_create(env, parent, &current_node);
                    stream = axiom_data_source_get_stream(data_source, env);
                  
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://org.apache.axis2/xsd",
                                            p_prefix));
                       }
                      

                   if (!_getOperationRequestCount->is_valid_serviceName)
                   {
                      
                           /* no need to complain for minoccurs=0 element */
                            
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("serviceName"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("serviceName")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing serviceName element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%sserviceName>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%sserviceName>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                           text_value_1 = _getOperationRequestCount->property_serviceName;
                           
                           axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                           
                            
                           text_value_1_temp = axutil_xml_quote_string(env, text_value_1, AXIS2_TRUE);
                           if (text_value_1_temp)
                           {
                               axutil_stream_write(stream, env, text_value_1_temp, axutil_strlen(text_value_1_temp));
                               AXIS2_FREE(env->allocator, text_value_1_temp);
                           }
                           else
                           {
                               axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
                           }
                           
                           axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                           
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                       if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING)))
                       {
                           p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT);
                           sprintf(p_prefix, "n%d", (*next_ns_index)++);
                           axutil_hash_set(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING, p_prefix);
                           
                           axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env,
                                            "http://org.apache.axis2/xsd",
                                            p_prefix));
                       }
                      

                   if (!_getOperationRequestCount->is_valid_operationName)
                   {
                      
                           /* no need to complain for minoccurs=0 element */
                            
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("operationName"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("operationName")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     
                     /*
                      * parsing operationName element
                      */

                    
                    
                            sprintf(start_input_str, "<%s%soperationName>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                            
                        start_input_str_len = axutil_strlen(start_input_str);
                        sprintf(end_input_str, "</%s%soperationName>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                        end_input_str_len = axutil_strlen(end_input_str);
                    
                           text_value_2 = _getOperationRequestCount->property_operationName;
                           
                           axutil_stream_write(stream, env, start_input_str, start_input_str_len);
                           
                            
                           text_value_2_temp = axutil_xml_quote_string(env, text_value_2, AXIS2_TRUE);
                           if (text_value_2_temp)
                           {
                               axutil_stream_write(stream, env, text_value_2_temp, axutil_strlen(text_value_2_temp));
                               AXIS2_FREE(env->allocator, text_value_2_temp);
                           }
                           else
                           {
                               axutil_stream_write(stream, env, text_value_2, axutil_strlen(text_value_2));
                           }
                           
                           axutil_stream_write(stream, env, end_input_str, end_input_str_len);
                           
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                   if(namespaces)
                   {
                       axutil_hash_index_t *hi;
                       void *val;
                       for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) 
                       {
                           axutil_hash_this(hi, NULL, NULL, &val);
                           AXIS2_FREE(env->allocator, val);
                       }
                       axutil_hash_free(namespaces, env);
                   }
                

            return parent;
        }
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_mime_body_part_write_to_list(
    axiom_mime_body_part_t *mime_body_part,
    const axutil_env_t *env,
    axutil_array_list_t *list)
{
    axutil_hash_index_t *hash_index = NULL;
    const void *key = NULL;
    void *value = NULL;
    axis2_char_t *header_str = NULL;
    axis2_char_t *temp_header_str = NULL;
    int header_str_size = 0;
    axis2_status_t status = AXIS2_FAILURE;
    axiom_mime_part_t *mime_header_part = NULL;

    /* We have the mime headers in the hash with thier keys
     * So first concatenate them to a one string */

    for(hash_index = axutil_hash_first(mime_body_part->header_map, env); hash_index; hash_index
        = axutil_hash_next(env, hash_index))
    {
        axutil_hash_this(hash_index, &key, NULL, &value);
        if(key && value)
        {
            /* First conactenate to the already conacatenated stuff */

            temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)key);
            if(header_str)
            {
                AXIS2_FREE(env->allocator, header_str);
            }
            header_str = temp_header_str;
            temp_header_str = axutil_stracat(env, header_str, ": ");
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;

            /* Add the new stuff */
            temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)value);
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;

            /* Next header will be in a new line. So lets add it */

            temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;
        }
    }

    /* If there is a data handler that's mean there is an attachment. Attachment
     * will always start after an additional new line . So let's add it .*/

    if(mime_body_part->data_handler)
    {
        temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
        AXIS2_FREE(env->allocator, header_str);
        header_str = temp_header_str;
    }

    if(header_str)
    {
        header_str_size = axutil_strlen(header_str);
    }

    /* Now we have the complete mime_headers string for a particular mime part.
     * First wrap it as a mime_part_t .Then add it to the array list so
     * later through the transport this can be written to the wire. */

    mime_header_part = axiom_mime_part_create(env);

    if(mime_header_part)
    {
        mime_header_part->part = (axis2_byte_t *)header_str;
        mime_header_part->part_size = header_str_size;
        mime_header_part->type = AXIOM_MIME_PART_BUFFER;
    }
    else
    {
        return AXIS2_FAILURE;
    }

    axutil_array_list_add(list, env, mime_header_part);

    /* Then if the data_handler is there let's add the binary data, may be
     * buffer , may be file name and information. 
     */

    if(mime_body_part->data_handler)
    {
        status = axiom_data_handler_add_binary_data(mime_body_part->data_handler, env, list);
        if(status != AXIS2_SUCCESS)
        {
            return status;
        }
    }
    return AXIS2_SUCCESS;
}