Hi, With reference to my last email, for text/xml request (I simplified it to get an idea):
* <ns1:setInterface xmlns:ns1="http://localhost:9090/axis2/quagga_openapi"> <name>eth0</name> </ns1:setInterface>* Now to read this, I followed echo example and have: * if (!node) /* root node */ { set_interface_error(env, "Invalid payload; echoString node is NULL"); return NULL; } text_parent_node = axiom_node_get_first_element(node, env); if (!text_parent_node) /* fucntion string: setInterface */ { set_interface_error(env, "Invalid payload; text node is NULL"); return NULL; } text_node = axiom_node_get_first_child(text_parent_node, env); if (!text_node) /* <name> tag */ { set_interface_error(env, "Invalid payload; text to be echoed is NULL"); return NULL; } if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) { axiom_text_t *text = (axiom_text_t *) axiom_node_get_data_element(text_node, env); if (text && axiom_text_get_value(text, env)) { axis2_char_t *text_str = (axis2_char_t *) axiom_text_get_value(text, env); printf("Interface Name: %s \n", text_str); } } else { set_interface_error(env, "Invalid payload; invalid XML in request"); return NULL; } * And it works if I have only <name> tag in the XML. But if I have: * <ns1:setInterface xmlns:ns1="http://localhost:9090/axis2/quagga_openapi"> <name>eth0</name> <address>192.168.0.1</address> </ns1:setInterface>* and now if I add to the code to extract address, * text_node1 = axiom_node_get_next_sibling(text_node, env); if (!text_node1) /* <address> tag */ { printf("No Sibling found !!!!*****\n"); set_interface_error(env, "Invalid payload; text to be echoed is NULL"); return NULL; } if (axiom_node_get_node_type(text_node1, env) == AXIOM_TEXT) { axiom_text_t *text1 = (axiom_text_t *) axiom_node_get_data_element(text_node1, env); if (text1 && axiom_text_get_value(text1, env)) { axis2_char_t *text_str1 = (axis2_char_t *) axiom_text_get_value(text1, env); printf("Address is : %s \n", text_str1); } } else { printf("Sibling Node text type not text !!!!*****\n"); set_interface_error(env, "Invalid payload; invalid XML in request"); return NULL; } * It results in No Sibling found!!! How do I access <address> ? How is the hierarchy traversed ? I hope my question is clear? Any guidance shall be highly appreciated. Regards, Shuaib On Wed, Feb 22, 2012 at 11:54 AM, Shuaib Siddiqui <shua...@gmail.com> wrote: > Hi, > > My goal is to implement a service that takes in different values for an > ethernet interface (e.g., ip address, name, etc) as input and make > respective changes in the kernel of the target machine. It will be a POST > REST method and for testing purpose, I am using Firefox REST client to send > POST request. Thats how I am doing it: > > *Request Header: > > Content-Type text/xml > > Request Body: > > <ns1:setInterface > xmlns:ns1="http://localhost:9090/axis2/service_openapi<http://localhost:9090/axis2/quagga_openapi> > "> > <interface> > <name>eth0</name> > <ip> > <address>192.168.0.1</address> > <prefixlen>24</prefixlen> > </ip> > </interface> > </ns1:setInterface>* > > This request should invoke the setInterface service and after extracting > the value of, i.e., <name>, <address> and <prefixlen> build up a stream and > send packet to server application which will talk with kernel to do the > required changes. > > For this given Request body, the following code, > > * axiom_element_t *element = NULL; > element = (axiom_element_t *) axiom_node_get_data_element(node, > env); > axis2_char_t *function_str = axiom_element_get_localname(element, > env); > printf("function string is %s \n", function_str);* > > results in printing setInterface on axis2 server console. How do I further > traverse through such a structure ? I tried using built-in functions like > *axiom_node_get_first_element(node, env); > axiom_node_get_first_child(node, env);* > But I am not able to traverse properly and extract the values. Does anyone > have any good pointers to an example which explains this ? > > Furthermore, in this given Request body, is <interface> element of node > <setInterface> or its child ? Similarly, <interface> has <name> and <ip> > (as its child or elements?), and <ip> has <address> and <prefixlen>. How do > we interpret this XML structure in AXIS2/C terminology ? > > Once again my question could be totally naive but XML and AXIS2/C are all > very new to me and I really want to understand this. > > Thanks for your time! > > Regards, > > S.S