AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL axiom_soap_fault_reason_get_first_soap_fault_text( axiom_soap_fault_reason_t * fault_reason, const axutil_env_t * env) { int status = AXIS2_SUCCESS; if (!(fault_reason->fault_texts) && (fault_reason->soap_builder)) { if (!(axiom_node_is_complete(fault_reason->om_ele_node, env))) { while (!(axiom_node_is_complete(fault_reason->om_ele_node, env))) { status = axiom_soap_builder_next(fault_reason->soap_builder, env); if (status == AXIS2_FAILURE) { return NULL; } } } } if (fault_reason->fault_texts) { void *value = NULL; value = axutil_array_list_get(fault_reason->fault_texts, env, 0); if (value) { return (axiom_soap_fault_text_t *) value; } } return NULL; }
AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL axiom_soap_fault_reason_get_soap_fault_text( axiom_soap_fault_reason_t * fault_reason, const axutil_env_t * env, axis2_char_t * lang) { int status = AXIS2_SUCCESS; int size = 0; int i = 0; AXIS2_PARAM_CHECK(env->error, fault_reason, NULL); if (!lang || (axutil_strcmp(lang, "") == 0)) { return NULL; } /** Here we have to build the soap fault reason element completly */ if (!fault_reason->fault_texts) { if (fault_reason->soap_builder && !(axiom_node_is_complete(fault_reason->om_ele_node, env))) { while (!(axiom_node_is_complete(fault_reason->om_ele_node, env))) { status = axiom_soap_builder_next(fault_reason->soap_builder, env); if (status == AXIS2_FAILURE) { return NULL; } } } } if (!fault_reason->fault_texts) { return NULL; } /** iterate the array list */ size = axutil_array_list_size(fault_reason->fault_texts, env); for (i = 0; i < size; i++) { axiom_soap_fault_text_t *fault_text = NULL; void *value = NULL; value = axutil_array_list_get(fault_reason->fault_texts, env, i); if (value) { axis2_char_t *fault_lang = NULL; fault_text = (axiom_soap_fault_text_t *) value; fault_lang = axiom_soap_fault_text_get_lang(fault_text, env); if (fault_lang && axutil_strcmp(lang, fault_lang) == 0) { return fault_text; } } } return NULL; }
/** this method encapsulate searching logic */ static void axiom_navigator_update_next_node( axiom_navigator_t * om_navigator, const axutil_env_t * env) { if (!om_navigator) { return; } if (!om_navigator->next) { return; } if ((AXIOM_ELEMENT == axiom_node_get_node_type(om_navigator->next, env)) && !(om_navigator->visited)) { if (axiom_node_get_first_child(om_navigator->next, env)) { om_navigator->next = axiom_node_get_first_child(om_navigator->next, env); } else if (AXIS2_TRUE == axiom_node_is_complete(om_navigator->next, env)) { om_navigator->backtracked = AXIS2_TRUE; } else { om_navigator->next = NULL; } } else { axiom_node_t *parent = NULL; axiom_node_t *next_sibling = NULL; next_sibling = axiom_node_get_next_sibling(om_navigator->next, env); parent = axiom_node_get_parent(om_navigator->next, env); if (next_sibling) { om_navigator->next = next_sibling; } else if ((parent) && axiom_node_is_complete(parent, env)) { om_navigator->next = parent; om_navigator->backtracked = AXIS2_TRUE; } else { om_navigator->next = NULL; } } }
/** * Returns the axiom_soap_fault_t struct in this axiom_soap_bodY_t * struct * * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code> * object */ AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL axiom_soap_body_get_fault( axiom_soap_body_t * soap_body, const axutil_env_t * env) { if(soap_body->soap_fault) { return soap_body->soap_fault; } else if(soap_body->soap_builder) { while(!(soap_body->soap_fault) && !(axiom_node_is_complete(soap_body->om_ele_node, env))) { int status = AXIS2_SUCCESS; status = axiom_soap_builder_next(soap_body->soap_builder, env); if(status == AXIS2_FAILURE) { return NULL; } } if(soap_body->soap_fault) { soap_body->has_fault = AXIS2_TRUE; return soap_body->soap_fault; } } return NULL; }
/** * Indicates whether a soap fault is available with this soap body * @param soap_body axiom_soap_body struct * @param env environment must not be null * @return AXIS2_TRUE if fault is available, AXIS2_FALSE otherwise */ AXIS2_EXTERN axis2_bool_t AXIS2_CALL axiom_soap_body_has_fault( axiom_soap_body_t * soap_body, const axutil_env_t * env) { if(soap_body->soap_fault) { soap_body->has_fault = AXIS2_TRUE; } else { /* This soap body could have been built programatically. Do the following only if soap * body is created from soap_builder. Check for last child is to make sure body's child * are not yet built. If atleast one child is built, we don't need to build it again, * because , if fault, first child node of body node should be the fault node. If the child * is not built yet, trigger it to be built. */ if(soap_body->soap_builder && !axiom_node_is_complete(soap_body->om_ele_node, env) && !axiom_node_get_last_child(soap_body->om_ele_node, env)) { axiom_soap_builder_next(soap_body->soap_builder, env); if(soap_body->soap_fault) { soap_body->has_fault = AXIS2_TRUE; } } } return soap_body->has_fault; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_stax_builder_discard_current_element( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { axiom_node_t *element = NULL; axiom_node_t *prev_node = NULL; axiom_node_t *parent = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); element = om_builder->lastnode; if(axiom_node_is_complete(element, env) || !(om_builder->cache)) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD, AXIS2_FAILURE); return AXIS2_FAILURE; } om_builder->cache = AXIS2_FALSE; do { while(axiom_xml_reader_next(om_builder->parser, env) != AXIOM_XML_READER_END_ELEMENT) ; } while(!(axiom_node_is_complete(element, env))); /*All children of this element is pulled now */ prev_node = axiom_node_get_previous_sibling(element, env); if(prev_node) { axiom_node_free_tree(axiom_node_get_next_sibling(prev_node, env), env); axiom_node_set_next_sibling(prev_node, env, NULL); } else { parent = axiom_node_get_parent(element, env); axiom_node_free_tree(axiom_node_get_first_child(parent, env), env); axiom_node_set_first_child(parent, env, NULL); om_builder->lastnode = parent; } om_builder->cache = AXIS2_TRUE; return AXIS2_SUCCESS; }
static axiom_node_t * axiom_stax_builder_create_om_element( axiom_stax_builder_t * om_builder, const axutil_env_t * env, axis2_bool_t is_empty) { axiom_node_t *element_node = NULL; axiom_element_t *om_ele = NULL; axis2_char_t *temp_localname = NULL; axiom_node_t *parent = NULL; temp_localname = axiom_xml_reader_get_name(om_builder->parser, env); if(!temp_localname) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot find name of the element"); return NULL; } om_builder->element_level++; if(om_builder->lastnode) { if(axiom_node_is_complete(om_builder->lastnode, env)) { /*previous node building is finished. This node should be a sibling of previous node */ parent = axiom_node_get_parent(om_builder->lastnode, env); } else { /*previous node building is not finished. This should be child of previous node */ parent = om_builder->lastnode; } } om_ele = axiom_element_create(env, parent, temp_localname, NULL, &element_node); axiom_xml_reader_xml_free(om_builder->parser, env, temp_localname); if((!om_ele) || (!element_node)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create axiom element"); return NULL; } axiom_node_set_builder(element_node, env, om_builder); axiom_element_set_is_empty(om_ele, env, is_empty); if(!om_builder->lastnode) { /* since last node is null, this should be the root node */ om_builder->root_node = element_node; axiom_document_set_root_element(om_builder->document, env, element_node); } /* order of processing name spaces first (before processing attributes) is important */ axiom_stax_builder_process_namespaces(om_builder, env, element_node, 0); axiom_stax_builder_process_attributes(om_builder, env, element_node); om_builder->lastnode = element_node; return element_node; }
static axiom_node_t * axiom_stax_builder_create_om_text( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { axis2_char_t *temp_value = NULL; axutil_string_t *temp_value_str = NULL; axiom_node_t *node = NULL; axiom_node_t *parent = om_builder->lastnode; if(!parent) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create OM Text without a node"); return NULL; } temp_value = axiom_xml_reader_get_value(om_builder->parser, env); if(!temp_value) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_VALUE_NULL, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid OM Text value"); return NULL; } #ifdef AXIS2_LIBXML2_ENABLED temp_value_str = axutil_string_create(env, temp_value); axiom_xml_reader_xml_free(om_builder->parser, env, temp_value); #else temp_value_str = axutil_string_create_assume_ownership(env, &temp_value); #endif if(!temp_value_str) { /* axutil_string_create will have set an error number */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create OM Text value"); return NULL; } if(axiom_node_is_complete(parent, env)) { parent = axiom_node_get_parent(om_builder->lastnode, env); } axiom_text_create_str(env, parent, temp_value_str, &node); axutil_string_free(temp_value_str, env); if(!node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create axiom_text"); return NULL; } axiom_node_set_builder(node, env, om_builder); axiom_node_set_complete(node, env, AXIS2_TRUE); om_builder->lastnode = node; return node; }
static axiom_node_t * axiom_stax_builder_create_om_processing_instruction( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { axiom_node_t *pi_node = NULL; axis2_char_t *target = NULL; axis2_char_t *value = NULL; target = axiom_xml_reader_get_pi_target(om_builder->parser, env); value = axiom_xml_reader_get_pi_data(om_builder->parser, env); if(!target) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); return NULL; } if(!om_builder->lastnode) { /* do nothing */ axiom_xml_reader_xml_free(om_builder->parser, env, target); axiom_xml_reader_xml_free(om_builder->parser, env, value); return NULL; } else if(axiom_node_is_complete(om_builder->lastnode, env) || (axiom_node_get_node_type(om_builder->lastnode, env) == AXIOM_TEXT)) { axiom_processing_instruction_create(env, axiom_node_get_parent(om_builder-> lastnode, env), target, value, &pi_node); axiom_node_set_next_sibling(om_builder->lastnode, env, pi_node); axiom_node_set_previous_sibling(pi_node, env, om_builder->lastnode); } else { axiom_processing_instruction_create(env, om_builder->lastnode, target, value, &pi_node); axiom_node_set_first_child(om_builder->lastnode, env, pi_node); axiom_node_set_parent(pi_node, env, om_builder->lastnode); } axiom_node_set_builder(pi_node, env, om_builder); om_builder->element_level++; if(target) { axiom_xml_reader_xml_free(om_builder->parser, env, target); } if(value) { axiom_xml_reader_xml_free(om_builder->parser, env, value); } om_builder->lastnode = pi_node; return pi_node; }
static axis2_status_t axiom_stax_builder_end_element( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { /* if last node is not set, that means end_element is called before start_element, * which is an error */ if(!om_builder->lastnode) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid XML. End element is received before start element."); return AXIS2_FAILURE; } om_builder->element_level--; if(axiom_node_is_complete(om_builder->lastnode, env)) { /* Last node completed means, this end element should be parent of the last node. */ axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env); if(parent) { axiom_node_set_complete(parent, env, AXIS2_TRUE); om_builder->lastnode = parent; } } else { axiom_node_set_complete((om_builder->lastnode), env, AXIS2_TRUE); } /* if we finish building the root node, then we can set the complete status of om_builder */ if(axiom_node_is_complete(om_builder->root_node, env)) { om_builder->done = AXIS2_TRUE; } return AXIS2_SUCCESS; }
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL axiom_soap_fault_reason_get_all_soap_fault_texts( axiom_soap_fault_reason_t * fault_reason, const axutil_env_t * env) { int status = AXIS2_SUCCESS; if (!(fault_reason->fault_texts) && (fault_reason->soap_builder)) { if (!(axiom_node_is_complete(fault_reason->om_ele_node, env))) { while (!(axiom_node_is_complete(fault_reason->om_ele_node, env))) { status = axiom_soap_builder_next(fault_reason->soap_builder, env); if (status == AXIS2_FAILURE) { return NULL; } } } } return fault_reason->fault_texts; }
static axiom_node_t * axiom_stax_builder_create_om_comment( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { axiom_node_t *comment_node = NULL; axis2_char_t *comment_value = NULL; axiom_node_t *parent = NULL; comment_value = axiom_xml_reader_get_value(om_builder->parser, env); if(!comment_value) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading comment"); return NULL; } if(axiom_node_is_complete(om_builder->lastnode, env)) { /* Last node is completed means, this node should be a sibling of last node */ parent = axiom_node_get_parent(om_builder->lastnode, env); } else { /* this node should be a child of last node */ parent = om_builder->lastnode; } axiom_comment_create(env, parent, comment_value, &comment_node); axiom_xml_reader_xml_free(om_builder->parser,env,comment_value); if(!comment_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create axiom element"); return NULL; } axiom_node_set_builder(comment_node, env, om_builder); om_builder->element_level++; om_builder->lastnode = comment_node; return comment_node; }
AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL axiom_soap_fault_code_get_value( axiom_soap_fault_code_t * fault_code, const axutil_env_t * env) { int status = AXIS2_SUCCESS; if(fault_code->value) { return fault_code->value; } else if(fault_code->builder) { while(!(fault_code->value) && !(axiom_node_is_complete(fault_code->om_ele_node, env))) { status = axiom_soap_builder_next(fault_code->builder, env); if(status == AXIS2_FAILURE) { break; } } } return fault_code->value; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap_body_build( axiom_soap_body_t * soap_body, const axutil_env_t * env) { int status = AXIS2_SUCCESS; axiom_node_t *xop_node = NULL; axis2_bool_t is_replaced = AXIS2_FALSE; axiom_element_t *xop_element = NULL; if(soap_body->om_ele_node && soap_body->soap_builder) { xop_node = axiom_util_get_node_by_local_name(env, soap_body->om_ele_node, AXIS2_XOP_INCLUDE); if(xop_node) { xop_element = (axiom_element_t *)axiom_node_get_data_element(xop_node, env); if(xop_element) { is_replaced = axiom_soap_builder_replace_xop(soap_body->soap_builder, env, xop_node, xop_element); } } while(axiom_node_is_complete(soap_body->om_ele_node, env) != AXIS2_TRUE) { status = axiom_soap_builder_next(soap_body->soap_builder, env); if(status == AXIS2_FAILURE) { return AXIS2_FAILURE; } } } return AXIS2_SUCCESS; }
axiom_node_t *AXIS2_CALL axiom_stax_builder_next( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { int token = 0; axiom_node_t *node = NULL; do { if(om_builder->done) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE); return NULL; } token = axiom_xml_reader_next(om_builder->parser, env); if(token == -1) { return NULL; } om_builder->current_event = token; switch(token) { case AXIOM_XML_READER_START_DOCUMENT: /*Do nothing */ break; case AXIOM_XML_READER_START_ELEMENT: node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE); break; case AXIOM_XML_READER_EMPTY_ELEMENT: #ifdef AXIS2_LIBXML2_ENABLED node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE); #else node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_TRUE); #endif case AXIOM_XML_READER_END_ELEMENT: axiom_stax_builder_end_element(om_builder, env); break; case AXIOM_XML_READER_SPACE: node = axiom_stax_builder_create_om_text(om_builder, env); break; case AXIOM_XML_READER_CHARACTER: node = axiom_stax_builder_create_om_text(om_builder, env); break; case AXIOM_XML_READER_ENTITY_REFERENCE: break; case AXIOM_XML_READER_COMMENT: node = axiom_stax_builder_create_om_comment(om_builder, env); axiom_stax_builder_end_element(om_builder, env); break; case AXIOM_XML_READER_PROCESSING_INSTRUCTION: node = axiom_stax_builder_create_om_processing_instruction(om_builder, env); axiom_stax_builder_end_element(om_builder, env); break; case AXIOM_XML_READER_CDATA: break; case AXIOM_XML_READER_DOCUMENT_TYPE: break; default: break; } } while(!node && !axiom_node_is_complete(om_builder->root_node, env)); return node; }