Hi,
You can do so by setting the following property to application/json,
application/json/badgerfish or text/javascript
msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE,
);
also make sure you have the following in your axis2.xml
<messageFormatter contentType="application/json"
class="org.apache.axis2.json.JSONMessageFormatter
"/>
<messageFormatter contentType="application/json/badgerfish"
class="
org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
<messageFormatter contentType="text/javascript"
class="org.apache.axis2.json.JSONMessageFormatter
"/>
in the messageFoematters section and
<messageBuilder contentType="application/json"
class="org.apache.axis2.json.JSONOMBuilder"/>
<messageBuilder contentType="application/json/badgerfish"
class="
org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
<messageBuilder contentType="text/javascript"
class="org.apache.axis2.json.JSONOMBuilder"/>
in the messageBuilders section.
You might also wanna take a look at http://wso2.org/library/768 this article
which describes JSON support in axis2 and explains the above configurations.
Hope that you have a happy time trying JSON and Axis2...
Thanks,
Keith.
On 10/2/07, Lechuza lechuza <[EMAIL PROTECTED]> wrote:
>
> Hi guys,
>
> I'd like to start using axis2 as a service engine.
>
> All clients in my structure are javacripts clients, and
> the best option could be use REST request and response using JSON
> objects?
>
> I'm using pojo objects in this way:
>
> public class User {
> private HashMap entries = new HashMap();
> public User(){
> }
> public void Add( User ){
> this.entries.put (entry.getName(), entry);
> }
> public User Info(String name){
> return (User) entries.get(name);
> }
> }
>
>
>
> public class User {
> private String name = null;
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this. name = name;
> }
> }
>
> How can i force json response ?
> I have added the tags in axis2.xml file.
>
> regards
> Lechu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Keith Chapman
WSO2 Inc.
Oxygen for Web Services Developers.
http://wso2.org/