axiom_node_t *
generate_request_xml(
    const axutil_env_t * env)
{
    axiom_node_t *op_node = NULL;
    axiom_element_t *op_ele = NULL;
    axiom_node_t *value_node = NULL;
    axiom_element_t *value_ele = NULL;
    axiom_namespace_t *ns1 = NULL;
    axis2_char_t *om_str = NULL;

    int value1 = 13;
    int value2 = 7;
    char value_str[64];

    ns1 =
        axiom_namespace_create(env, "http://localhost/axis/Calculator", "ns1");
    op_ele = axiom_element_create(env, NULL, "add", ns1, &op_node);

    value_ele = axiom_element_create(env, op_node, "in1", NULL, &value_node);
    sprintf(value_str, "%d", value1);
    axiom_element_set_text(value_ele, env, value_str, value_node);

    value_ele = axiom_element_create(env, op_node, "in2", NULL, &value_node);
    sprintf(value_str, "%d", value1);
    axiom_element_set_text(value_ele, env, value_str, value_node);

    printf("requesting %d  + %d \n", value1, value2);
    om_str = axiom_node_to_string(op_node, env);
    if (om_str)
        printf("\nSending OM : %s\n", om_str);

    return op_node;

}
Beispiel #2
0
  static axiom_node_t * AXIS2_CALL Axis2Service_on_fault(
    axis2_svc_skeleton_t*,
    const axutil_env_t* pEnv,
    axiom_node_t* /*pNode*/)
  {
    staff::ScopedLock tLock(m_tFaultDetailsMutex);

    std::map<unsigned long, std::string>::iterator itFault =
        m_mFaultDetails.find(staff::Thread::GetCurrentId());

    axiom_node_t* pErrorNode = NULL;
    axiom_element_t* pErrorElement = axiom_element_create(pEnv, NULL, "Exception", NULL, &pErrorNode);

    if (itFault != m_mFaultDetails.end())
    {
      axiom_element_set_text(pErrorElement, pEnv, itFault->second.c_str(), pErrorNode);
      m_mFaultDetails.erase(itFault);
    }
    else
    {
      axiom_element_set_text(pErrorElement, pEnv, "No fault details", pErrorNode);
    }

    return pErrorNode;
  }
