/**
          * auto generated method signature for in only mep invocations
          * for "add|http://ws.apache.org/axis2" operation.
          * @param stub The stub (axis2_stub_t)
          * @param env environment ( mandatory)
          * @param _add of the adb_add_t*
          *
          * @return 
          */
         axis2_status_t AXIS2_CALL
         axis2_stub_op_IIp2Location_add( axis2_stub_t *stub, const axutil_env_t *env,
                                              adb_add_t* _add)
         {
            axis2_status_t status;

            axis2_svc_client_t *svc_client = NULL;
            axis2_options_t *options = NULL;

            const axis2_char_t *soap_action = NULL;
            axutil_qname_t *op_qname =  NULL;
            axiom_node_t *payload = NULL;

            axutil_string_t *soap_act = NULL;
            
                                payload = adb_add_serialize(_add, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
                           


            svc_client = axis2_stub_get_svc_client(stub, env );
            
           
            
            


            options = axis2_stub_get_options( stub, env);
            if ( NULL == options )
            { 
              AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
              AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "options is null in stub");
              return AXIS2_FAILURE;
            }
            svc_client = axis2_stub_get_svc_client (stub, env );
            soap_act = axis2_options_get_soap_action ( options, env );
            if ( NULL == soap_act )
            {
              soap_action = "urn:add";
              soap_act = axutil_string_create(env, "urn:add");
              axis2_options_set_soap_action(options, env, soap_act);    
            }
            
            axis2_options_set_soap_version(options, env, AXIOM_SOAP12 );
             
            op_qname = axutil_qname_create(env,
                                        "add" ,
                                        "http://ws.apache.org/axis2",
                                        NULL);
            status =  axis2_svc_client_send_robust_with_op_qname( svc_client, env, op_qname, payload);
            return status;

        }
         adb_getResponse_t* AXIS2_CALL 
         axis2_stub_op_IIp2Location_get( axis2_stub_t *stub, const axutil_env_t *env,
                                               adb_get_t* _get)
         {
            axis2_svc_client_t *svc_client = NULL;
            axis2_options_t *options = NULL;
            axiom_node_t *ret_node = NULL;

            const axis2_char_t *soap_action = NULL;
            axutil_qname_t *op_qname =  NULL;
            axiom_node_t *payload = NULL;
            axis2_bool_t is_soap_act_set = AXIS2_TRUE;
            axutil_string_t *soap_act = NULL;

            adb_getResponse_t* ret_val;
            
                                payload = adb_get_serialize(_get, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
                           
            svc_client = axis2_stub_get_svc_client(stub, env );
            
           
            
            

            options = axis2_stub_get_options( stub, env);
            if (NULL == options)
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "options is null in stub");
                return (adb_getResponse_t*)NULL;
            }
            soap_act = axis2_options_get_soap_action( options, env );
            if (NULL == soap_act)
            {
              is_soap_act_set = AXIS2_FALSE;
              soap_action = "urn:get";
              soap_act = axutil_string_create(env, "urn:get");
              axis2_options_set_soap_action(options, env, soap_act);    
            }

            
            axis2_options_set_soap_version(options, env, AXIOM_SOAP12);
             
            ret_node =  axis2_svc_client_send_receive_with_op_qname( svc_client, env, op_qname, payload);
 
            if (!is_soap_act_set)
            {
              
              axis2_options_set_soap_action(options, env, NULL);    
              
              axis2_options_set_action( options, env, NULL);
            }
            if(soap_act)
            {
              axutil_string_free(soap_act, env);
            }

            
                    if ( NULL == ret_node )
                    {
                        return (adb_getResponse_t*)NULL;
                    }
                    ret_val = adb_getResponse_create(env);

                    if(adb_getResponse_deserialize(ret_val, env, &ret_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE)
                    {
                        if(ret_val != NULL)
                        {
                            adb_getResponse_free(ret_val, env);
                        }

                        AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the adb_getResponse_deserialize: "
                                                                "This should be due to an invalid XML");
                        return (adb_getResponse_t*)NULL;
                    }

                   
                            return ret_val;
                       
        }
         void AXIS2_CALL
         axis2_stub_start_op_IIp2Location_get( axis2_stub_t *stub, const axutil_env_t *env,
                                              adb_get_t* _get,
                                                  void *user_data,
                                                  axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, adb_getResponse_t* _getResponse, void *data) ,
                                                  axis2_status_t ( AXIS2_CALL *on_error ) (const axutil_env_t *, int exception, void *data) )
         {

            axis2_callback_t *callback = NULL;

            axis2_svc_client_t *svc_client = NULL;
            axis2_options_t *options = NULL;

            const axis2_char_t *soap_action = NULL;
            axiom_node_t *payload = NULL;

            axis2_bool_t is_soap_act_set = AXIS2_TRUE;
            axutil_string_t *soap_act = NULL;

            
            
            struct axis2_stub_IIp2Location_get_callback_data *callback_data;

            callback_data = (struct axis2_stub_IIp2Location_get_callback_data*) AXIS2_MALLOC(env->allocator, 
                                    sizeof(struct axis2_stub_IIp2Location_get_callback_data));
            if(NULL == callback_data)
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
                AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "Can not allocate memeory for the callback data structures");
                return;
            }
            

            
                                payload = adb_get_serialize(_get, env, NULL, NULL, AXIS2_TRUE, NULL, NULL);
                           


            svc_client = axis2_stub_get_svc_client(stub, env );
            
           
            
            

            options = axis2_stub_get_options( stub, env);
            if (NULL == options)
            {
              AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
              AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "options is null in stub");
              return;
            }

            soap_act =axis2_options_get_soap_action (options, env);
            if (NULL == soap_act)
            {
              is_soap_act_set = AXIS2_FALSE;
              soap_action = "urn:get";
              soap_act = axutil_string_create(env, "urn:get");
              axis2_options_set_soap_action(options, env, soap_act);
            }
            
            axis2_options_set_soap_version(options, env, AXIOM_SOAP12);
             

            callback = axis2_callback_create(env);
            /* Set our on_complete fucntion pointer to the callback object */
            axis2_callback_set_on_complete(callback, axis2_stub_on_complete_IIp2Location_get);
            /* Set our on_error function pointer to the callback object */
            axis2_callback_set_on_error(callback, axis2_stub_on_error_IIp2Location_get);

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

            axis2_callback_set_data(callback, (void*)callback_data);

            /* Send request */
            axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback);
            
            if (!is_soap_act_set)
            {
              
              axis2_options_set_soap_action(options, env, NULL);
              
              axis2_options_set_action(options, env, NULL);
            }
         }
