You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by harriquitawn tawn tawn <ha...@hotmail.com> on 2013/07/15 13:48:35 UTC

Return issue Axis2 and JSON

Hello,
I've tried to configure axis2 1.6.2 with JSON as explained in http://axis.apache.org/axis2/java/core/docs/json_support.html, but it doesn't work for me. I've solved the error adding what it is explained in the next one: http://blog.djakapm.com/2011/12/15/json-web-service-with-java-and-axis2/
<module ref="DynamicResponseHandler"/>wso2dynamic-response-20080916.170559-241.mar jettison-1.2-patched.jar

Now I don't receive any error, but the result seems not to be a standard JSON.

{"return":[{"@type":"ax21:Ejemplo2","id":2,"name":"bb"},{"@type":"ax21:Ejemplo2","id":4,"name":"aa"}]}
If the WS returns an array of a customized class, in every object it returns "@type":"ax21:Ejemplo2"...
public Ejemplo2[] getListado3()
{
	Ejemplo2[] ejs = new Ejemplo2[2];
	Ejemplo2 e2 = new Ejemplo2(2L,"bb");
	Ejemplo2 e4 = new Ejemplo2(4L,"aa");
	
	ejs[0] = e2;
	ejs[1] = e4;
				
	return ejs;
}
Is there any way to avoid it?
Thanks in advance.


 		 	   		  

Re: Return issue Axis2 and JSON

Posted by Shameera Rathnayaka <sh...@gmail.com>.
Hi,

On Wed, Jul 17, 2013 at 6:51 PM, harriquitawn tawn tawn <
harriquitawn@hotmail.com> wrote:

> Hi,
>
> the first error I receive is
>
> Error 500: javax.servlet.ServletException: javax.servlet.ServletException:
> org.apache.axis2.AxisFault: The system is attempting to engage a module
> that is not available: addressing
>

This addressing module comes with axis2 distribution( see
AXIS2_HOME/repository/modules). If you see default axis2.xml file, this
module  has been engaged globally. Therefore it is necessary to have this
addressing module.


> But I solved adding the modules as a lib changinge .mar to .jar (I use
> Websphere as a application server and found that solution).
>

> After modify that, I don't receive any error, but the response is always
> an xml file, not json, altohug I use the ?response=application/json
>

The error your getting above is doesn't effect to axis2 json support. You
are using a custom handler(DynamicResponseHandler) which uses this
response=application/json  parameter. But with orginal axis2 this has on
meaning other that it is another query parameter.

Thanks,
Shameera.



> Thanks.
>
> ------------------------------
> From: shameerainfo@gmail.com
> Date: Tue, 16 Jul 2013 17:30:15 +0530
> Subject: Re: Return issue Axis2 and JSON
> To: java-user@axis.apache.org
>
>
> Hi Tawn,
>
> On Mon, Jul 15, 2013 at 5:18 PM, harriquitawn tawn tawn <
> harriquitawn@hotmail.com> wrote:
>
> Hello,
>
> I've tried to configure axis2 1.6.2 with JSON as explained in
> http://axis.apache.org/axis2/java/core/docs/json_support.html, but it
> doesn't work for me.
>
>
> What is the error you are getting?
>
> Thanks,
> Shameera.
>
>
>
> I've solved the error adding what it is explained in the next one:
> http://blog.djakapm.com/2011/12/15/json-web-service-with-java-and-axis2/
>
> <module ref="DynamicResponseHandler"/>
> wso2dynamic-response-20080916.170559-241.mar
> jettison-1.2-patched.jar
>
>
> Now I don't receive any error, but the result seems not to be a standard
> JSON.
>
>
> {"return":[{"@type":"ax21:Ejemplo2","id":2,"name":"bb"},{"@type":"ax21:Ejemplo2","id":4,"name":"aa"}]}
>
>
> If the WS returns an array of a customized class, in every object it returns "@type":"ax21:Ejemplo2"...
>
>
> public Ejemplo2[] getListado3()
> {
> 	Ejemplo2[] ejs = new Ejemplo2[2];
> 	Ejemplo2 e2 = new Ejemplo2(2L,"bb");
> 	Ejemplo2 e4 = new Ejemplo2(4L,"aa");
> 	
> 	ejs[0] = e2;
> 	ejs[1] = e4;
> 				
> 	return ejs;
> }
>
>
> Is there any way to avoid it?
>
>
> Thanks in advance.
>
>
>
>
>
>
>
> --
> Best Regards,
> Shameera Rathnayaka.
>
> email: shameera AT apache.org , shameerainfo AT gmail.com
> Blog : http://shameerarathnayaka.blogspot.com/
>