/* build SOAP request message content using OM */
axiom_node_t *
build_om_programatically(
    const axutil_env_t *env,
    axis2_char_t *text,
    axis2_char_t *seq)
{
    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;
    axis2_char_t *buffer = NULL;
    axiom_node_t* seq_om_node = NULL;
    axiom_element_t * seq_om_ele = NULL;

    ns1 = axiom_namespace_create (env, "http://tempuri.org/", "ns1");
    ping_om_ele = axiom_element_create(env, NULL, "ping", ns1, &ping_om_node);
    text_om_ele = axiom_element_create(env, ping_om_node, "Text", ns1, &text_om_node);
    seq_om_ele = axiom_element_create(env, ping_om_node, "Sequence", ns1, &seq_om_node);
    axiom_element_set_text(text_om_ele, env, text, text_om_node);
    axiom_element_set_text(text_om_ele, env, seq, seq_om_node);
    
    buffer = axiom_node_to_string(ping_om_node, env);
    if(buffer)
    {
        printf("\nSending OM node in XML : %s \n",  buffer);
        AXIS2_FREE(env->allocator, buffer);
    }
    return ping_om_node;
}
axiom_node_t *
build_soap_body_content(
    const axutil_env_t * env,
    const axis2_char_t * operation,
    const axis2_char_t * google_key,
    const axis2_char_t * word_to_spell)
{
    axiom_node_t *google_om_node = NULL;
    axiom_element_t *google_om_ele = NULL;
    axiom_node_t *text_om_node = NULL;
    axiom_element_t *text_om_ele = NULL;
    axiom_namespace_t *ns0 = NULL,
        *ns1 = NULL,
        *ns2 = NULL,
        *ns3 = NULL;
    axiom_attribute_t *attri1 = NULL;
    axis2_char_t *buffer = NULL;

    ns0 =
        axiom_namespace_create(env, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI,
                               "soapenv");
    ns1 = axiom_namespace_create(env, "urn:GoogleSearch", "ns1");
    ns2 =
        axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema-instance",
                               "xsi");
    ns3 =
        axiom_namespace_create(env, "http://www.w3.org/1999/XMLSchema", "xsd");

    attri1 = axiom_attribute_create(env, "encodingStyle",
                                    "http://schemas.xmlsoap.org/soap/encoding/",
                                    ns0);

    google_om_ele =
        axiom_element_create(env, NULL, operation, ns1, &google_om_node);
    axiom_element_add_attribute(google_om_ele, env, attri1, google_om_node);
    axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns2);
    axiom_element_declare_namespace(google_om_ele, env, google_om_node, ns3);

    text_om_ele =
        axiom_element_create(env, google_om_node, "key", NULL, &text_om_node);
    attri1 = axiom_attribute_create(env, "type", "xsd:string", ns2);
    axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node);
    axiom_element_set_text(text_om_ele, env, google_key, text_om_node);

    text_om_ele =
        axiom_element_create(env, google_om_node, "phrase", NULL,
                             &text_om_node);
    axiom_element_add_attribute(text_om_ele, env, attri1, text_om_node);
    axiom_element_set_text(text_om_ele, env, word_to_spell, text_om_node);

    buffer = axiom_node_to_string(google_om_node, env);
    printf("%s\n", buffer);
    AXIS2_FREE (env->allocator, buffer);
    return google_om_node;
}
Beispiel #5
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/rampart/c/samples", "ns1");
    /*ns1 = axiom_namespace_create(env, "http://echo.services.wsas.wso2.org", "ns1");*/
    echo_om_ele = axiom_element_create(env, NULL, "echoIn", 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, "Hello", text_om_node);

    om_str = axiom_node_to_string(echo_om_node, env);
    if(om_str)
    {
        printf("\nSending OM : %s\n", om_str);
        AXIS2_FREE(env->allocator, om_str);
        om_str = NULL;
    }
    return echo_om_node;
}
    axiom_node_t* AXIS2_CALL
    axis2_svc_skel_IIp2Location_on_fault(axis2_svc_skeleton_t *svc_skeleton,
                  const axutil_env_t *env, axiom_node_t *node)
	{
		axiom_node_t *error_node = NULL;
		axiom_element_t *error_ele = NULL;
        axutil_error_codes_t error_code;
        axis2_svc_skel_IIp2Location_t *svc_skeleton_wrapper = NULL;

        svc_skeleton_wrapper = (axis2_svc_skel_IIp2Location_t*)svc_skeleton;

        error_code = env->error->error_number;

        if(error_code <= AXIS2_SKEL_IIP2LOCATION_ERROR_NONE ||
                error_code >= AXIS2_SKEL_IIP2LOCATION_ERROR_LAST )
        {
            error_ele = axiom_element_create(env, node, "fault", NULL,
                            &error_node);
            axiom_element_set_text(error_ele, env, "IIp2Location|http://ws.apache.org/axis2 failed",
                            error_node);
        }
        

		return error_node;
	}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_fault_text_set_text(
    axiom_soap_fault_text_t * fault_text,
    const axutil_env_t * env,
    axis2_char_t * value,
    axis2_char_t * lang)
{
    AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);

    if(fault_text->om_ele_node)
    {
        axiom_element_t *text_ele = NULL;
        text_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env);
        if(text_ele)
        {
            axiom_element_set_text(text_ele, env, value, fault_text->om_ele_node);
            if(lang)
            {
                axiom_soap_fault_text_set_lang(fault_text, env, lang);
            }
            return AXIS2_SUCCESS;
        }
    }
    return AXIS2_FAILURE;
}
Beispiel #8
0
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
service_admin_util_serialize_param(axutil_env_t *env,
								   axutil_param_t *param)
{
	axis2_char_t *name = NULL;
	axis2_char_t *value = NULL;
	void *param_value = NULL;
	axiom_node_t *param_node = NULL;
	axiom_element_t *param_ele = NULL;
	axiom_attribute_t *attri = NULL;

	name = axutil_param_get_name(param, env);
	param_value = axutil_param_get_value(param, env);
	if(name && axutil_strcmp(name, "ServiceClass") ==0)
	{
		return NULL;
	}else
	{
		value = (axis2_char_t*)param_value;
	}

	param_ele = axiom_element_create(env, NULL, "parameter", NULL, &param_node);
	
	attri = axiom_attribute_create(env, "name", name, NULL);
	axiom_element_add_attribute(param_ele, env, attri, param_node);
	if(value)
		axiom_element_set_text(param_ele, env, value, param_node);
	return param_node;
}
Beispiel #9
0
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
remote_registry_util_serialize_tag(
    const axutil_env_t *env, 
    axis2_char_t *tag)
{
    axiom_node_t *entry_node = NULL;
    axiom_element_t *entry_element = NULL;
    axiom_namespace_t *ns1 = NULL;
	axis2_char_t *content = NULL;

    axiom_node_t *content_node = NULL;
    axiom_element_t *content_element = NULL;
    axiom_node_t *summary_node = NULL;
    axiom_element_t *summary_element = NULL;
    axiom_attribute_t *type_attr = NULL;
    axis2_char_t *media_type = NULL;

    ns1 = axiom_namespace_create(env, REMOTE_REGISTRY_ATOM_NS, "ns1");
    entry_element = axiom_element_create(env, NULL, "entry", ns1, &entry_node);


    /* getting variables from the argument and rendering into an XML */

    content_element = axiom_element_create(env, entry_node, "content", ns1, &content_node);
    axiom_element_set_text(content_element, env, tag, content_node);

    type_attr = axiom_attribute_create(env, "type", "text", NULL); 
    axiom_element_add_attribute(content_element, env, type_attr, content_node);

    return entry_node;
}
Beispiel #10
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/services/echo",
                               "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, "Hello World!", text_om_node);

    om_str = axiom_node_to_string(echo_om_node, env);
    if (om_str)
        printf("\nSending OM : %s\n", om_str);
    AXIS2_FREE(env->allocator, om_str);

    return echo_om_node;
}
    axiom_node_t* AXIS2_CALL
    axis2_svc_skel_StatisticsAdmin_on_fault(axis2_svc_skeleton_t *svc_skeleton,
                  const axutil_env_t *env, axiom_node_t *node)
	{
		axiom_node_t *error_node = NULL;
		axiom_element_t *error_ele = NULL;
        axutil_error_codes_t error_code;
        axis2_svc_skel_StatisticsAdmin_t *svc_skeleton_wrapper = NULL;

        svc_skeleton_wrapper = (axis2_svc_skel_StatisticsAdmin_t*)svc_skeleton;

        error_code = env->error->error_number;

        if(error_code <= AXIS2_SKEL_STATISTICSADMIN_ERROR_NONE ||
                error_code >= AXIS2_SKEL_STATISTICSADMIN_ERROR_LAST )
        {
            error_ele = axiom_element_create(env, node, "fault", NULL,
                            &error_node);
            axiom_element_set_text(error_ele, env, "StatisticsAdmin|http://services.statistics.carbon.wso2.org failed",
                            error_node);
        }
        

		return error_node;
	}
