Hi Graham,

Yes, you are right and I did make sure that spaces are not the cause of
this behavior.

Best,

Shuaib

On Wed, Feb 22, 2012 at 5:33 PM, Graham Holden <
graham.hol...@versionone.co.uk> wrote:

> The first thing I would do is make sure that the payload is being sent
> without any spaces/newlines, i.e.:
>
> <ns1:setInterface
> xmlns:ns1="http://localhost:9090/axis2/quagga_openapi";><name>eth0</name>
> <address>192.168.0.1</address></ns1:setInterface>
>
> In my (not vast) experiences with Axis2/C, it seems to have trouble
> handling "human formatted" XML.
>
> Graham Holden
> Software Development Manager
> Version One Limited
>
> > -----Original Message-----
> > From: Shuaib Siddiqui [mailto:shua...@gmail.com]
> > Sent: 22 February 2012 14:43
> > To: Apache AXIS C User List
> > Subject: Re: Traversing text/xml node Axis2/C
> >
> > 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
> >
> >
> >
> ----------------------------------------------------------------
> Version One End-User Seminars
>
> REGISTER NOW!
> http://www.versionone.co.uk/seminars
>
> ----------------------------------------------------------------
> Version One Ltd. is the author of intelligent electronic document
> delivery and imaging software. This software enables the electronic
> storage, retrieval, management, enhancement and delivery of business
> documents such as invoices, purchase orders and statements. Version One's
> 'paperless office' technology is seamlessly integrated into all major
> finance and ERP systems. With a typical ROI of less than six months,
> Version One's solutions are enabling thousands of organisations to
> save dramatic amounts of time and money.
>
> Version One is a Member of BASDA (Business Application Software
> Developers Association) and ESA (European Software Association).
>
> The opinions expressed within this email represent those of the
> individual and not necessarily those of Version One Limited.
> The contents of this email may be privileged and are confidential.
> It may not be disclosed to or used by anyone other than the addressee(s),
> nor copied in any way.
>
> Version One Limited, Pentland House, Village Way, Wilmslow, Cheshire, SK9
> 2GH, UK.
> Registered office: Munro House, Portsmouth Road, Cobham, Surrey, KT11 1TF,
> UK
> Registered in England Number: 2443078   VAT Registration Number: 927 5479
> 83
>
> Version One is an Advanced Computer Software PLC company.
>
> -----------------------------------------------------------------
>
>
>
> Think about the environment - Do you really need to print this email?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-user-unsubscr...@axis.apache.org
> For additional commands, e-mail: c-user-h...@axis.apache.org
>
>

Reply via email to