I agree it makes sense to let users to customize a 204 response by adding more headers or even changing the status and adding some
entity if it is what is needed, so I've updated the mainline accordingly
cheers, Sergey
Our service is a login service (specific for a web frontend) and it was
decided that no content in this case must be returned. So what the service
does is returning cookies and set the response status code (201,400,401 or
501 the cases).
In our response handler we set the cache headers and we want to configure
this in spring (since at the moment is based on the service and not pe
method); for this reason I think it would make sense to let any response
handler run even when nothing is returned. Another use case could be an
handler logging the response info.
BTW, if the change cannot be done I can easily change the signature
returning a Response: a simple update to your wiki would probably guarantee
that no other people will make the same mistake.
Thanks,
V.
On Mon, Jan 18, 2010 at 6:31 PM, Sergey Beryozkin <[email protected]>wrote:
Hi
Hi,
I'm integrating a ResponseHandler with common code modyfing the final
response. It's than added through spring to the jaxrs:server section as a
provider.
The service is this:
@POST
@Path("/login")
@Produces("text/html")
public void login(@FormParam("username") String username,
@FormParam("password") String password,
@FormParam("rememberMe") boolean rememberMe,
@FormParam("redirect") String redirect)
and than in spring:
<bean id="atomWfeAuthenticationWebService"
class="com.tomtom.buenosaires.ws.wfe.authentication.impl.AtomWfeAuthenticationRestWebService">
<property name="wfeAuthenticationService" ref="wfeAuthenticationService"
/>
</bean>
<jaxrs:server id="atomWfeAuthenticationRestWebService"
address="/wfe/authentication">
<jaxrs:serviceBeans>
<ref bean="atomWfeAuthenticationWebService" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="atomFeedProvider" />
<ref bean="cacheDisabledFilter" />
</jaxrs:providers>
</jaxrs:server>
the atom feed provider is there in case the service definition will change
and a proper atom feed will be returned. I guess the problem is related
with
nothing being returned.
According to the JAX-RS spec, it has to be just 204 that has to be
returned...I'll need to have a look and check if letting custom response
handlers to override a default Response would make sense even for void
methods...What exactly would you like to be returned on the wire for a
POST-handling method returning 'void' ?
Is there a way to fix that or are we forced to always return something
(which maybe probably also make sense).
Perhaps you can use HttpServletResponse directly ? Another option is to
create a custom out CXF interceptor (instead of ResponseHandler), it will
run before JAXRSOutInterceptor is invoked...Or may be you can just return a
Response, instead of 'void' ?
cheers, Sergey
thanks,
V.