Beispiel #12
0
axis2_status_t AXIS2_CALL
savan_client_add_sub_id_to_soap_header(
    savan_client_t *client,
    const axutil_env_t *env,
    axis2_svc_client_t *svc_client)
{
    axiom_namespace_t *ns = NULL;
    axiom_node_t *id_node = NULL;
    axiom_element_t *id_elem = NULL;

    /* Create a node with the subscription id and attach it as a soap header
     * to the service client */

    ns = axiom_namespace_create(env, EVENTING_NAMESPACE, EVENTING_NS_PREFIX);
    id_elem = axiom_element_create(env, NULL, ELEM_NAME_ID, ns, &id_node);
    if (!id_elem)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] [client] Failed to "
            "create element for Identifier node");
        return AXIS2_FAILURE;
    }

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "client->sub_id:%s\n", client->sub_id);
    axiom_element_set_text(id_elem, env, client->sub_id, id_node);

    axis2_svc_client_add_header(svc_client, env, id_node);

    return AXIS2_SUCCESS;

}
Beispiel #13
0
/* Builds the response content */
axiom_node_t *
build_response1(
    const axutil_env_t * env,
    axis2_char_t * text)
{
    axiom_node_t *mtom_om_node = NULL;
    axiom_element_t *mtom_om_ele = NULL;
    axiom_node_t *om_node = NULL;
    axiom_element_t *om_ele = NULL;

   
    axiom_namespace_t *ns1 = NULL;

    ns1 =
        axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples",
                               "ns1");

    mtom_om_ele =
        axiom_element_create(env, NULL, "response", ns1, &mtom_om_node);

    om_ele  = axiom_element_create(env, mtom_om_node, "string", NULL, &om_node);
    
    axiom_element_set_text(mtom_om_ele, env, text, om_node);
   

    return mtom_om_node;
}
Beispiel #14
0
/**
* Creates <ds:X509IssuerName> element
*/
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
oxs_token_build_issuer_name_element(
    const axutil_env_t *env,
    axiom_node_t *parent,
    axis2_char_t* value)
{
    axiom_node_t *issuer_name_node = NULL;
    axiom_element_t *issuer_name_ele = NULL;
    axiom_namespace_t *ns_obj = NULL;

    ns_obj = axiom_namespace_create(env, OXS_DSIG_NS, OXS_DS);

    issuer_name_ele = axiom_element_create(
        env, parent, OXS_NODE_X509_ISSUER_NAME, ns_obj, &issuer_name_node);
    if (!issuer_name_ele)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating X509IssuerName element.");
        axiom_namespace_free(ns_obj, env);
        return NULL;
    }

    if (value)
    {
         axiom_element_set_text(issuer_name_ele, env, value, issuer_name_node);
    }

    return issuer_name_node;
}
Beispiel #15
0
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
remote_registry_comment_serialize(
    remote_registry_comment_t *comment,
    const axutil_env_t *env)
{
    axiom_node_t *entry_node = NULL;
    axiom_element_t *entry_element = NULL;
    axiom_namespace_t *ns1 = NULL;
    axis2_char_t *author = NULL;
    axis2_char_t *content = NULL;

    ns1 = axiom_namespace_create(env, REMOTE_REGISTRY_ATOM_NS, "ns1");
    entry_element = axiom_element_create(env, NULL, "entry", ns1, &entry_node);

    /* getting variables from the structure and rendering into an XML */

    author = remote_registry_comment_get_user(comment, env);
    if(author)
    {
        axiom_node_t *author_node = NULL;
        axiom_node_t *name_node = NULL;
        axiom_element_t *name_ele = NULL;

        axiom_element_create(env, entry_node, "author", ns1, &author_node);
        name_ele = axiom_element_create(env, author_node, "name", ns1, &name_node);

        axiom_element_set_text(name_ele, env, author, name_node);
    }

    content = remote_registry_comment_get_text(comment, env);
    if(content)
    {
        axiom_node_t *content_node = NULL;
        axiom_element_t *content_element = NULL;
        axiom_attribute_t *type_attr = NULL;
        axis2_char_t *media_type = NULL;

        content_element = axiom_element_create(env, entry_node, "content", ns1, &content_node);
        axiom_element_set_text(content_element, env, content, content_node);

        type_attr = axiom_attribute_create(env, "type", "text", NULL); 
        axiom_element_add_attribute(content_element, env, type_attr, content_node);
    }

    return entry_node;
}
    axiom_node_t* AXIS2_CALL
    axis2_svc_skel_TraderExchange_on_fault(axis2_svc_skeleton_t *svc_skeleton,
                  const axutil_env_t *env, axiom_node_t *node)
	{
		axiom_node_t *error_node = NULL;
		axiom_element_t *error_ele = NULL;
		error_ele = axiom_element_create(env, node, "fault", NULL,
    					&error_node);
		axiom_element_set_text(error_ele, env, "TraderExchange|http://www.wso2.org failed",
    					error_node);
		return error_node;
	}
