2 Replies Latest reply on Jan 7, 2015 10:17 AM by Vijai Kumar

    RestApi task content unmarshal

    Zoltán Kaló Newbie

      Hi!

       

      I get content of a task by restApi (rest/task/content/{contentId}). I get response XML string. How can I get variable values?

       

      Thank you,

      Zoli

       

      This is the XML response:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <content>

         <id>32</id>

         <class-name>java.util.HashMap</class-name>

         <content-map>

            <entry key="taskId" class-name="java.lang.String">rO0ABXQAATY=</entry>

            <entry key="besorolasList" class-name="java.lang.String">rO0ABXQAW1t7ImlkIiA6ICIiLCAidGlwdXMiIDogIjMzMSIsICJlcnRlayIgOiAiMTEifSwgeyJpZCIgOiAiIiwgInRpcHVzIiA6ICI4MTQiLCAiZXJ0ZWsiIDogIjMifV0=</entry>

            <entry key="partnerKapcsolatList" class-name="java.lang.String">rO0ABXQAAltd</entry>

            <entry key="elerhetosegList" class-name="java.lang.String">rO0ABXQAAltd</entry>

            <entry key="kulsoAzonositoList" class-name="java.lang.String">rO0ABXQAAltd</entry>

            <entry key="termeszetesAzonositok" class-name="java.lang.String">rO0ABXQBK3sicGFydG5lcklkIjoiIiwgImVsb3RhZyI6IiIsICJ2ZXpldGVrbmV2IjoiS2lzcyIsICJrZXJlc3p0bmV2IjoiU3phYm9sY3MiLCAibmVtZSI6IiIsICJhbnlqYU5ldmUiOiJLaXNzIElsb25hIiwgInN6dWxldGVzaVZlemV0ZWtuZXYiOiIiLCAic3p1bGV0ZXNpS2VyZXN6dG5ldiI6Im51bGwiLCAic3p1bEhlbHkiOiJTem9sbm9rIiwgInN6dWxEYXR1bSI6IjIwMTQuMDguMDQuIiwgImhhbGFsb3phc2lEYXR1bSI6IiIsICJhbGxhbXBvbGdhcnNhZyI6IiIsICJhZGF0Z2F6ZGEiOiJOw4lCSUgiLCAibWVnamVneXplcyI6IiJ9</entry>

            <entry key="szamlaList" class-name="java.lang.String">rO0ABXQAAltd</entry>

            <entry key="cimList" class-name="java.lang.String">rO0ABXQCKFt7ImlkIiA6ICIiLCAiaGVseWxlaXJhc1RpcHVzIiA6ICIyIiwgImhlbHlsZWlyb0thdGVnb3JpYSIgOiAiMSIsICJoZWx5bGVpcmFzRmFqdGEiIDogIjEiLCAib3JzemFnIiA6ICIxIiwgInRlbGVwdWxlcyIgOiAiTGXDoW55ZmFsdSIsICJ0ZWxlcHVsZXNSZXN6IiA6ICJMZcOhbnlmYWx1IiwgImlyYW55aXRvc3phbSIgOiAiMjAxNiIsICJrb3p0ZXJ1bGV0TmV2ZSIgOiAiVMO2bGd5IiwgImtvenRlcnVsZXRKZWxsZWdlIiA6ICJ1dGNhIiwgImhhenN6YW0iIDogIjI2IiwgImVtZWxldCIgOiAiIiwgImFqdG8iIDogIiIsICJoZWx5UG9udG9zaXRhc2EiIDogIiIsICJrdWxmb2xkaUlyYW55aXRvc3phbSIgOiAiIiwgImt1bGZvbGRpVGVsZXB1bGVzIiA6ICIiLCAia3VsZm9sZGlDaW0iIDogIiIsICJmZWt2ZXMiIDogIjEiLCAiaGVseXJhanppU3phbSIgOiAiIiwgImdwc0tvb3JkaW5hdGFrIiA6ICIiLCAibWVwYXJCbG9ra0F6b25vc2l0byIgOiAiIiwgInN6dWxvIiA6ICIiLCAiY3NvcG9ydEF6b25vc2l0byIgOiAiIiwgImVydmVueWVzc2VnaUlkb3N6YWsiIDogIiJ9XQ==</entry>

            <entry key="megfeleloPartner" class-name="java.lang.String">rO0ABXQABGlnZW4=</entry>

            <entry key="partnerTevekenyseg" class-name="java.lang.String">rO0ABXQABU5JTkNT</entry>

         </content-map>

      </content>

        • 1. Re: RestApi task content unmarshal
          Zoltán Kaló Newbie

          I resolved.

           

          You have to read content, key and class name values from xml string, and base 64 decode content. Then you can deserialize object with StringObjectMapXmlAdapter.deserializeObject method. Then you can cast the result object to excepted class.

           

          String content = Base64.decode(nodes.item(i).getTextContent());

          NamedNodeMap attrs = nodes.item(i).getAttributes();

          String key = attrs.getNamedItem("key").getNodeValue();

          String className = attrs.getNamedItem("class-name").getNodeValue();

          Object contentObj = StringObjectMapXmlAdapter.deserializeObject(content, className, key);

          String contenetStr = (String)contentObj;

           

          Zoli

          • 2. Re: RestApi task content unmarshal
            Vijai Kumar Newbie

            Hi Zoltan,

             

            Could you please share me the code, actually I am trying to get the task variables as you did?

             

            Regards,

            Vijai