You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Muhammad Sheraz Siddiqi <ms...@folio3.com> on 2010/08/31 12:38:30 UTC

@Produces programmatically

Hi,

I want to expose a webmethod like this:

@WebMethod
public List<CustonBean> test(String output) 
{
	If(output == "xml")
	{
		//use XML Provider i.e. output XML
	}	
	Else if(output == "json")
	{
		//use JSON Provider i.e. output JSON
	}
}

I do not want to use @Produces or rely on "Accept" request header.

Any help please ?




Re: @Produces programmatically

Posted by Sheraz Attari <ms...@folio3.com>.



Oh is there any separate list for these type of questions.

 

Yes you are right, I am using JAX-RS. If you can look at the
pseudo code below, there is an argument “output” I will decide based on its
value whether to return XML or JSON.

 

Any clues ?

 

Thanks



--- On Tue, 8/31/10, Sergey Beryozkin <sb...@gmail.com> wrote:

From: Sergey Beryozkin <sb...@gmail.com>
Subject: Re: @Produces programmatically
To: users@cxf.apache.org
Cc: msheraz@folio3.com
Date: Tuesday, August 31, 2010, 10:45 AM

Hi this is a question for the users list...

On Tue, Aug 31, 2010 at 11:38 AM, Muhammad Sheraz Siddiqi <ms...@folio3.com> wrote:

Hi,



I want to expose a webmethod like this:



@WebMethod

public List<CustonBean> test(String output)

{

        If(output == "xml")

        {

                //use XML Provider i.e. output XML

        }

        Else if(output == "json")

        {

                //use JSON Provider i.e. output JSON

        }

}



I do not want to use @Produces or rely on "Accept" request header.



Any help please ?





I'm presuming you're using JAXRS. So how are you going to decide if it's JSON or XML that needs to be returned ?

cheers, Sergey 
 


Re: @Produces programmatically

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi this is a question for the users list...

On Tue, Aug 31, 2010 at 11:38 AM, Muhammad Sheraz Siddiqi <
msheraz@folio3.com> wrote:

> Hi,
>
> I want to expose a webmethod like this:
>
> @WebMethod
> public List<CustonBean> test(String output)
> {
>        If(output == "xml")
>        {
>                //use XML Provider i.e. output XML
>        }
>        Else if(output == "json")
>        {
>                //use JSON Provider i.e. output JSON
>        }
> }
>
> I do not want to use @Produces or rely on "Accept" request header.
>
> Any help please ?
>
>
>
I'm presuming you're using JAXRS. So how are you going to decide if it's
JSON or XML that needs to be returned ?

cheers, Sergey