Beispiel #17
0
/* build SOAP request message content using OM */
axiom_node_t *
build_om_programatically_mtom(
    const axutil_env_t * env)
{
    axiom_node_t *mtom_om_node = NULL;
    axiom_element_t *mtom_om_ele = NULL;
    axiom_node_t *image_om_node = NULL;
    axiom_element_t *image_om_ele = NULL;
    axiom_node_t *file_om_node = NULL;
    axiom_element_t *file_om_ele = NULL;
    axiom_node_t *data_om_node = NULL;
    axiom_text_t *data_text = NULL;
    axiom_namespace_t *ns1 = NULL;
    axis2_char_t *om_str = NULL;
    const axis2_char_t *image_name = "E:/src/C/Axis2C/build/deploy/samples/bin/resources/axis2.jpg";
    const axis2_char_t *to_save_name = "test.jpg";
    axis2_bool_t optimized = AXIS2_TRUE;

    axiom_data_handler_t *data_handler = NULL;

    ns1 = axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom", "ns1");
    mtom_om_ele = axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);

    file_om_ele = axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node);
    axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);

    image_om_ele = axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);

    /* This is when we directly give file name */

    data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");

    /* Uncomment following to set a callback instead of a file */

    /*data_handler = axiom_data_handler_create(env, NULL, "image/jpeg");
     axiom_data_handler_set_data_handler_type(data_handler, env, AXIOM_DATA_HANDLER_TYPE_CALLBACK);
     axiom_data_handler_set_user_param(data_handler, env, (void *)image_name);*/

    data_text
        = axiom_text_create_with_data_handler(env, image_om_node, data_handler, &data_om_node);

    axiom_text_set_optimize(data_text, env, optimized);
    /*axiom_text_set_is_swa(data_text, env, AXIS2_TRUE);*/
    om_str = axiom_node_to_string(mtom_om_node, env);
    if(om_str)
    {
        printf("%s", om_str);
        AXIS2_FREE(env->allocator, om_str);
    }
    return mtom_om_node;
}
Beispiel #18
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;
}
Beispiel #19
0
axis2_status_t
axis2_addr_out_handler_process_any_content_type(
    const axutil_env_t * env,
    axis2_any_content_type_t * reference_values,
    axiom_node_t * parent_ele_node,
    const axis2_char_t * addr_ns)
{
    axutil_hash_t *value_ht = NULL;
    axutil_hash_index_t *hash_index = NULL;

    if(reference_values)
    {
        const void *key = NULL;
        void *val = NULL;
        axis2_ssize_t len = 0;
        value_ht = axis2_any_content_type_get_value_map(reference_values, env);
        if(!value_ht)
        {
            return AXIS2_FAILURE;
        }

        for(hash_index = axutil_hash_first(value_ht, env); hash_index; hash_index
            = axutil_hash_next(env, hash_index))
        {
            axutil_hash_this(hash_index, &key, &len, &val);
            if(key)
            {
                axiom_node_t *node = NULL;
                axiom_element_t *ele = NULL;
                ele = axiom_element_create(env, parent_ele_node, key, NULL, &node);
                if(ele)
                {
                    if(!axutil_strcmp(AXIS2_WSA_NAMESPACE, addr_ns))
                    {
                        axiom_namespace_t *addr_ns_obj = NULL;
                        axiom_attribute_t *att = NULL;
                        addr_ns_obj
                            = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                        att = axiom_attribute_create(env,
                            AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
                            AXIS2_WSA_TYPE_ATTRIBUTE_VALUE, addr_ns_obj);
                    }
                    axiom_element_set_text(ele, env, val, node);
                }
            }
        }
    }
    return AXIS2_SUCCESS;
}
Beispiel #20
0
/* On fault, handle the fault */
axiom_node_t* AXIS2_CALL
echo_on_fault(axis2_svc_skeleton_t *svc_skeli,
              const axutil_env_t *env, axiom_node_t *node)
{
    /* Here we are just setting a simple error message inside an element
     * called 'EchoServiceError'
     */
    axiom_node_t *error_node = NULL;
    axiom_node_t *text_node = NULL;
    axiom_element_t *error_ele = NULL;

    error_ele = axiom_element_create(env, NULL, "EchoServiceError", NULL,  &error_node);
    axiom_element_set_text(error_ele, env, "Echo service failed ", text_node);
    return error_node;
}
Beispiel #21
0
axiom_node_t *
axis2_addr_out_handler_process_string_info(
    const axutil_env_t * env,
    const axis2_char_t * value,
    const axis2_char_t * type,
    axiom_soap_header_t ** soap_header_p,
    const axis2_char_t * addr_ns,
	axis2_bool_t set_must_understand)
{
    axiom_soap_header_t *soap_header = NULL;
    axiom_soap_header_block_t *header_block = NULL;
    axiom_node_t *header_block_node = NULL;
    axiom_element_t *header_block_ele = NULL;

    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, value, NULL);
    AXIS2_PARAM_CHECK(env->error, type, NULL);
    AXIS2_PARAM_CHECK(env->error, soap_header_p, NULL);
    AXIS2_PARAM_CHECK(env->error, addr_ns, NULL);

    soap_header = *(soap_header_p);

    if(value && *value)
    {
        axiom_namespace_t *addr_ns_obj = NULL;
        addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
        header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
        header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
        header_block_ele = (axiom_element_t *)axiom_node_get_data_element(header_block_node, env);
        if(header_block_ele)
        {
            axiom_namespace_t *dec_ns = NULL;
            axiom_element_set_text(header_block_ele, env, value, header_block_node);
            dec_ns = axiom_element_find_declared_namespace(header_block_ele, env, addr_ns,
                AXIS2_WSA_DEFAULT_PREFIX);
            if(!dec_ns)
            {
                axiom_namespace_free(addr_ns_obj, env);
                addr_ns_obj = NULL;
            }
        }
		if(set_must_understand)
		{
			axiom_soap_header_block_set_must_understand_with_bool(header_block, env, AXIS2_TRUE);
		}
    }
    return header_block_node;
}
Beispiel #22
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_fault_value_set_text(
    axiom_soap_fault_value_t * fault_value,
    const axutil_env_t * env,
    axis2_char_t * text)
{
    AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE);
    if(fault_value->om_ele_node && axiom_node_get_node_type(fault_value->om_ele_node, env)
        == AXIOM_ELEMENT)
    {
        axiom_element_t *om_ele = NULL;
        om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_value->om_ele_node, env);
        return axiom_element_set_text(om_ele, env, text, fault_value->om_ele_node);
    }
    return AXIS2_FAILURE;
}
Beispiel #23
0
/**
 * Creates <wsc:Length> element
 */
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
oxs_token_build_length_element(
    const axutil_env_t *env,
    axiom_node_t *parent,
    int length, 
    axis2_char_t *wsc_ns_uri)
{
    axiom_node_t *length_node = NULL;
    axiom_element_t *length_ele = NULL;
    axis2_status_t ret;
    axiom_namespace_t *ns_obj = NULL;
    axis2_char_t *length_val = NULL;

    if(!wsc_ns_uri)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[rampart]Error creating %s Token element. SecConv namespace uri is not valid.", 
            OXS_NODE_LENGTH);
        return NULL;
    }

    ns_obj = axiom_namespace_create(env, wsc_ns_uri, OXS_WSC);
    length_ele = axiom_element_create(env, parent, OXS_NODE_LENGTH, ns_obj, &length_node);
    if(!length_ele)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[rampart]Error creating %s Token element.", OXS_NODE_LENGTH);
        axiom_namespace_free(ns_obj, env);
        return NULL;
    }

    if(length > 0)
    {
        length_val = (axis2_char_t *) AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 32);
        sprintf(length_val, "%d", length );
    }
 
    if(length_val)
    {
        ret  = axiom_element_set_text(length_ele, env, length_val, length_node);
		AXIS2_FREE(env->allocator, length_val);
    }

    return length_node;
}
Beispiel #24
0
/* Builds the response content */
axiom_node_t *
build_om_programatically(
    const axutil_env_t * env,
    axis2_char_t * text)
{
    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;

    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, text, text_om_node);
	axiom_namespace_free(ns1, env);
    return echo_om_node;
}
Beispiel #25
0
/** Add a node with an element to root_node, either as child or as sibling.
 *   The element name is in the same namespace as the root node's name.
 *   The element may optionally include one attribute; if no attribute
 *   is desired then pass 'NULL'.
 *
 *  Example with attribute:
 *     node_id.name="foo";     node.value="bar";
 *     attribute.name="attr";  attribute.value="Zar";
 *  Result :  <ns:foo attr="Zar">bar</ns:foo>
 *
 * @param env
 * @param root_node
 * @param node_id
 *   node_id.name:  name of element to be added,
 *   node_id.value: text of element
 * @param attribute optional Name_value pair for setting an attribute,
 *   may be NULL.
 * @param sibling 1: add as sibling, 0: add as child.
 * @param whitespace: whitespace added before the newly added element (the
 *  newly added element is indented by this space.
 * @return ptr to the the newly added node.
 */
