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 Sun, 17 Jun 2012 14:35:42 GMT
Hi devs ,

I could able to implement GsonXMLStreamReader successfully.
Now i can pass JSON object and get relevant XML infoset,
according to the given JSON object. And i could able to get
OMElement using this. I used StAXOMBuilder API to get
the OMElement. here is the code segment i uses.

*XMLStreamReader xmlStreamReader = new GsonXMLStreamReader(jsonReader);
messageContext.setEnvelope(soapEnvelope);
StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
OMElement omElement = stAXOMBuilder.getDocumentElement();*

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
*
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/

Mime
View raw message