Thanx for your answer Glen.
I tried to develop, based on one of the samples, a small REST web service. It
works. But there is a small thing I can't understand: It's the parameter
mapping in the REST uri.
I have a method in my service interface declared in a way that it expects an
employee id:
@Get
@HttpResource(location="/employees/{id}")
Employee getEmployee(long id);
BTW, this doesn't work. I can't understand why. Maybe I don't get what CXF is
doing with the ID in the uri. It's throwing me this exception when I try to
access the URL:
http://localhost:8080/cfx-web/services/employeeService/employees/33
Thanx for your time.
JS.
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:92)
at
org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:82)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:62)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:56)
at
org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:92)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:73)
at
org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDestination.java:78)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:231)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:105)
at
org.apache.cxf.transport.servlet.CXFServlet.invoke(CXFServlet.java:271)
at
org.apache.cxf.transport.servlet.CXFServlet.doGet(CXFServlet.java:253)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:99)
at
org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:73)
... 28 more
-----Message d'origine-----
De : Glen Mazza [mailto:[EMAIL PROTECTED]
Envoyé : 15 août 2007 16:54
À : [email protected]
Objet : Re: AJAX -> [JSON] -> REST service
Am Mittwoch, den 15.08.2007, 13:48 -0400 schrieb Jean-Sebastien
Bournival:
> Hi guys,
>
> I am in the process of validating using web services in conjonction with an
> AJAX layer on the front-side. The architecture of this might look like:
>
> - using CXF to expose REST services
> - these services will throw out some JSON (via Jettison)
> - the client side will use YUI to access the service layer
>
> I have 2 questions for you all:
>
> 1) Has anyone ever tried that (AJAX -> WS) ? I thought it might decouples a
> little more the GUI from the back-end.
>
Chapter 10 in Mark Hansen's SOA book covers AJAX -> WS in general (if not
precisely the way you wish to do this). That sample chapter is available as a
free download here:
http://www.theserverside.com/tt/articles/article.tss?l=AjaxJavaWebServices_Chapter
You may need some of the Chapter 9 code to understand Chapter 10--all source
code is available at http://soabook.com
> 2) Are the annotations used in CXF to build a RESTful WS, in sync with what
> is going on in the JCP regarding JAX-RS (JSR 311 I think) ?
>
AFAIK JSR 311 will be implemented in CXF, and it is a relatively high priority,
but it is not there yet.
HTH,
Glen