Пример #4
0
void
wsdl_util_manage_client_options(
    const axutil_env_t* env, 
    axis2_svc_client_t* svc_client,
    axutil_hash_t* svc_client_user_options, 
    axis2_options_t* client_options, 
    const axis2_char_t* operation_name,
    axiom_node_t* wsdl_axiom,
    axis2_bool_t is_version1_wsdl,
    axiom_node_t* sig_axiom, 
    axis2_char_t* service_name,
    axis2_char_t* port_name,
    axiom_node_t** operation_axiom,
    int* soap_version)
{
    axis2_char_t* endpoint_address = NULL;
    axis2_char_t* classmap = NULL;
    axis2_char_t* proxy_host = NULL;
    axis2_char_t* proxy_port = NULL;
    axis2_bool_t option_supported = AXIS2_TRUE;  /* ;-) */

    int string_malloc_length = -1;
    axis2_bool_t is_multiple_interfaces = AXIS2_FALSE; 
    axis2_bool_t multiple_ep = AXIS2_FALSE;
    axis2_endpoint_ref_t *to_epr = NULL;    
    axis2_char_t *soap_action = NULL;
    axis2_char_t *wsa_action = NULL;
    axis2_bool_t is_http_method_post = AXIS2_TRUE;
    axiom_node_t* binding_node = NULL;

    axis2_char_t *ssl_server_key_filename = NULL;
    axis2_char_t *ssl_client_key_filename = NULL;
    axis2_char_t *passphrase = NULL; 
    axutil_hash_t* wsdl_policy_hash = NULL;

    /* allocations */
    string_malloc_length = sizeof(axis2_char_t) * 256; 
    endpoint_address = (axis2_char_t *)AXIS2_MALLOC(env->allocator, string_malloc_length); 
    classmap = (axis2_char_t *)AXIS2_MALLOC(env->allocator, string_malloc_length); 
    soap_action = (axis2_char_t *)AXIS2_MALLOC(env->allocator, string_malloc_length); 
    wsa_action = (axis2_char_t *)AXIS2_MALLOC(env->allocator, string_malloc_length); 

    strcpy(soap_action, "");
    strcpy(wsa_action, "");

    if (svc_client_user_options)
    {
        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_ENDPOINT))
        {  
            strcpy(endpoint_address, (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_ENDPOINT, AXIS2_HASH_KEY_STRING)); 
        }
        else 
        {
            strcpy(endpoint_address, "");
        }

        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_CLASSMAP))
        {
            strcpy(classmap, (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_CLASSMAP, AXIS2_HASH_KEY_STRING)); 
        }
        else
        {
            strcpy(classmap, "");
        }
    
        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_USE_SOAP))
        {
            axis2_char_t* use_soap = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_USE_SOAP, AXIS2_HASH_KEY_STRING);
            if (axutil_strcmp(use_soap, WSF_WSDL_SOAP_1_2) == 0)
            {
                *soap_version = 2;
                AXIS2_LOG_DEBUG_MSG(env->log, "soap version SOAP12");
            }
            else if (axutil_strcmp(use_soap, WSF_WSDL_SOAP_1_1) == 0)
            {
                *soap_version = 1;
                AXIS2_LOG_DEBUG_MSG(env->log, "soap version SOAP11"); 
            }
            else
            {
                 /* TODO: support REST */
            }
        }
        else
        {
            /* default to soap version 1.2 */
            *soap_version = 2;
            AXIS2_LOG_DEBUG_MSG(env->log, "default to soap version 1.2");
        }
        

        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_PROXY_HOST))
        {
            proxy_host = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_PROXY_HOST, AXIS2_HASH_KEY_STRING);
        }

        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_PROXY_PORT))
        {
            proxy_port = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_PROXY_PORT, AXIS2_HASH_KEY_STRING);
        }
        
        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_CLIENT_CERT))
        {
            ssl_server_key_filename = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_CLIENT_CERT, AXIS2_HASH_KEY_STRING);
        }
        
        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_PASSPHRASE))
        {
            ssl_client_key_filename = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_PASSPHRASE, AXIS2_HASH_KEY_STRING);
        }
        
        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_SERVER_CERT))
        {
            passphrase = (axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_SERVER_CERT, AXIS2_HASH_KEY_STRING);
        }

        if (axutil_hash_contains_key(svc_client_user_options, env, WSF_WSDL_HTTP_METHOD))
        {
            if (axutil_strcasecmp((axis2_char_t*)axutil_hash_get(svc_client_user_options, WSF_WSDL_HTTP_METHOD, AXIS2_HASH_KEY_STRING), AXIS2_HTTP_GET) == 0)
            {
                is_http_method_post = AXIS2_FALSE;   
            }     
        }

    }
    else
    {
        strcpy(endpoint_address, "");
    }
    
    is_multiple_interfaces = AXIS2_FALSE;
    
    /* TODO: add support for multiple port/interface types */
    
    if (axutil_strcmp(endpoint_address, "") == 0)
    {
        axis2_char_t* sig_endpoint_address = NULL;
        if (wsdl_util_get_endpoint_address(sig_axiom, env, &sig_endpoint_address) == AXIS2_SUCCESS)
        {
            strcpy(endpoint_address, (char *)sig_endpoint_address);
        }
    }
    else
    {
        multiple_ep = 1;

        /* TODO: add suppor for multiple endpoints */ 
    }
    
    if (option_supported) /* get binding details */
    {
        axiom_node_t* op_axiom = NULL;
        int soap_ver = 2;
        axis2_char_t* wsa_action_binding_details = NULL;
        axis2_char_t* soap_action_binding_details = NULL;
    
        if (wsdl_util_find_operation(env,
                                     operation_name, endpoint_address,
                                     AXIS2_TRUE /* is_multiple */,
                                     sig_axiom,
                                     &op_axiom,
                                     &soap_ver) == AXIS2_SUCCESS)
        {
            *operation_axiom = op_axiom;
            *soap_version = soap_ver;
            if (wsdl_util_get_binding_details(env, 
                                              op_axiom,
                                              &wsa_action, &soap_action) == AXIS2_SUCCESS)
            {
                if (wsa_action_binding_details)
                    strcpy (wsa_action, wsa_action_binding_details);
                if (soap_action_binding_details)
                    strcpy (soap_action, soap_action_binding_details);

                /*TODO: check this condition */
                //if (wsa_action_binding_details || soap_action_binding_details) 
                //{
                //    soap_version = soap_version_binding_details; 
                //}
            }
        }
    }

    if (wsf_wsdl_util_get_binding_node(env,
                                       wsdl_axiom,
                                       is_version1_wsdl,
                                       service_name,
                                       port_name,
                                       &binding_node))
    {

        if (wsf_wsdl_util_get_all_policies_from_wsdl(env, 
                                                     wsdl_axiom,
                                                     is_version1_wsdl,
                                                     binding_node,
                                                     operation_name,
                                                     &wsdl_policy_hash))
        {
    
            wsf_wsdl_util_configure_security_for_svc_client(env,
                                                            svc_client_user_options,
                                                            wsdl_policy_hash,
                                                            svc_client);
        }
    }
                                                
    to_epr = axis2_endpoint_ref_create (env, endpoint_address);
    axis2_options_set_to (client_options, env, to_epr);
    
    /** enable ssl **/
    if (option_supported) /* wsf_client_enable_ssl */
    {
        axutil_property_t *ssl_server_key_prop = NULL;
        axutil_property_t *ssl_client_key_prop = NULL;
        axutil_property_t *passphrase_prop = NULL;

        ssl_server_key_prop =
            axutil_property_create_with_args (env, 0, AXIS2_TRUE, 0,
            axutil_strdup (env, ssl_server_key_filename));

        axis2_options_set_property (client_options, env, WSF_WSDL_SERVER_CERT, ssl_server_key_prop);

        ssl_client_key_prop = axutil_property_create_with_args (env, 0, AXIS2_TRUE, 0,
        axutil_strdup (env, ssl_client_key_filename));
        axis2_options_set_property (client_options, env, WSF_WSDL_KEY_FILE, ssl_client_key_prop);

        passphrase_prop = axutil_property_create_with_args (env, 0, AXIS2_TRUE, 0, axutil_strdup (env, passphrase));
        axis2_options_set_property (client_options, env, WSF_WSDL_SSL_PASSPHRASE, passphrase_prop);

        AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                        "[wsf-client] setting ssh options %s -- %s -- %s ",
                        ssl_server_key_filename, ssl_client_key_filename, passphrase);
    }

    if (axutil_strcmp(soap_action, "") != 0){
        axutil_string_t *action_string = axutil_string_create (env, soap_action);
        axis2_options_set_soap_action (client_options, env, action_string);
        AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                         "soap action present :- %s",
                         soap_action);
    }
    
    if (axutil_strcmp(wsa_action, "") != 0){
        axis2_options_set_action(client_options, env, wsa_action);
        AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                         "addressing action present :- %s",
                         wsa_action);
        axis2_svc_client_engage_module (svc_client, env, WSF_WSDL_MODULE_ADDRESSING);
    }
    
    if (*soap_version)
    {
      axis2_options_set_soap_version (client_options, env,
                      *soap_version);
      AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
               "[wsf_wsdl]soap version in wsdl mode is %d",
               *soap_version);
    }

    /* 
    Add proxy options */
    if (proxy_host && proxy_port) 
    {
        axis2_svc_client_set_proxy (svc_client, env, proxy_host, proxy_port);
        AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI,
                         "[wsf_wsdl_client] setting proxy options %s -- %s -- ", proxy_host, 
                         proxy_port);
    }

    /* 
    Default header type is POST, so only setting the HTTP_METHOD if GET */
    if (is_http_method_post == AXIS2_FALSE)
    {
        axutil_property_t *property = axutil_property_create (env);
        axutil_property_set_value (property, env, axutil_strdup (env, AXIS2_HTTP_GET));

        axis2_options_set_property (client_options, env, AXIS2_HTTP_METHOD, property);

        AXIS2_LOG_DEBUG_MSG(env->log, "[wsf_client] setting http method get property");
    }
}