cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Leclercq <pascal.lecle...@gmail.com>
Subject Re: Help on REST Bests practices
Date Thu, 09 Jun 2011 22:02:37 GMT
   Hi,


In my tests :


Test 1:

RESTXDocReportService.upload(Report report)


Tested by:

WebClient.post(Report)



   -> OK


Test 2 :

RESTXDocReportService.upload(String reportID, byte[] document, List<String>
fieldsMetaData)  {

Tested by:

   WebClient.post(Collection)

   => .No message body writer found for class : class
java.util.Arrays$ArrayList.



Test 3:

 RESTXDocReportService.upload(String reportID, byte[] document, List<String>
fieldsMetaData)  {

Tested by:

WebClient.post(Object[])

=> .No message body writer found for class : class [Ljava.lang.Object;.


Test 4:

RESTXDocReportService.upload(String reportID, byte[] document, List<String>
fieldsMetaData)  {


Tested by :

   Form aForm=new Form();

aForm.set("reportID", report.getReportID());

aForm.set("document", report.getDocument());

aForm.set("fieldsMetaData", report.getFieldsMetaData());

client.post(aForm);


=> .No message body writer found for class : class
org.apache.cxf.jaxrs.ext.form.Form.



What should I do ? How can I test my REST Service ?


Cheers.








2011/6/9 Sergey Beryozkin <sberyozkin@gmail.com>

> Please explain what is not working
>
> Cheers, Sergey
>
> On Wed, Jun 8, 2011 at 11:00 PM, Pascal Leclercq
> <pascal.leclercq@gmail.com> wrote:
> > Sergey,
> >
> > sorry to bother you but do you have time to have a look at the sample
> > project included ?
> > To be more precise, I don't know how to make the REST service
> > "uploadMultiple" with my Junit tests.
> >
> > I would like to know/ understand what's going wrong....
> >
> > Thanks in advance.
> >
> >
> >
> > 2011/6/8 Sergey Beryozkin <sberyozkin@gmail.com>
> >>
> >> Hi Pascal
> >>
> >> > I would like to know if i should create method like this :
> >> >
> >> >
> >> > upload(String id, byte[] content, List<String> metadata)
> >> >
> >> > or
> >> > upload(Report report)
> >> >
> >> > and if so how can I handle method like this :
> >> >
> >> > uploadAndProcess(Report report, List<DataContext> data, Options
> >> > options);
> >> >
> >>
> >> As far as JAX-RS is concerned, you can have methods with multiple
> >> parameters (including explicit collections)
> >> but only a single method parameter can be mapped to a request payload,
> >> other parameters, if any, can be mapped to various URI parts or HTTP
> >> headers or JAX-RS Contexts.
> >> Multipart attachment parts or form name/value pairs can be mapped to
> >> multiple parameters, but generally speaking, a request payload has to
> >> be represented by a single method parameter.
> >>
> >> >
> >> > So far I have no solution for the last case.
> >> >
> >> > I don't really want to create a custom request object for each method
> I
> >> > create.
> >>
> >> You don't have to. It seems that this issue is somewhat orthogonal to
> >> the issue of how many input parameters a given resource method has.
> >>
> >> thanks, Sergey
> >>
> >> >
> >>
> >>
> >>
> >> >
> >> > Cheers, Pascal.
> >> >
> >> > 2011/6/7 Sergey Beryozkin <sberyozkin@gmail.com>
> >> >
> >> >> Hi
> >> >>
> >> >>
> >> >>
> >> >> Would you like to have a shared signature for SOAP and REST services
> ?
> >> >> You may want to have a method dedicated to serving SOAP requests only
> >> >> and which would return say DataSource. That method may work for
> JAX-RS
> >> >> too.
> >> >>
> >> >> And you may also try introducing a method which returns a JAXB bean
> >> >> capturing the data - this will work for SOAP but also use CXF JAX-RS
> >> >> RequestDispatcherProvider  to redirect to HTML-aware handlers or use
> >> >> XSLTJaxbProvider
> >> >>
> >> >>
> >> >>
> >> >>
> http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection-WithRequestDispatcherProvider
> >> >>
> >> >>
> >> >>
> http://cxf.apache.org/docs/jax-rs-advanced-xml.html#JAX-RSAdvancedXML-XSLTsupport
> >> >>
> >> >> RequestDispatcherProvider and XSLTJaxbProvider are not 'intrusive'
> and
> >> >> can help with separating the presentation logic from the main
> >> >> controller code.
> >> >>
> >> >> Some users are combining Struts with CXF as well - but I've no
> >> >> experience
> >> >> there
> >> >>
> >> >> Cheers, Sergey
> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Pascal Leclercq
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Sergey Beryozkin
> >> >>
> >> >> Application Integration Division of Talend
> >> >> http://sberyozkin.blogspot.com
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Pascal Leclercq
> >> >
> >>
> >>
> >>
> >> --
> >> Sergey Beryozkin
> >>
> >> Application Integration Division of Talend
> >> http://sberyozkin.blogspot.com
> >
> >
> >
> > --
> > Pascal Leclercq
> >
> >
> >
>
>
>
> --
> Sergey Beryozkin
>
> Application Integration Division of Talend
> http://sberyozkin.blogspot.com
>



-- 
Pascal Leclercq

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message