-- 
Best Regards,
Shameera Rathnayaka.

email: shameera AT apache.org , shameerainfo AT gmail.com
Blog : http://shameerarathnayaka.blogspot.com/

RE: Return issue Axis2 and JSON

Posted by harriquitawn tawn tawn <ha...@hotmail.com>.
Hi,
the first error I receive is
Error 500: javax.servlet.ServletException: javax.servlet.ServletException: org.apache.axis2.AxisFault: The system is attempting to engage a module that is not available: addressing
But I solved adding the modules as a lib changinge .mar to .jar (I use Websphere as a application server and found that solution).
After modify that, I don't receive any error, but the response is always an xml file, not json, altohug I use the ?response=application/json
Thanks.

From: shameerainfo@gmail.com
Date: Tue, 16 Jul 2013 17:30:15 +0530
Subject: Re: Return issue Axis2 and JSON
To: java-user@axis.apache.org

Hi Tawn, 

On Mon, Jul 15, 2013 at 5:18 PM, harriquitawn tawn tawn <ha...@hotmail.com> wrote:






Hello,
I've tried to configure axis2 1.6.2 with JSON as explained in http://axis.apache.org/axis2/java/core/docs/json_support.html, but it doesn't work for me. 



What is the error you are getting? 

Thanks,


Shameera.

 
I've solved the error adding what it is explained in the next one: http://blog.djakapm.com/2011/12/15/json-web-service-with-java-and-axis2/



<module ref="DynamicResponseHandler"/>


wso2dynamic-response-20080916.170559-241.mar 


jettison-1.2-patched.jar










Now I don't receive any error, but the result seems not to be a standard JSON.










{"return":[{"@type":"ax21:Ejemplo2","id":2,"name":"bb"},{"@type":"ax21:Ejemplo2","id":4,"name":"aa"}]}



If the WS returns an array of a customized class, in every object it returns "@type":"ax21:Ejemplo2"...



public Ejemplo2[] getListado3()
{
	Ejemplo2[] ejs = new Ejemplo2[2];
	Ejemplo2 e2 = new Ejemplo2(2L,"bb");
	Ejemplo2 e4 = new Ejemplo2(4L,"aa");
	
	ejs[0] = e2;
	ejs[1] = e4;
				
	return ejs;
}
Is there any way to avoid it?
Thanks in advance.








 		 	   		  


-- 
Best Regards,Shameera Rathnayaka.



email: shameera AT apache.org , shameerainfo AT gmail.com


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




 		 	   		  

Re: Return issue Axis2 and JSON

Posted by Shameera Rathnayaka <sh...@gmail.com>.
Hi Tawn,

On Mon, Jul 15, 2013 at 5:18 PM, harriquitawn tawn tawn <
harriquitawn@hotmail.com> wrote:

> Hello,
>
> I've tried to configure axis2 1.6.2 with JSON as explained in
> http://axis.apache.org/axis2/java/core/docs/json_support.html, but it
> doesn't work for me.
>

What is the error you are getting?

Thanks,
Shameera.



> I've solved the error adding what it is explained in the next one:
> http://blog.djakapm.com/2011/12/15/json-web-service-with-java-and-axis2/
>
> <module ref="DynamicResponseHandler"/>
> wso2dynamic-response-20080916.170559-241.mar
> jettison-1.2-patched.jar
>
>
> Now I don't receive any error, but the result seems not to be a standard
> JSON.
>
>
> {"return":[{"@type":"ax21:Ejemplo2","id":2,"name":"bb"},{"@type":"ax21:Ejemplo2","id":4,"name":"aa"}]}
>
>
> If the WS returns an array of a customized class, in every object it returns "@type":"ax21:Ejemplo2"...
>
>
> public Ejemplo2[] getListado3()
> {
> 	Ejemplo2[] ejs = new Ejemplo2[2];
> 	Ejemplo2 e2 = new Ejemplo2(2L,"bb");
> 	Ejemplo2 e4 = new Ejemplo2(4L,"aa");
> 	
> 	ejs[0] = e2;
> 	ejs[1] = e4;
> 				
> 	return ejs;
> }
>
>
> Is there any way to avoid it?
>
>
> Thanks in advance.
>
>
>
>
>


-- 
Best Regards,
Shameera Rathnayaka.

email: shameera AT apache.org , shameerainfo AT gmail.com
Blog : http://shameerarathnayaka.blogspot.com/