static axiom_node_t *rp_add_node(
    const axutil_env_t *env,
    axiom_node_t       *root_node,
    Name_value         *node_id,
    Name_value         *attribute,
    int                sibling,
    const axis2_char_t *whitespace
 )
{

	sp_add_whspace(env, root_node, whitespace);

    axiom_namespace_t * ns = rp_get_namespace (env, root_node);

    axiom_node_t    *new_node = axiom_node_create(env);
    axiom_element_t *new_ele =
      axiom_element_create(env, NULL, node_id->name, ns, &new_node);
    if (NULL != node_id->value)
    {
    	axiom_element_set_text(new_ele, env, node_id->value, new_node);
    }

    if (NULL != attribute)
    {
        axiom_attribute_t *attr =
          axiom_attribute_create (env, attribute->name, attribute->value, NULL);
        axiom_element_add_attribute (new_ele, env, attr, new_node);
    }

    axis2_status_t success = (
    		sibling ?
    				axiom_node_insert_sibling_after (root_node, env, new_node) :
    				axiom_node_add_child            (root_node, env, new_node)
    );

    if (AXIS2_SUCCESS != success)
    {
    	rp_log_error(env, "*** S2P(%s:%d): Failed to add node name='%s'\n",
    			__FILE__, __LINE__, node_id->name);
    }

    return new_node;
}
void
axis2_addr_in_create_fault_envelope(
    const axutil_env_t * env,
    const axis2_char_t * header_name,
    const axis2_char_t * addr_ns_str,
    axis2_msg_ctx_t * msg_ctx)
{
    axiom_soap_envelope_t *envelope = NULL;
    axutil_array_list_t *sub_codes = NULL;
    int soap_version = AXIOM_SOAP12;
    axiom_node_t *text_om_node = NULL;
    axiom_element_t *text_om_ele = NULL;
    axiom_namespace_t *ns1 = NULL;

    if (axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
    {
        soap_version = AXIOM_SOAP11;
    }

    ns1 = axiom_namespace_create(env, addr_ns_str, AXIS2_WSA_DEFAULT_PREFIX);
    text_om_ele =
        axiom_element_create(env, NULL, "ProblemHeaderQName", ns1,
                             &text_om_node);
    axiom_element_set_text(text_om_ele, env, header_name, text_om_node);

    sub_codes = axutil_array_list_create(env, 2);
    if (sub_codes)
    {
        axutil_array_list_add(sub_codes, env, "wsa:InvalidAddressingHeader");
        axutil_array_list_add(sub_codes, env, "wsa:InvalidCardinality");
    }

    envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env,
                                                                      "soapenv:Sender",
                                                                      "A header representing a Message Addressing Property is not valid and the message cannot be processed",
                                                                      soap_version,
                                                                      sub_codes,
                                                                      text_om_node);
    axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, envelope);
    axis2_msg_ctx_set_wsa_action(msg_ctx, env,
                                 "http://www.w3.org/2005/08/addressing/fault");
    return;
}
Beispiel #27
0
axiom_node_t * AXIS2_CALL
create_saml_assertion(const axutil_env_t *env)
{
    saml_assertion_t *assertion = NULL;
    saml_attr_stmt_t *attr_stmt = NULL;
    saml_subject_t *subject = NULL;
    saml_named_id_t *named_id = NULL;
    saml_attr_t *attr = NULL;
    axiom_node_t *attr_val = NULL;
    axiom_element_t *e = NULL;
    saml_stmt_t *stmt = NULL;

    assertion = saml_assertion_create(env);
    attr_stmt = saml_attr_stmt_create(env);
    subject = saml_subject_create(env);

    saml_assertion_set_issue_instant(assertion, env, axutil_date_time_create(env));
    saml_assertion_set_issuer(assertion, env, "www.mrt.ac.lk");
    saml_assertion_set_minor_version(assertion, env, 1);

    saml_subject_add_confirmation(subject, env, SAML_SUB_CONFIRMATION_SENDER_VOUCHES);

    named_id = saml_named_id_create(env);
    saml_named_id_set_name(named_id, env, "cse07");
    saml_subject_set_named_id(subject, env, named_id);

    attr = saml_attr_create(env);
    saml_attr_set_name(attr, env, "csestudent");
    saml_attr_set_namespace(attr, env, "www.mrt.ac.lk/cse");
    e = axiom_element_create(env, NULL, "noofstudent", NULL, &attr_val);
    axiom_element_set_text(e, env, "10", attr_val);
    saml_attr_add_value(attr, env, attr_val); 
   
    saml_attr_stmt_set_subject(attr_stmt, env, subject);
    saml_attr_stmt_add_attribute(attr_stmt, env, attr);

    stmt = saml_stmt_create(env);
    saml_stmt_set_stmt(stmt, env, attr_stmt, SAML_STMT_ATTRIBUTESTATEMENT);

    saml_assertion_add_statement(assertion, env, stmt);
    return saml_assertion_to_om(assertion, NULL, env);
}
Beispiel #28
0
/* build SOAP request message content using OM */
axiom_node_t *
build_om_payload_for_echo_svc(
   const axutil_env_t *env,
   axis2_char_t *text)
{
    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 *ns = NULL;

    ns = "http://tempuri.org/";
    
    ns1 = axiom_namespace_create (env, ns, "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, text, text_om_node);
    
    return echo_om_node;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_fault_role_set_role_value(
    axiom_soap_fault_role_t * fault_role,
    const axutil_env_t * env,
    axis2_char_t * uri)
{
    axiom_element_t *role_ele = NULL;

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

    if(!fault_role->om_ele_node)
    {
        return AXIS2_FAILURE;
    }
    role_ele = (axiom_element_t *)axiom_node_get_data_element(fault_role->om_ele_node, env);

    if(role_ele)
    {
        return axiom_element_set_text(role_ele, env, uri, fault_role->om_ele_node);
    }
    return AXIS2_FAILURE;
}
/* build SOAP request message content using OM */
axiom_node_t *
build_om_payload_for_echo_svc(
    const axutil_env_t * env,
    const axis2_char_t * echo_text)
{
    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;

    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, echo_text, text_om_node);

    return echo_om_node;
}