/** * Creates <ds:Transform> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_transform_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* algorithm) { axiom_node_t *transform_node = NULL, *tr_para_node = NULL, *tr_can_node = NULL; axiom_element_t *transform_ele = NULL, *tr_para_ele = NULL, *tr_can_ele = NULL; axiom_attribute_t *algo_attr = NULL; int ret; axiom_namespace_t *ns_obj = NULL; ns_obj = axiom_namespace_create(env, OXS_DSIG_NS, OXS_DS); transform_ele = axiom_element_create(env, parent, OXS_NODE_TRANSFORM, ns_obj, &transform_node); if (!transform_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating transform element."); axiom_namespace_free(ns_obj, env); return NULL; } /* If transform algorithm is NULL then use the default */ if(!algorithm) { algorithm = (axis2_char_t*)OXS_HREF_XML_EXC_C14N; } algo_attr = axiom_attribute_create(env, OXS_ATTR_ALGORITHM, algorithm, NULL); ret = axiom_element_add_attribute(transform_ele, env, algo_attr, transform_node); if (!axutil_strcmp(algorithm, OXS_HREF_TRANSFORM_STR_TRANSFORM)) { ns_obj = axiom_namespace_create(env, OXS_WSSE_NS, OXS_WSSE); tr_para_ele = axiom_element_create( env, NULL, OXS_NODE_TRANSFORMATIONPARAMETERS, ns_obj, &tr_para_node); if (!tr_para_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating TransformationParameters element."); axiom_namespace_free(ns_obj, env); return NULL; } ns_obj = axiom_namespace_create(env, OXS_DSIG_NS, OXS_DS); tr_can_ele = axiom_element_create( env, tr_para_node, OXS_NODE_CANONICALIZATION_METHOD, ns_obj, &tr_can_node); if (!tr_can_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating CanonicalizationMethod element."); axiom_namespace_free(ns_obj, env); return NULL; } algo_attr = axiom_attribute_create(env, OXS_ATTR_ALGORITHM, OXS_HREF_XML_EXC_C14N, NULL); axiom_element_add_attribute(tr_can_ele, env, algo_attr, tr_can_node); axiom_node_add_child(transform_node, env, tr_para_node); } return transform_node; }
//----------------------------------------------------------------------------- // This function is invoked via sp_func_at_nodes() from sp_add_soapurl() static int f_add_soapurl( const axutil_env_t * env, axiom_node_t *target_node, void *arg3) { // // Find the paths // HTTP // and add the SOAP capability. // If none found it is not considered an error. // /* <ows:Post xlink:type="simple" xlink:href="http://SERVER_UNDEFINED/service"> <ows:Constraint name="PostEncoding"> <ows:AllowedValues> <ows:Value>SOAP</ows:Value> </ows:AllowedValues> </ows:Constraint> */ axis2_char_t *soap_ops_url = (axis2_char_t *) arg3; if (NULL == soap_ops_url) { soap_ops_url = ""; } axiom_node_t *top_node = rp_find_named_child(env, target_node, "HTTP", 1); if (NULL == top_node) return 0; axiom_namespace_t * root_ns = rp_get_namespace (env, top_node); axiom_node_t *post_node = axiom_node_create(env); axiom_element_t *post_ele = axiom_element_create(env, top_node, "Post", root_ns, &post_node); axiom_namespace_t *xlink_ns = axiom_namespace_create( env, SP_XLINK_NAMESPACE_STR, "xlink"); axiom_attribute_t *attr = axiom_attribute_create (env, "type", "simple", xlink_ns); axiom_element_add_attribute (post_ele, env, attr, post_node); attr = axiom_attribute_create (env, "href", soap_ops_url, xlink_ns); axiom_element_add_attribute (post_ele, env, attr, post_node); Name_value c_nv; c_nv.name = "Constraint"; c_nv.value = NULL; Name_value p_nv; p_nv.name = "name"; p_nv.value = "PostEncoding"; axiom_node_t *c_node = rp_add_child(env, post_node, &c_nv, &p_nv, NULL); axiom_node_t *a_node = rp_add_child_el(env, c_node, "AllowedValues", NULL); c_nv.name = "Value"; c_nv.value = "SOAP"; rp_add_child(env, a_node, &c_nv, NULL, NULL); return 0; }
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; }
/** * Creates <wsc:DerivedKeyToken> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_derived_key_token_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* id, axis2_char_t* algo, axis2_char_t* wsc_ns_uri) { axiom_node_t *derived_key_token_node = NULL; axiom_element_t *derived_key_token_ele = NULL; axiom_attribute_t *algo_att = NULL; axiom_attribute_t *id_attr = NULL; int ret; axiom_namespace_t *ns_obj = NULL; axiom_namespace_t *ns = 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_DERIVED_KEY_TOKEN); return NULL; } ns_obj = axiom_namespace_create(env, wsc_ns_uri, OXS_WSC); ns = axiom_namespace_create(env, RAMPART_WSU_XMLNS, OXS_WSU); derived_key_token_ele = axiom_element_create( env, parent, OXS_NODE_DERIVED_KEY_TOKEN, ns_obj, &derived_key_token_node); if (!derived_key_token_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating %s Token element", OXS_NODE_DERIVED_KEY_TOKEN); axiom_namespace_free(ns_obj, env); axiom_namespace_free(ns, env); return NULL; } if(algo) { algo_att = axiom_attribute_create(env, OXS_ATTR_ALGORITHM, algo, NULL); ret = axiom_element_add_attribute( derived_key_token_ele, env, algo_att, derived_key_token_node); } if (!id) { id = oxs_util_generate_id(env,(axis2_char_t*)OXS_DERIVED_ID); } id_attr = axiom_attribute_create(env, OXS_ATTR_ID, id,ns); ret = axiom_element_add_attribute(derived_key_token_ele, env, id_attr, derived_key_token_node); return derived_key_token_node; }
/** * Creates <wsse:Embedded> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_embedded_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* id) { axiom_node_t *embedded_node = NULL; axiom_element_t *embedded_ele = NULL; axiom_attribute_t *id_attr = NULL; int ret; axiom_namespace_t *ns_obj = NULL; ns_obj = axiom_namespace_create(env, OXS_WSSE_NS, OXS_WSSE); embedded_ele = axiom_element_create(env, parent, OXS_NODE_EMBEDDED, ns_obj, &embedded_node); if(!embedded_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating embedded element."); axiom_namespace_free(ns_obj, env); return NULL; } if(!id) { id = oxs_util_generate_id(env,(axis2_char_t*)OXS_EMBEDDED_ID); } id_attr = axiom_attribute_create(env, OXS_ATTR_ID, id, NULL); ret = axiom_element_add_attribute(embedded_ele, env, id_attr, embedded_node); return embedded_node; }
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, ¶m_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; }
char *test_endpoint_serialize() { axiom_namespace_t *ns = NULL; axiom_node_t *subs_node = NULL; axiom_element_t *subs_elem = NULL; axiom_node_t *endpoint_node = NULL; axiom_element_t *endpoint_elem = NULL; axiom_node_t *addr_node = NULL; axiom_element_t *addr_elem = NULL; axiom_attribute_t *url_attr = NULL; char *content = NULL; const axutil_env_t *env = NULL; axis2_char_t *nsurl = "http://ws.apache.org/ns/synapse"; axis2_char_t *ns_prefix = "syn"; axis2_char_t *notifyto = "http://localhost:9000/services/SimpleStockQuoteService"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); /* Format of the message is as * <subscription><syn:endpoint xmlns:syn="http://ws.apache.org/ns/synapse"><syn:address uri= * "http://localhost:9000/services/SimpleStockQuoteService" /></syn:endpoint></subscription> */ printf("\ncontent1:<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); ns = axiom_namespace_create (env, nsurl, ns_prefix); subs_elem = axiom_element_create(env, NULL, "subscription", NULL, &subs_node); endpoint_elem = axiom_element_create(env, subs_node, "endpoint", ns, &endpoint_node); addr_elem = axiom_element_create(env, endpoint_node, "address", ns, &addr_node); url_attr = axiom_attribute_create(env, "url", notifyto, NULL); axiom_element_add_attribute(addr_elem, env, url_attr, addr_node); content = (char *) axiom_node_to_string(subs_node, env); printf("\n\ncontent2:%s\n\n", content); return content; }
AXIS2_EXTERN axiom_node_t* AXIS2_CALL saml_authentication_query_to_om(saml_authentication_query_t *authentication_query, axiom_node_t *parent, const axutil_env_t *env) { axiom_element_t *e = NULL; axiom_node_t *n = NULL; axiom_namespace_t *ns = NULL; axiom_attribute_t *attr = NULL; ns = axiom_namespace_create(env, SAML_PROTOCOL_NMSP, SAML_PROTOCOL_PREFIX); e = axiom_element_create(env, parent, SAML_AUTHENTICATION_QUERY, ns, &n); if(e) { if(authentication_query->subject) saml_subject_to_om(authentication_query->subject, n, env); if(authentication_query->auth_method) { attr = axiom_attribute_create(env, SAML_AUTHENTICATION_METHOD, authentication_query->auth_method, NULL); axiom_element_add_attribute(e, env, attr, n); } } return n; }
/** * Creates <ds:CanonicalizationMethod> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_c14n_method_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* algorithm) { axiom_node_t *c14n_method_node = NULL; axiom_element_t *c14n_method_ele = NULL; axiom_attribute_t *algo_attr = NULL; axiom_namespace_t *ns_obj = NULL; ns_obj = axiom_namespace_create(env, OXS_DSIG_NS, OXS_DS); c14n_method_ele = axiom_element_create( env, parent, OXS_NODE_CANONICALIZATION_METHOD, ns_obj, &c14n_method_node); if (!c14n_method_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating %s Token element.", OXS_NODE_CANONICALIZATION_METHOD); axiom_namespace_free(ns_obj, env); return NULL; } /* If c14n algorithm is NULL then use the default */ if(!algorithm) { algorithm = (axis2_char_t*)OXS_HREF_XML_EXC_C14N; } algo_attr = axiom_attribute_create(env, OXS_ATTR_ALGORITHM, algorithm, NULL); axiom_element_add_attribute(c14n_method_ele, env, algo_attr, c14n_method_node); return c14n_method_node; }
axis2_status_t create_username_node(neethi_options_t *options, const axutil_env_t *env, axiom_node_t *parent_node) { axiom_node_t *signsupport_node = NULL; axiom_node_t *signsupport_policy_node = NULL; axiom_node_t *ut_node = NULL; axiom_element_t *ut_ele = NULL; axiom_attribute_t *attr = NULL; /*axiom_namespace_t *sp_ns = NULL;*/ (void)options; /*sp_ns = axiom_namespace_create(env, RP_SP_NS_12, RP_SP_PREFIX);*/ axiom_element_create(env, parent_node, RP_SIGNED_SUPPORTING_TOKENS, sp_ns, &signsupport_node); signsupport_policy_node = neethi_options_create_policy_node(env, signsupport_node); ut_ele = axiom_element_create(env, signsupport_policy_node, RP_USERNAME_TOKEN, sp_ns, &ut_node); if(ut_ele) { attr = axiom_attribute_create(env, RP_INCLUDE_TOKEN, RP_INCLUDE_ALWAYS, sp_ns); axiom_element_add_attribute(ut_ele, env, attr, ut_node); } else { return AXIS2_FAILURE; } return AXIS2_SUCCESS; }
/** * Adds an attribute to a particular node * @param env Environment. MUST NOT be NULL * @param node the node where the attibute will be added * @param attribute_ns the the ns_prefix of the attribute * @param attribute_ns_uri the uri of the attribute * @param attribute the localname of the attribute * @param value the value of the attribute * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE */ AXIS2_EXTERN axis2_status_t AXIS2_CALL oxs_axiom_add_attribute( const axutil_env_t *env, axiom_node_t* node, axis2_char_t* attribute_ns, axis2_char_t* attribute_ns_uri, axis2_char_t* attribute, axis2_char_t* value) { axiom_attribute_t *attr = NULL; axiom_element_t *ele = NULL; axis2_status_t status = AXIS2_FAILURE; axiom_namespace_t *ns = NULL; if(attribute_ns_uri) { ns = axiom_namespace_create(env, attribute_ns_uri, attribute_ns); } ele = axiom_node_get_data_element(node, env); attr = axiom_attribute_create(env, attribute , value, ns); if((!attr) && ns) { axiom_namespace_free(ns, env); } status = axiom_element_add_attribute(ele, env, attr, node); return status; }
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; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap_fault_text_set_lang( axiom_soap_fault_text_t * fault_text, const axutil_env_t * env, const axis2_char_t * lang) { int status = AXIS2_SUCCESS; axiom_element_t *om_ele = NULL; AXIS2_PARAM_CHECK(env->error, lang, AXIS2_FAILURE); if(fault_text->lang_attribute) { axis2_char_t *attr_lang = NULL; attr_lang = axiom_attribute_get_value(fault_text->lang_attribute, env); if(attr_lang) { if(axutil_strcmp(attr_lang, lang) == 0) { /** this attribute already exists */ return AXIS2_SUCCESS; } } axiom_attribute_set_value(fault_text->lang_attribute, env, lang); return AXIS2_SUCCESS; } fault_text->lang_attribute = axiom_attribute_create(env, AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, lang, fault_text-> lang_namespace); if(!fault_text->lang_attribute) { return AXIS2_FAILURE; } if(!fault_text->om_ele_node) { return AXIS2_FAILURE; } om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); if(!om_ele) { return AXIS2_FAILURE; } status = axiom_element_add_attribute(om_ele, env, fault_text->lang_attribute, fault_text->om_ele_node); if(status == AXIS2_SUCCESS) { fault_text->lang_ns_used = AXIS2_TRUE; } else { axiom_attribute_free(fault_text->lang_attribute, env); fault_text->lang_attribute = NULL; } return status; }
axis2_status_t create_protection_node( neethi_options_t *options, const axutil_env_t *env, axiom_node_t *parent_node) { axiom_node_t *in_token_node = NULL; axiom_node_t *in_policy_node = NULL; axiom_node_t *x509_node = NULL; axiom_node_t *x509_policy_node = NULL; axiom_node_t *x509_type_node = NULL; axiom_element_t *parent_ele = NULL; axiom_element_t *in_token_ele = NULL; axiom_element_t *x509_ele = NULL; axiom_attribute_t *attr = NULL; parent_ele = axiom_node_get_data_element(parent_node, env); if(!parent_ele) { return AXIS2_FAILURE; } in_token_ele = axiom_element_create(env, parent_node, RP_PROTECTION_TOKEN, sp_ns, &in_token_node); if(!in_token_ele) { return AXIS2_FAILURE; } in_policy_node = neethi_options_create_policy_node(env, in_token_node); x509_ele = axiom_element_create(env, in_policy_node, RP_X509_TOKEN, sp_ns, &x509_node); if(!x509_ele) { return AXIS2_FAILURE; } attr = axiom_attribute_create(env, RP_INCLUDE_TOKEN, RP_INCLUDE_ALWAYS_TO_RECIPIENT, sp_ns); axiom_element_add_attribute(x509_ele, env, attr, x509_node); x509_policy_node = neethi_options_create_policy_node(env, x509_node); if(x509_policy_node) { if(options->keyidentifier && options->server_side) { axiom_node_t *key_identifier_node = NULL; axiom_element_create(env, x509_policy_node, options->keyidentifier, sp_ns, &key_identifier_node); } } axiom_element_create(env, x509_policy_node, RP_WSS_X509_V3_TOKEN_10, sp_ns, &x509_type_node); return AXIS2_SUCCESS; }
/** * Creates <xenc:EncryptedData> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_encrypted_data_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* type_attribute, axis2_char_t* id) { axiom_node_t *encrypted_data_node = NULL; axiom_element_t *encrypted_data_ele = NULL; axiom_attribute_t *type_attr = NULL; axiom_attribute_t *id_attr = NULL; axiom_namespace_t *ns_obj = NULL; ns_obj = axiom_namespace_create(env, OXS_ENC_NS, OXS_XENC); encrypted_data_ele = axiom_element_create( env, parent, OXS_NODE_ENCRYPTED_DATA, ns_obj, &encrypted_data_node); if(!encrypted_data_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating encrypted data element."); axiom_namespace_free(ns_obj, env); return NULL; } if (type_attribute) { type_attr = axiom_attribute_create(env, OXS_ATTR_TYPE, type_attribute, NULL); axiom_element_add_attribute(encrypted_data_ele, env, type_attr, encrypted_data_node); } if(!id) { id = oxs_util_generate_id(env, (axis2_char_t*)OXS_ENCDATA_ID); } id_attr = axiom_attribute_create(env, OXS_ATTR_ID, id, NULL ); axiom_element_add_attribute(encrypted_data_ele, env, id_attr, encrypted_data_node); return encrypted_data_node; }
/** * Creates <wsse:Reference> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_reference_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t *ref, axis2_char_t *value_type) { axiom_node_t *reference_node = NULL; axiom_element_t *reference_ele = NULL; axiom_attribute_t *ref_attr = NULL; axiom_attribute_t *value_type_attr = NULL; int ret; axiom_namespace_t *ns_obj = NULL; ns_obj = axiom_namespace_create(env, OXS_WSSE_NS, OXS_WSSE); reference_ele = axiom_element_create(env, parent, OXS_NODE_REFERENCE, ns_obj, &reference_node); if (!reference_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating Reference element."); axiom_namespace_free(ns_obj, env); return NULL; } if(!ref) { ref = ""; } ref_attr = axiom_attribute_create(env, OXS_ATTR_URI , ref, NULL); ret = axiom_element_add_attribute(reference_ele, env, ref_attr, reference_node); if(value_type) { value_type_attr = axiom_attribute_create(env, OXS_ATTR_VALUE_TYPE , value_type, NULL); ret = axiom_element_add_attribute(reference_ele, env, value_type_attr, reference_node); } return reference_node; }
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; }
AXIS2_EXTERN axiom_node_t* AXIS2_CALL saml_autho_decision_query_to_om(saml_autho_decision_query_t *autho_decision_query, axiom_node_t *parent, const axutil_env_t *env) { int size = 0, i = 0; axiom_element_t *e = NULL; axiom_node_t *n = NULL; axiom_namespace_t *ns = NULL; axiom_attribute_t *attr = NULL; saml_action_t *action; ns = axiom_namespace_create(env, SAML_PROTOCOL_NMSP, SAML_PROTOCOL_PREFIX); e = axiom_element_create(env, parent, SAML_AUTHORIZATION_DECISION_QUERY, ns, &n); if(e) { if(autho_decision_query->subject) saml_subject_to_om(autho_decision_query->subject, n, env); if(autho_decision_query->resource) { attr = axiom_attribute_create(env, SAML_RESOURCE, autho_decision_query->resource, NULL); axiom_element_add_attribute(e, env, attr, n); } if(autho_decision_query->saml_actions) { size = axutil_array_list_size(autho_decision_query->saml_actions, env); for(i = 0 ; i < size ; i++) { action = (saml_action_t*)axutil_array_list_get(autho_decision_query->saml_actions, env, i); saml_action_to_om(action, n, env); } } if(autho_decision_query->evidence) { saml_evidence_to_om(autho_decision_query->evidence, n, env); } } return n; }
/** 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; }
AXIS2_EXTERN axiom_node_t* AXIS2_CALL saml_attr_query_to_om(saml_attr_query_t *attribute_query, axiom_node_t *parent, const axutil_env_t *env) { int size = 0, i = 0; axiom_element_t *e = NULL; axiom_node_t *n = NULL; axiom_namespace_t *ns = NULL; axiom_attribute_t *attr = NULL; saml_attr_desig_t *attr_desig = NULL; ns = axiom_namespace_create(env, SAML_PROTOCOL_NMSP, SAML_PROTOCOL_PREFIX); e = axiom_element_create(env, parent, SAML_ATTRIBUTE_QUERY, ns, &n); if(e) { if(attribute_query->subject) saml_subject_to_om(attribute_query->subject, n, env); if(attribute_query->resource) { attr = axiom_attribute_create(env, SAML_RESOURCE, attribute_query->resource, NULL); axiom_element_add_attribute(e, env, attr, n); } if(attribute_query->attr_desigs) { size = axutil_array_list_size(attribute_query->attr_desigs, env); for( i=0 ; i < size ; i++) { attr_desig = (saml_attr_desig_t*)axutil_array_list_get(attribute_query->attr_desigs, env, i); saml_attr_desig_to_om(attr_desig, n, env); } } } return n; }
axiom_node_t* AXIS2_CALL adb_CanonicalizationMethodType_serialize_obj( adb_CanonicalizationMethodType_t* _CanonicalizationMethodType, 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_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; int i = 0; int count = 0; void *element = NULL; 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 *text_value = NULL; 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, _CanonicalizationMethodType, 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(_CanonicalizationMethodType->is_valid_Algorithm) { p_prefix = NULL; text_value = axutil_uri_to_string(_CanonicalizationMethodType->property_Algorithm, env, AXIS2_URI_UNP_OMITUSERINFO); string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(text_value) + axutil_strlen("Algorithm"))); sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "Algorithm", text_value); axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); AXIS2_FREE(env-> allocator, string_to_stream); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute Algorithm"); return NULL; } string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } p_prefix = NULL; if (!_CanonicalizationMethodType->is_valid_extraElement) { /* 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("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 array */ if (_CanonicalizationMethodType->property_extraElement != NULL) { 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); count = axutil_array_list_size(_CanonicalizationMethodType->property_extraElement, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i); if(NULL == element) { continue; } /* * parsing extraElement element */ text_value_1 = axiom_node_to_string((axiom_node_t*)element, 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(parent_tag_closed) { if(_CanonicalizationMethodType->is_valid_Algorithm) { p_prefix = NULL; ns1 = NULL; text_value = axutil_uri_to_string(_CanonicalizationMethodType->property_Algorithm, env, AXIS2_URI_UNP_OMITUSERINFO); text_attri = axiom_attribute_create (env, "Algorithm", 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 Algorithm"); return NULL; } } return parent; }
axiom_node_t* AXIS2_CALL adb_OperationMetaDataWrapper_serialize_obj( adb_OperationMetaDataWrapper_t* _OperationMetaDataWrapper, 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; axis2_char_t* type_attrib = 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; int i = 0; int count = 0; void *element = NULL; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_2[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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _OperationMetaDataWrapper, 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); } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"OperationMetaDataWrapper\"", 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); } } } xsi_ns = axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "OperationMetaDataWrapper", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://mgt.operation.carbon.wso2.org/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://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", p_prefix)); } if (!_OperationMetaDataWrapper->is_valid_controlOperations) { /* 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("controlOperations"))); /* 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("controlOperations"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing controlOperations array */ if (_OperationMetaDataWrapper->property_controlOperations != NULL) { sprintf(start_input_str, "<%s%scontrolOperations", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%scontrolOperations>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_OperationMetaDataWrapper->property_controlOperations, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_OperationMetaDataWrapper->property_controlOperations, env, i); if(NULL == element) { continue; } /* * parsing controlOperations element */ if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_OperationMetaData_serialize((adb_OperationMetaData_t*)element, env, current_node, parent_element, adb_OperationMetaData_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_OperationMetaData_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(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://mgt.operation.carbon.wso2.org/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://mgt.operation.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://mgt.operation.carbon.wso2.org/xsd", p_prefix)); } if (!_OperationMetaDataWrapper->is_valid_publishedOperations) { /* 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("publishedOperations"))); /* 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("publishedOperations"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing publishedOperations array */ if (_OperationMetaDataWrapper->property_publishedOperations != NULL) { sprintf(start_input_str, "<%s%spublishedOperations", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%spublishedOperations>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_OperationMetaDataWrapper->property_publishedOperations, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_OperationMetaDataWrapper->property_publishedOperations, env, i); if(NULL == element) { continue; } /* * parsing publishedOperations element */ if(!adb_OperationMetaData_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_OperationMetaData_serialize((adb_OperationMetaData_t*)element, env, current_node, parent_element, adb_OperationMetaData_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_OperationMetaData_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); } return parent; }
axiom_node_t* AXIS2_CALL adb_service_type0_serialize_obj( adb_service_type0_t* _service_type0, 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_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 *text_value_2; axis2_char_t *text_value_2_temp; axis2_char_t *text_value = NULL; 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, _service_type0, 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(_service_type0->is_valid_id) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(_service_type0->property_id) + axutil_strlen("id"))); sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "id", _service_type0->property_id); 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 id"); return NULL; } string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.daisy.org/ns/daisy-online/", 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.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", p_prefix)); } if (!_service_type0->is_valid_label) { /* 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("label"))); /* 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("label"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing label element */ sprintf(start_input_str, "<%s%slabel", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%slabel>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_label_type0_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_label_type0_serialize(_service_type0->property_label, env, current_node, parent_element, adb_label_type0_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_label_type0_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(parent_tag_closed) { if(_service_type0->is_valid_id) { p_prefix = NULL; ns1 = NULL; text_value = _service_type0->property_id; text_attri = axiom_attribute_create (env, "id", 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 id"); return NULL; } } return parent; }
axiom_node_t* AXIS2_CALL adb_Exception_serialize_obj( adb_Exception_t* _Exception, 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; axis2_char_t* type_attrib = 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; axis2_char_t *text_value_1_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, _Exception, 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); } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"Exception\"", 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); } } } xsi_ns = axiom_namespace_create (env, "http://services.resource.ui.mgt.registry.carbon.wso2.org", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "Exception", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); 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 (!_Exception->is_valid_Exception) { /* 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("Exception"))); /* 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("Exception"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing Exception element */ sprintf(start_input_str, "<%s%sException>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sException>", 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(_Exception->property_Exception, env); 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; }
/** * Creates <wsse:BinarySecurityToken> element */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_token_build_binary_security_token_element( const axutil_env_t *env, axiom_node_t *parent, axis2_char_t* id, axis2_char_t* encoding_type, axis2_char_t* value_type, axis2_char_t* data) { axiom_node_t *binary_sec_token_node = NULL; axiom_node_t *first_child_of_parent = NULL; axiom_element_t *binary_security_token_ele = NULL; axiom_attribute_t *encoding_type_att = NULL; axiom_attribute_t *value_type_att = NULL; axiom_attribute_t *id_attr = NULL; axiom_namespace_t *ns_obj = NULL; axiom_namespace_t *ns = NULL; ns_obj = axiom_namespace_create(env, OXS_WSSE_NS, OXS_WSSE); ns = axiom_namespace_create(env, RAMPART_WSU_XMLNS, OXS_WSU); binary_security_token_ele = axiom_element_create(env, parent, OXS_NODE_BINARY_SECURITY_TOKEN, ns_obj, &binary_sec_token_node); if(!binary_security_token_ele) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Error creating %s element.", OXS_NODE_BINARY_SECURITY_TOKEN); axiom_namespace_free(ns_obj, env); axiom_namespace_free(ns, env); return NULL; } /* Binary security token must be added as the first child of the paretn */ binary_sec_token_node = axiom_node_detach_without_namespaces(binary_sec_token_node, env); first_child_of_parent = axiom_node_get_first_element(parent, env); if(first_child_of_parent) { /* If there is a child add bst before it */ axiom_node_insert_sibling_before(first_child_of_parent, env, binary_sec_token_node); } else { /* If there are no children just add the bst */ axiom_node_add_child(parent, env, binary_sec_token_node); } if(!id) { id = oxs_util_generate_id(env, (axis2_char_t*)OXS_CERT_ID); } id_attr = axiom_attribute_create(env, OXS_ATTR_ID, id, ns); encoding_type_att = axiom_attribute_create(env, OXS_ATTR_ENCODING_TYPE, encoding_type, NULL); value_type_att = axiom_attribute_create(env, OXS_ATTR_VALUE_TYPE, value_type, NULL); axiom_element_add_attribute(binary_security_token_ele, env, id_attr, binary_sec_token_node); axiom_element_add_attribute(binary_security_token_ele, env, encoding_type_att, binary_sec_token_node); axiom_element_add_attribute(binary_security_token_ele, env, value_type_att, binary_sec_token_node); if(data) { axiom_element_set_text(binary_security_token_ele, env, data, binary_sec_token_node); } return binary_sec_token_node; }
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; }
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; }
axiom_node_t* AXIS2_CALL adb_sample_type0_serialize_obj( adb_sample_type0_t* _sample_type0, 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_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 = NULL; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _sample_type0, 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(_sample_type0->is_valid_id) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(_sample_type0->property_id) + axutil_strlen("id"))); sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "id", _sample_type0->property_id); 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 id"); 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) { if(_sample_type0->is_valid_id) { p_prefix = NULL; ns1 = NULL; text_value = _sample_type0->property_id; text_attri = axiom_attribute_create (env, "id", 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 id"); return NULL; } } return parent; }
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; }
axiom_node_t* AXIS2_CALL adb_audio_type0_serialize_obj( adb_audio_type0_t* _audio_type0, 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_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[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_3[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_4[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *text_value = NULL; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _audio_type0, 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(_audio_type0->is_valid_uri) { p_prefix = NULL; text_value = axutil_uri_to_string(_audio_type0->property_uri, env, AXIS2_URI_UNP_OMITUSERINFO); string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(text_value) + axutil_strlen("uri"))); sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "uri", text_value); axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); AXIS2_FREE(env-> allocator, string_to_stream); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute uri"); return NULL; } if(_audio_type0->is_valid_rangeBegin) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (ADB_DEFAULT_DIGIT_LIMIT + 5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen("rangeBegin"))); sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "rangeBegin", _audio_type0->property_rangeBegin); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env-> allocator, text_value); } if(_audio_type0->is_valid_rangeEnd) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (ADB_DEFAULT_DIGIT_LIMIT + 5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen("rangeEnd"))); sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "rangeEnd", _audio_type0->property_rangeEnd); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env-> allocator, text_value); } if(_audio_type0->is_valid_size) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (ADB_DEFAULT_DIGIT_LIMIT + 5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen("size"))); sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "size", _audio_type0->property_size); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env-> allocator, text_value); } string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } if(parent_tag_closed) { if(_audio_type0->is_valid_uri) { p_prefix = NULL; ns1 = NULL; text_value = axutil_uri_to_string(_audio_type0->property_uri, env, AXIS2_URI_UNP_OMITUSERINFO); text_attri = axiom_attribute_create (env, "uri", 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 uri"); return NULL; } } if(parent_tag_closed) { if(_audio_type0->is_valid_rangeBegin) { p_prefix = NULL; ns1 = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT); sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_rangeBegin); text_attri = axiom_attribute_create (env, "rangeBegin", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); AXIS2_FREE(env-> allocator, text_value); } } if(parent_tag_closed) { if(_audio_type0->is_valid_rangeEnd) { p_prefix = NULL; ns1 = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT); sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_rangeEnd); text_attri = axiom_attribute_create (env, "rangeEnd", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); AXIS2_FREE(env-> allocator, text_value); } } if(parent_tag_closed) { if(_audio_type0->is_valid_size) { p_prefix = NULL; ns1 = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT); sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_size); text_attri = axiom_attribute_create (env, "size", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); AXIS2_FREE(env-> allocator, text_value); } } return parent; }