Well, I would not say it is impossible, with some proper fixes, it should work
with more than one parameters. But do remember though, the request entity body
can only be mapped to one parameter, the rest of incoming parameters can be
mapped from URI, http headers etc. For example, following works in JAX-RS
(JSR-311):
@HttpMethod("PUT")
@UriTemplate("/books/{bookId}")
public Response updateBook(Book book, @UriParam("bookId") int id) {
....
}
The Book is mapped from request entity body.
Cheers,
Jervis
> -----Original Message-----
> From: Vespa, Anthony J [mailto:[EMAIL PROTECTED]
> Sent: 2008年1月14日 0:25
> To: [email protected]; [email protected]
> Subject: RE: Issues with JSON based Service and Jettison
>
> Hrm...so how would one implement JSON services with more than one
> parameter? Is it not possible in CXF?
>
> ________________________________
>
> From: Liu, Jervis [mailto:[EMAIL PROTECTED]
> Sent: Sun 1/13/2008 5:00 AM
> To: [email protected]
> Subject: RE: Issues with JSON based Service and Jettison
>
>
>
> According to the stack trace, it looks like your service method has more than
> one parameters. The CXF HTTP binding requires that the service method can
> only have one input parameters. For example, following is invalid:
>
> @Put
> @HttpResource(location = "/books/{id}")
> void updateBook(@WebParam(name = "Book")Book c, int id);
>
> Hope this helps,
> Jervis
>
> > -----Original Message-----
> > From: Vespa, Anthony J [mailto:[EMAIL PROTECTED]
> > Sent: 2008?1?13? 10:33
> > To: [email protected]; [email protected]
> > Subject: RE: Issues with JSON based Service and Jettison
> >
> > I actually tried the jax_rs samples a week or two back and it caused quite a
> > few issues with our codebase, as well as generally not working - it would
> > also require re-writes of all services, but even just re-writing one I get
> > exceptions and other issues - there was also some odd behavior, like not
> > being able to pass any data type but a String, for example, as any
> > arguement.
> >
> > Has anyone got a good detailed example of getting JSON to work from end
> > to end, with submitting a JSON formatted input into a service, and getting
> > appropriate output, with a configuration through beans.xml? I can get
> the
> > simple examples to work with some futzing around, but I'm doing to send
> > some complex input back and forth I've scanned through the mailing list
> > and searched the web, but I haven't found much info - the docs for jettison
> > tend to give the same general example and I need something specific - or
> at
> > least a hard enough push to know if it is a configuration issue, or if I am
> > trying to do something that is either crazy or not supported.
> >
> > ________________________________
> >
> > From: Liu, Jervis [mailto:[EMAIL PROTECTED]
> > Sent: Sat 1/12/2008 11:36 AM
> > To: [email protected]
> > Subject: RE: Issues with JSON based Service and Jettison
> >
> >
> >
> > Grab a latest snapshot of CXF, check out the
> > samples\jax_rs\content_negotiation demo. The spring configuration can
> be
> > found in [1]. An example of using JSON to do post can be found in system
> > test:
> >
> trunk\systests\src\test\java\org\apache\cxf\systest\jaxrs\JAXRSClientServer
> > BookTest.java
> >
> > [1]. http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
> >
> > Cheers,
> > Jervis
> >
> > > -----Original Message-----
> > > From: Vespa, Anthony J [mailto:[EMAIL PROTECTED]
> > > Sent: 2008?1?12? 1:43
> > > To: [email protected]
> > > Subject: Issues with JSON based Service and Jettison
> > >
> > > Hello,
> > >
> > > I cannot seem to get a JSON based servive to work properly. Does
> > anyone
> > > have a complete end to end example using the spring config to set up
> > > jettison? Ideally I want to be able to use a post or a get to a service
> > > using JSON both on request and response.
> > >
> > > I am accessing the service via /message/ABC123DEF456/4
> > > I am using Jettison and am getting the following exceptions:
> > >
> > > Jan 11, 2008 12:36:27 PM
> > > org.apache.cxf.interceptor.AttachmentInInterceptor handleMessage
> > > INFO: AttachmentInInterceptor skipped in HTTP GET method
> > > Jan 11, 2008 12:36:27 PM
> > > org.apache.cxf.binding.http.interceptor.DispatchInterceptor
> > > handleMessage
> > > INFO: Invoking GET on /message/ABC123DEF456/4
> > > Jan 11, 2008 12:36:27 PM
> > > org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor
> > > handleMessage
> > > INFO: URIParameterInterceptor handle message on path
> > > [/message/ABC123DEF456/4] with content-type [null]
> > > Jan 11, 2008 12:36:27 PM org.apache.cxf.phase.PhaseInterceptorChain
> > > doIntercept
> > > INFO: Interceptor has thrown exception, unwinding now
> > > org.apache.cxf.interceptor.Fault: SINGLE_PART_REQUIRED
> > > at
> > >
> org.apache.cxf.binding.http.interceptor.URIParameterInInterceptor.handle
> > > Message(URIParameterInInterceptor.java:82)
> > > at
> > >
> >
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> > > hain.java:207)
> > > at
> > >
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
> > > onObserver.java:78)
> > > at
> > >
> org.apache.cxf.transport.servlet.ServletDestination.doMessage(ServletDes
> > > tination.java:79)
> > > at
> > > org.apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
> > > vletController.java:264)
> > > at
> > > org.apache.cxf.transport.servlet.ServletController.invoke(ServletControl
> > > ler.java:123)
> > > at
> > >
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
> > > rvlet.java:170)
> > > at
> > >
> org.apache.cxf.transport.servlet.AbstractCXFServlet.doGet(AbstractCXFSer
> > > vlet.java:152)
> > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
> > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> > > tionFilterChain.java:290)
> > > at
> > > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> > > erChain.java:206)
> > > at
> > >
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa
> > > lv
> > > e.java:233)
> > > at
> > >
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> > > e.java:175)
> > > at
> > >
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> > > :128)
> > > at
> > >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> > > :102)
> > > at
> > >
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> > > java:109)
> > > at
> > >
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2
> > > 63)
> > > at
> > >
> >
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:84
> > > 4)
> > > at
> > >
> >
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
> > > ss(
> > > Http11Protocol.java:584)
> > > at
> > >
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> > > at java.lang.Thread.run(Thread.java:595)
> > > Jan 11, 2008 12:36:27 PM org.apache.cxf.phase.PhaseInterceptorChain
> > > doIntercept
> > > INFO: Interceptor has thrown exception, unwinding now
> > > java.lang.IllegalStateException: Invalid JSON namespace:
> > > http://cxf.apache.org/bindings/xformat
> > > at
> > >
> >
> org.codehaus.jettison.mapped.MappedNamespaceConvention.getJSONNam
> > > espace(
> > > MappedNamespaceConvention.java:148)
> > > at
> > >
> >
> org.codehaus.jettison.mapped.MappedNamespaceConvention.createKey(M
> > > appedN
> > > amespaceConvention.java:155)
> > > at
> > >
> >
> org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeStartElement(
> > > Map
> > > pedXMLStreamWriter.java:220)
> > > at
> > > org.apache.cxf.staxutils.StaxUtils.writeStartElement(StaxUtils.java:182)
> > > )
> > >
> > >
> > > I set up my jettison properties in my beans.xml as such following other
> > > examples on this list:
> > >
> > > <jaxws:endpoint id="jBoardService"
> > > implementor="com.cbs.bos.ws.json.BoardServiceImpl"
> > > address="/jBoardService"
> > > bindingUri="http://apache.org/cxf/binding/http">
> > > <jaxws:properties>
> > > <entry key="Content-Type" value="text/plain"/>
> > > </jaxws:properties>
> > > <jaxws:serviceFactory>
> > > <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> > > <property name="wrapped" value="false"/>
> > > <property name="properties">
> > > <map>
> > > <entry>
> > > <key><value>javax.xml.stream.XMLInputFactory</value></key>
> > > <bean class="org.codehaus.jettison.mapped.MappedXMLInputFactory">
> > > <constructor-arg>
> > > <map>
> > > <entry key="http://BoardService.json.bos.cbs.com/"
> > > value="jBoardService"/>
> > > <entry key="http://BoardServiceImpl.json.bos.cbs.com/"
> > > value="jBoardServiceImpl"/>
> > > </map>
> > > </constructor-arg>
> > > </bean>
> > > </entry>
> > > <entry>
> > > <key><value>javax.xml.stream.XMLOutputFactory</value></key>
> > > <bean
> class="org.codehaus.jettison.mapped.MappedXMLOutputFactory">
> > > <constructor-arg>
> > > <map>
> > > <entry key="http://BoardService.json.bos.cbs.com/"
> > > value="jBoardService"/>
> > > <entry key="http://BoardServiceImpl.json.bos.cbs.com/"
> > > value="jBoardServiceImpl"/>
> > > </map>
> > > </constructor-arg>
> > > </bean>
> > > </entry>
> > > </map>
> > > </property>
> > > </bean>
> > > </jaxws:serviceFactory>
> > > </jaxws:endpoint>
> >
> > ----------------------------
> > IONA Technologies PLC (registered in Ireland)
> > Registered Number: 171387
> > Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> >
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland