Hi,
I'm using cxf2.7.3 and I have some methods like for example:
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Path("/GetPacketByArrivalTimeAndConfigIdWithOffset")
@ApiOperation(value = " Gets the list of IProxyPacket objects identified by the
given information.",
notes="Returns the list of objects identified by the given input",
response = IProxyPacket.class, produces ="application/xml,application/json")
public List<IProxyPacket> GetPacketByArrivalTimeAndConfigIdWithOffset(
@ApiParam(value = "appGardenID", required = true) @WebParam(name =
"appGardenID") @QueryParam("appGardenID") int appGardenID,
@ApiParam(value = "configId", required = true) @WebParam(name = "configId")
@QueryParam("configId") @CxfWSAuthGrain(type=authType.config) int configId,
@ApiParam(value = "lowerBound", required = true) @WebParam(name =
"lowerBound") @QueryParam("lowerBound") Date lowerBound,
@ApiParam(value = "upperBound", required = true) @WebParam(name =
"upperBound") @QueryParam("upperBound") Date upperBound,
@ApiParam(value = "maxResult", required = true) @WebParam(name =
"maxResult") @QueryParam("maxResult") Integer maxResult,
@ApiParam(value = "offset", required = true) @WebParam(name = "offset")
@QueryParam("offset") Integer offset);
On server side until now I'm using a
TimestampParameterHandler implements ParameterHandler<Date>{...}
that is properly recalled,
while on client side I'm not able to enter in the toString of the new parameter
converter.
Andrea
Date: Wed, 4 Sep 2013 07:43:27 -0700
From: [email protected]
To: [email protected]
Subject: Re: Serialize parameters on client side
Hi,
What CXF version and how method Date parameter is annotated ?
Cheers, Sergey
On 04/09/13 15:24, eanbiso wrote:
Hi Sergey,
I'm in a similar situation...I must use a parameter converter for Date type
to be sure at the serialization of a Date parameter the toString() method
adds also the milliseconds info in the produced string (until now I've seen
that when a Date obj is serialized by default the string is in the format
"Wed Sep 04 16:09:02 CEST 2013" and when I rebuild the Date obj at server
side I lose the ms info).
So I've built a new parameter converter for type Date like this:
@Provider
public class TimestampParamConverter implements ParamConverter<Date> {
/**
* Required for REST ws invocation
*/
@Override
public Date fromString(String s) {
//EXAMPLE TEST
//example s: Mon May 13 14:21:47 CEST 2013
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd
HH:mm:ss
zzz yyyy", Locale.US);
try {
return new Date(dateFormat.parse(s).getTime());
} catch (ParseException e) {
log.error("Exception building the Date from
corresponding string at REST
ws invocation. We return a NULL object. ",e);
return null;
}
}
@Override
public String toString(Date arg0) throws IllegalArgumentException {
// EXAMPLE TEST
if(arg0 != null){
return arg0.toString();
}else{
return null;
}
}
}
and I've added it on client side loading the endPoint in this way:
JAXRSClientFactoryBean proxyFactory = new JAXRSClientFactoryBean();
proxyFactory.setServiceClass(clazz);
proxyFactory.setAddress(address);
List providers = new ArrayList();
providers.add(new StringArrayBodyReader());
providers.add(new TimestampParamConverter());
proxyFactory.setProviders(providers);
.....
However I'm not able to arrive in the toString() method at the REST API
invocation....
What am I doing wrong?
Thanks a lot,
Andrea
--
View this message in context:
http://cxf.547215.n5.nabble.com/Serialize-parameters-on-client-side-tp5726421p5733516.html
Sent from the cxf-user mailing list archive at Nabble.com.
If you reply to this email, your message will be added to the
discussion below:
http://cxf.547215.n5.nabble.com/Serialize-parameters-on-client-side-tp5726421p5733518.html
To unsubscribe from Serialize parameters on client side, click
here.
NAML
--
View this message in context:
http://cxf.547215.n5.nabble.com/Serialize-parameters-on-client-side-tp5726421p5733519.html
Sent from the cxf-user mailing list archive at Nabble.com.