web-servicestomcattreeapache-axis

How to create tree using web service?


I want to create tree structure using web service. I have used bottom up web service technique for creation of simple arithmatic operation. I can not understand, how to build a tree using web services. Is there is way to achieve this?


Solution

  • Use a recursive definition like :

    expr = expr1 operand expr2 | node
    expr1 = expr
    expr2 = expr
    
    operand = '+' | '-'
    
    node = number
    

    Then you cqn straightforward encode it using JSON or XML

    15 + 3 - 2 becomes

    { "expr" : 
      { "expr1": { "expr1":"15" "operand":"+" "expr2":"3"} 
        "operand": "-"
        "expr2": "2"}}
    

    or in xml

    <expr>
       <expr1>
          <expr1>15</expr1>
          <operand>+</operand>
          <expr2>3</expr2>
       </expr1>
       <operand>+</operand>
       <expr2>2</expr2>
    </expr>
    

    In the service you can then walk the tree or build the tree. I am not sure if you see the service as a consumer or a producer.