axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shameera Rathnayaka <shameerai...@gmail.com>
Subject Re: [GSOC 2012] Improve Json support in Axis2 with google-gson, [Part-2]
Date Fri, 29 Jun 2012 06:53:15 GMT
Hi devs,

I have a problem with, writing OMElement to the wire
at the JsonFormatter, The problem is how do i identify
whether it is a JSON object or JSON array.

As an example let's say i have this OMElement,

    <student>
        <name>micky</name>
        <age>15</age>
        <subject>History</subject>
        <subject>Science</subject>
    </student>

So the expected JSON Object is,
{"student":{"name":'micky" , "age":15 , "subject":["History", "Science"]}}

The thing is how should I know the student should be a JsonArray, when i
receive a <subject> Start element?

Another thing is if i get below OMElement, How do i know subject is a
JsonArray?
  <student>
        <name>micky</name>
        <age>15</age>
        <subject>History</subject>
    </student>

The relevant JSON object should be,

{"student":{"name":'micky" , "age":15 , "subject":["History"]}}

It would be nice to hear your ideas to overcome these problems.

Thanks,
Shameera.



On Mon, Jun 25, 2012 at 11:10 AM, Shameera Rathnayaka <
shameerainfo@gmail.com> wrote:

> Hi devs,
>
> Everything is fine, if i try to print OMElement using
>> omElement.toString();
>> it prints OMElement without any error. But after returning from
>> JsonBuilder,
>> and inside the TransportUtils class it throws a class cast exception when
>> it try
>> to add this returned OMelement to the SoapEnvelop by using
>> envelope.getBody().addChild(documentElement); here is the code segment in
>> TransportUtils class
>>
>> envelope = soapFactory.getDefaultEnvelope();
>> if (documentElement != null) {
>>      envelope.getBody().addChild(documentElement); // THIS LINE THROWS AN
>> EXCEPTION
>> }
>>
>> The exception is  *java.lang.ClassCastException:
>> org.apache.axiom.om.impl.llom.OMDocumentImpl cannot be cast to
>> org.apache.axiom.om.impl.OMNodeEx*
>
>
> I could able to solve this , there was an error in my GsonXMLStreamReader
> , I had to dig AXIOM to identify this. AXIOM process the parser while it
> receive XMLStreamReader.END_ELEMENT but my implementation had an error
> returning the END_ELEMENT, I solved it now I an not getting above
> ClassCastException.
>
> Thanks,
> Shameera.
>
> *
>> *
>> What should be the problem for this? , do i use wrong way to get
>> the OMElement or something else??  devs any comments on this ??
>>
>> Thanks,
>> Shameera.
>>
>>
>> On Sat, May 5, 2012 at 11:30 AM, Shameera Rathnayaka <
>> shameerainfo@gmail.com> wrote:
>>
>>> Hi devs ,
>>>
>>> According to my second approach, I need to map json elements in request
>>> to relevant XML tags/text and vice versa. When i am working on this, there
>>> is a  problem arises that which convention should i expect for this. So i
>>> need to clarify whether the following convention is correct or are there
>>> any suggestions for it.
>>>
>>> json message
>>>
>>> {    "alise": {
>>>         "bob": {
>>>             "x": "valueX",
>>>             "y": "valueY",
>>>             "z": ["valueU","valueV","valueW"],
>>>             "l": { "name": "john",  "age": 23 },
>>>             "m": [ { "a": ["A","B","C" ]  }, { "b": ["D","E","F" ]  }  ]
>>>         }
>>>     }
>>> }
>>>
>>> Relevant,expected xml message from this json request (actually, it is
>>> not converted to xml)
>>>
>>>     <json>
>>>         <alise>
>>>             <bob>
>>>                 <x>valueX</x>
>>>                 <y>valueY</y>
>>>                 <z>valueU</z>
>>>                 <z>valueV</z>
>>>                 <z>valueW</z>
>>>                 <l>
>>>                     <name>john</name>
>>>                     <age>23</age>
>>>                 </l>
>>>                 <m>
>>>                     <a>A</a>
>>>                     <a>B</a>
>>>                     <a>C</a>
>>>                 </m>
>>>                 <m>
>>>                     <b>D</b>
>>>                     <b>E</b>
>>>                     <b>F</b>
>>>                 </m>
>>>             </bob>
>>>         </alise>
>>>     </json>
>>>
>>>
>>> Thanks
>>> Shameera.
>>>
>>>
>>> On Tue, Apr 24, 2012 at 7:12 PM, Shameera Rathnayaka <
>>> shameerainfo@gmail.com> wrote:
>>>
>>>> Hi devs,
>>>>
>>>> As this project is accepted for GSoC 2012, I would like
>>>> to continue my work and looking forward to finish my project
>>>> as a success in this summer. According to my mentor (Amila
>>>> Suriarachchi)
>>>> it is better to improve my knowledge further about Axis2 architecture
>>>> in this community bounding period. Therefore I'll start to read the
>>>> Documentation and Apache Axis2 book.
>>>>
>>>> Andreas, as you mentioned in the previous mail thread[1] could you
>>>> please point out some of the code samples in synapse which do
>>>> a similar work as i do in my 2nd approach of the project?.
>>>>
>>>> I will use this thread for future discussion about the project.
>>>> And I'll keep update my implementation patches to  AXIS2-5270<https://issues.apache.org/jira/browse/AXIS2-5270>too.
>>>>
>>>>
>>>> [1]
>>>> http://axis.markmail.org/thread/4lg7xefplv7o65z6#query:page:1+mid:u7zauh37nj4mje6n+state:results
>>>>
>>>> Thanks
>>>> Shameera.
>>>>
>>>> --
>>>> Shameera Rathnayaka
>>>> Undergraduate
>>>> Department of Computer Science and Engineering
>>>> University of Moratuwa.
>>>> Sri Lanka.
>>>>
>>>> Blog : http://shameerarathnayaka.blogspot.com/
>>>>
>>>>
>>>
>>>
>>> --
>>> Shameera Rathnayaka
>>> Undergraduate
>>> Department of Computer Science and Engineering
>>> University of Moratuwa.
>>> Sri Lanka.
>>>
>>> Blog : http://shameerarathnayaka.blogspot.com/
>>>
>>>
>>
>>
>> --
>> Shameera Rathnayaka
>> Undergraduate
>> Department of Computer Science and Engineering
>> University of Moratuwa.
>> Sri Lanka.
>>
>> Blog : http://shameerarathnayaka.blogspot.com/
>>
>>
>
>
>
> --
> Shameera Rathnayaka
> Undergraduate
> Department of Computer Science and Engineering
> University of Moratuwa.
> Sri Lanka.
>
> Blog : http://shameerarathnayaka.blogspot.com/
>
>


-- 
Shameera Rathnayaka
Undergraduate
Department of Computer Science and Engineering
University of Moratuwa.
Sri Lanka.

Blog : http://shameerarathnayaka.blogspot.com/

Mime
View raw message