I wonder if you doing it right...The content/format negotiation is naturally supported by JAX-RS if we are talking about the actual HTTP message body. If you have some custom URI parameters representing encoded JSON or XML then you;d need to rely on some extra hints (extra URI parameters etc)

Cheers, Sergey
On 19/07/14 14:31, Puneet Gupta wrote:
Hi Sergey,

Thanks for your guidance. I end up using ParamConverterProvider to
implement my CustomParamConverterProvider.

Just a quick question. For now I have used CustomParamConverterProvider to
marshal/unmarshal JSON type input(using Jackson's JSON API). Can you
suggest me how to marshal/unmarshal XML type input so that I can use both.
I want to create a CustomParamConverterProvider which can marshal XML as
well as JSON type input string.

Thanks again for your help.

Regards, Puneet.


On Sun, Jul 13, 2014 at 11:11 PM, Sergey Beryozkin <[email protected]>
wrote:

Hi

You can have this complex object have a static valueOf(String) or factory
constuctor accepting String, or you can register JAX-RS 2.0
ParamConverterProvider

HTH, Sergey

On 12/07/14 17:49, Mark Streit wrote:

Perhaps the CXF JAX-RS examples will help.

http://svn.apache.org/viewvc/cxf/trunk/distribution/src/
main/release/samples/jax_rs/basic/

I believe it includes the case for passing a custom object.

There is a How-To link on the main page

http://cxf.apache.org/docs/sample-projects.html


On Saturday, July 12, 2014, Puneet Gupta <[email protected]>
wrote:

  Hi All,

I am working on Apache CXF rest services from past few days. I am stuck
at
one place. I am not able to figure out how to create a rest web service
call that excepts that custom object and perform some operation. For Ex:

Assume I have a custom object like below:

public class SampleObject {
    String x;
    String y;
    Integer i;
    Calendar c;
}

Now I want to create a rest web service like below:

          @POST
@Path("addSampleObject")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
MediaType.APPLICATION_FORM_URLENCODED })
public SampleObject addSampleObject(@FormParam("sampleObject")
SampleObject
sampleObject) throws WebServiceFault {
/**
* Perform some operation with SampleObject and return same object
*
*/
return sampleObject;
}

Can anyone help me find an example which I can use to fulfill my
scenario.

I would also like to understand how client can call this service.

Any help is highly appreciated.

Regards, Puneet.







--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to