You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "Johnson, Eric" <Er...@iona.com> on 2007/05/25 00:49:50 UTC

Newby REST question

I've got a class:
package com.acme.customer;
 
public interface WidgetCatalog
{
  Widgets getWidgets();
 
  Widget getWidget(long id);
 
  void addWidget(Widget widget);
 
  void updateWidget(Widget w);
  
  int removeWidgets(String type, int num);
  
  void deleteWidget(Widget widget);
}

That I want to get working using the convention based REST stuff, so I
publish it like this:

       JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setServiceClass(WidgetCatalog.class);
 
        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sf.setAddress("http://localhost:9000/xml/");
 
        WidgetCatalogImpl bs = new WidgetCatalogImpl();
        sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
 
        sf.getServiceFactory().setWrapped(true);
 
        sf.create();

When I try to access the getWidgets() method by going to
http://localhost:9000/xml/widgets I get "Invalid URL/Verb combination.
Verb: GET Path: /widgets."

What did I do wrong? I basically copied most of the restfull_http demo
and removed the annotations.

RE: Newby REST question

Posted by "Johnson, Eric" <Er...@iona.com>.
Thanks Dan!! 

> -----Original Message-----
> From: Dan Diephouse [mailto:dan@envoisolutions.com] 
> Sent: Tuesday, May 29, 2007 1:38 PM
> To: cxf-dev@incubator.apache.org
> Subject: Re: Newby REST question
> 
> OK, I figured this out. You're missing a @WebService 
> annotation on your WidgetCatalog class. If you don't want to 
> use any annotations, try using the 
> ReflectionServiceFactoryBean. (not sure why there isn't an 
> error being thrown, I'll see if I can fix that).
> 
> Also, your removeWidgets(...) method seems to cause problems 
> for the http binding because currently it assumes that 
> remove/delete methods are singular, not plular (i.e. 
> deleteWidget). I would suggest adding an @HttpResource for 
> that method. I'll see if I can get it sorted inside the HTTP 
> binding, but I'm afraid it will depend on us detecting 
> whether or not a word is singular or plural to begin with - 
> which is kind of hard :-).
> 
> Regards,
> - Dan
> 
> On 5/29/07, Johnson, Eric <Er...@iona.com> wrote:
> >
> > As a test to make sure I didn't screw up stuff when I copied the 
> > restful_http_binding demo as a starting point, I stripped out the 
> > annotations, as well Web services endpoint, from the actual 
> demo and 
> > got the same result.
> >
> > Putting the @HttpResource on the interface had no effect.
> >
> >
> >
> > > -----Original Message-----
> > > From: Dan Diephouse [mailto:dan@envoisolutions.com]
> > > Sent: Friday, May 25, 2007 1:35 PM
> > > To: cxf-dev@incubator.apache.org
> > > Subject: Re: Newby REST question
> > >
> > > You shouldn't need any annotations for the convention 
> based mode to 
> > > work.
> > > I'm not sure why Eric's example isn't working actually, 
> so it looks 
> > > like a bug to me. Which is kind of odd because I have a 
> very similar 
> > > unit test to what you've written. I'll have to take a 
> more in depth 
> > > look and get back to you.
> > >
> > > - Dan
> > >
> > > On 5/24/07, Freeman Fang <fr...@iona.com> wrote:
> > > >
> > > > Hi Eric,
> > > >
> > > > You need add @HttpResource in WidgetCatalog interface, like
> > > we do in
> > > > CustomerService of restful demo.
> > > >
> > > > Thanks very much
> > > >
> > > > Freeman
> > > >
> > > >
> > > > Johnson, Eric wrote:
> > > > > I've got a class:
> > > > > package com.acme.customer;
> > > > >
> > > > > public interface WidgetCatalog
> > > > > {
> > > > >   Widgets getWidgets();
> > > > >
> > > > >   Widget getWidget(long id);
> > > > >
> > > > >   void addWidget(Widget widget);
> > > > >
> > > > >   void updateWidget(Widget w);
> > > > >
> > > > >   int removeWidgets(String type, int num);
> > > > >
> > > > >   void deleteWidget(Widget widget); }
> > > > >
> > > > > That I want to get working using the convention based
> > > REST stuff, so
> > > > > I publish it like this:
> > > > >
> > > > >        JaxWsServerFactoryBean sf = new 
> JaxWsServerFactoryBean();
> > > > >         sf.setServiceClass(WidgetCatalog.class);
> > > > >
> > > > >         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
> > > > >         sf.setAddress("http://localhost:9000/xml/");
> > > > >
> > > > >         WidgetCatalogImpl bs = new WidgetCatalogImpl();
> > > > >         sf.getServiceFactory().setInvoker(new 
> BeanInvoker(bs));
> > > > >
> > > > >         sf.getServiceFactory().setWrapped(true);
> > > > >
> > > > >         sf.create();
> > > > >
> > > > > When I try to access the getWidgets() method by going to 
> > > > > http://localhost:9000/xml/widgets I get "Invalid URL/Verb
> > > combination.
> > > > > Verb: GET Path: /widgets."
> > > > >
> > > > > What did I do wrong? I basically copied most of the 
> > > > > restfull_http demo and removed the annotations.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Dan Diephouse
> > > Envoi Solutions
> > > http://envoisolutions.com | http://netzooid.com/blog
> > >
> >
> 
> 
> 
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
> 

Re: Newby REST question

Posted by Dan Diephouse <da...@envoisolutions.com>.
OK, I figured this out. You're missing a @WebService annotation on your
WidgetCatalog class. If you don't want to use any annotations, try using the
ReflectionServiceFactoryBean. (not sure why there isn't an error being
thrown, I'll see if I can fix that).

Also, your removeWidgets(...) method seems to cause problems for the http
binding because currently it assumes that remove/delete methods are
singular, not plular (i.e. deleteWidget). I would suggest adding an
@HttpResource for that method. I'll see if I can get it sorted inside the
HTTP binding, but I'm afraid it will depend on us detecting whether or not a
word is singular or plural to begin with - which is kind of hard :-).

Regards,
- Dan

On 5/29/07, Johnson, Eric <Er...@iona.com> wrote:
>
> As a test to make sure I didn't screw up stuff when I copied the
> restful_http_binding demo as a starting point, I stripped out the
> annotations, as well Web services endpoint, from the actual demo and got
> the same result.
>
> Putting the @HttpResource on the interface had no effect.
>
>
>
> > -----Original Message-----
> > From: Dan Diephouse [mailto:dan@envoisolutions.com]
> > Sent: Friday, May 25, 2007 1:35 PM
> > To: cxf-dev@incubator.apache.org
> > Subject: Re: Newby REST question
> >
> > You shouldn't need any annotations for the convention based
> > mode to work.
> > I'm not sure why Eric's example isn't working actually, so it
> > looks like a bug to me. Which is kind of odd because I have a
> > very similar unit test to what you've written. I'll have to
> > take a more in depth look and get back to you.
> >
> > - Dan
> >
> > On 5/24/07, Freeman Fang <fr...@iona.com> wrote:
> > >
> > > Hi Eric,
> > >
> > > You need add @HttpResource in WidgetCatalog interface, like
> > we do in
> > > CustomerService of restful demo.
> > >
> > > Thanks very much
> > >
> > > Freeman
> > >
> > >
> > > Johnson, Eric wrote:
> > > > I've got a class:
> > > > package com.acme.customer;
> > > >
> > > > public interface WidgetCatalog
> > > > {
> > > >   Widgets getWidgets();
> > > >
> > > >   Widget getWidget(long id);
> > > >
> > > >   void addWidget(Widget widget);
> > > >
> > > >   void updateWidget(Widget w);
> > > >
> > > >   int removeWidgets(String type, int num);
> > > >
> > > >   void deleteWidget(Widget widget);
> > > > }
> > > >
> > > > That I want to get working using the convention based
> > REST stuff, so
> > > > I publish it like this:
> > > >
> > > >        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
> > > >         sf.setServiceClass(WidgetCatalog.class);
> > > >
> > > >         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
> > > >         sf.setAddress("http://localhost:9000/xml/");
> > > >
> > > >         WidgetCatalogImpl bs = new WidgetCatalogImpl();
> > > >         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
> > > >
> > > >         sf.getServiceFactory().setWrapped(true);
> > > >
> > > >         sf.create();
> > > >
> > > > When I try to access the getWidgets() method by going to
> > > > http://localhost:9000/xml/widgets I get "Invalid URL/Verb
> > combination.
> > > > Verb: GET Path: /widgets."
> > > >
> > > > What did I do wrong? I basically copied most of the restfull_http
> > > > demo and removed the annotations.
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Dan Diephouse
> > Envoi Solutions
> > http://envoisolutions.com | http://netzooid.com/blog
> >
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

RE: Newby REST question

Posted by "Johnson, Eric" <Er...@iona.com>.
As a test to make sure I didn't screw up stuff when I copied the
restful_http_binding demo as a starting point, I stripped out the
annotations, as well Web services endpoint, from the actual demo and got
the same result.

Putting the @HttpResource on the interface had no effect.

 

> -----Original Message-----
> From: Dan Diephouse [mailto:dan@envoisolutions.com] 
> Sent: Friday, May 25, 2007 1:35 PM
> To: cxf-dev@incubator.apache.org
> Subject: Re: Newby REST question
> 
> You shouldn't need any annotations for the convention based 
> mode to work.
> I'm not sure why Eric's example isn't working actually, so it 
> looks like a bug to me. Which is kind of odd because I have a 
> very similar unit test to what you've written. I'll have to 
> take a more in depth look and get back to you.
> 
> - Dan
> 
> On 5/24/07, Freeman Fang <fr...@iona.com> wrote:
> >
> > Hi Eric,
> >
> > You need add @HttpResource in WidgetCatalog interface, like 
> we do in 
> > CustomerService of restful demo.
> >
> > Thanks very much
> >
> > Freeman
> >
> >
> > Johnson, Eric wrote:
> > > I've got a class:
> > > package com.acme.customer;
> > >
> > > public interface WidgetCatalog
> > > {
> > >   Widgets getWidgets();
> > >
> > >   Widget getWidget(long id);
> > >
> > >   void addWidget(Widget widget);
> > >
> > >   void updateWidget(Widget w);
> > >
> > >   int removeWidgets(String type, int num);
> > >
> > >   void deleteWidget(Widget widget);
> > > }
> > >
> > > That I want to get working using the convention based 
> REST stuff, so 
> > > I publish it like this:
> > >
> > >        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
> > >         sf.setServiceClass(WidgetCatalog.class);
> > >
> > >         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
> > >         sf.setAddress("http://localhost:9000/xml/");
> > >
> > >         WidgetCatalogImpl bs = new WidgetCatalogImpl();
> > >         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
> > >
> > >         sf.getServiceFactory().setWrapped(true);
> > >
> > >         sf.create();
> > >
> > > When I try to access the getWidgets() method by going to 
> > > http://localhost:9000/xml/widgets I get "Invalid URL/Verb 
> combination.
> > > Verb: GET Path: /widgets."
> > >
> > > What did I do wrong? I basically copied most of the restfull_http 
> > > demo and removed the annotations.
> > >
> > >
> >
> >
> 
> 
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
> 

Re: Newby REST question

Posted by Dan Diephouse <da...@envoisolutions.com>.
You shouldn't need any annotations for the convention based mode to work.
I'm not sure why Eric's example isn't working actually, so it looks like a
bug to me. Which is kind of odd because I have a very similar unit test to
what you've written. I'll have to take a more in depth look and get back to
you.

- Dan

On 5/24/07, Freeman Fang <fr...@iona.com> wrote:
>
> Hi Eric,
>
> You need add @HttpResource in WidgetCatalog interface, like we do in
> CustomerService of restful demo.
>
> Thanks very much
>
> Freeman
>
>
> Johnson, Eric wrote:
> > I've got a class:
> > package com.acme.customer;
> >
> > public interface WidgetCatalog
> > {
> >   Widgets getWidgets();
> >
> >   Widget getWidget(long id);
> >
> >   void addWidget(Widget widget);
> >
> >   void updateWidget(Widget w);
> >
> >   int removeWidgets(String type, int num);
> >
> >   void deleteWidget(Widget widget);
> > }
> >
> > That I want to get working using the convention based REST stuff, so I
> > publish it like this:
> >
> >        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
> >         sf.setServiceClass(WidgetCatalog.class);
> >
> >         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
> >         sf.setAddress("http://localhost:9000/xml/");
> >
> >         WidgetCatalogImpl bs = new WidgetCatalogImpl();
> >         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
> >
> >         sf.getServiceFactory().setWrapped(true);
> >
> >         sf.create();
> >
> > When I try to access the getWidgets() method by going to
> > http://localhost:9000/xml/widgets I get "Invalid URL/Verb combination.
> > Verb: GET Path: /widgets."
> >
> > What did I do wrong? I basically copied most of the restfull_http demo
> > and removed the annotations.
> >
> >
>
>


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

RE: Newby REST question

Posted by "Johnson, Eric" <Er...@iona.com>.
excellent!! Thanks.

-----Original Message-----
From: Freeman Fang [mailto:freeman.fang@iona.com]
Sent: Thu 5/24/2007 9:30 PM
To: cxf-dev@incubator.apache.org
Subject: Re: Newby REST question
 
Hi Eric,

You need add @HttpResource in WidgetCatalog interface, like we do in 
CustomerService of restful demo.

Thanks very much

Freeman


Johnson, Eric wrote:
> I've got a class:
> package com.acme.customer;
>  
> public interface WidgetCatalog
> {
>   Widgets getWidgets();
>  
>   Widget getWidget(long id);
>  
>   void addWidget(Widget widget);
>  
>   void updateWidget(Widget w);
>   
>   int removeWidgets(String type, int num);
>   
>   void deleteWidget(Widget widget);
> }
>
> That I want to get working using the convention based REST stuff, so I
> publish it like this:
>
>        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
>         sf.setServiceClass(WidgetCatalog.class);
>  
>         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
>         sf.setAddress("http://localhost:9000/xml/");
>  
>         WidgetCatalogImpl bs = new WidgetCatalogImpl();
>         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
>  
>         sf.getServiceFactory().setWrapped(true);
>  
>         sf.create();
>
> When I try to access the getWidgets() method by going to
> http://localhost:9000/xml/widgets I get "Invalid URL/Verb combination.
> Verb: GET Path: /widgets."
>
> What did I do wrong? I basically copied most of the restfull_http demo
> and removed the annotations.
>
>   



Re: Newby REST question

Posted by Freeman Fang <fr...@iona.com>.
Hi Eric,

You need add @HttpResource in WidgetCatalog interface, like we do in 
CustomerService of restful demo.

Thanks very much

Freeman


Johnson, Eric wrote:
> I've got a class:
> package com.acme.customer;
>  
> public interface WidgetCatalog
> {
>   Widgets getWidgets();
>  
>   Widget getWidget(long id);
>  
>   void addWidget(Widget widget);
>  
>   void updateWidget(Widget w);
>   
>   int removeWidgets(String type, int num);
>   
>   void deleteWidget(Widget widget);
> }
>
> That I want to get working using the convention based REST stuff, so I
> publish it like this:
>
>        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
>         sf.setServiceClass(WidgetCatalog.class);
>  
>         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
>         sf.setAddress("http://localhost:9000/xml/");
>  
>         WidgetCatalogImpl bs = new WidgetCatalogImpl();
>         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
>  
>         sf.getServiceFactory().setWrapped(true);
>  
>         sf.create();
>
> When I try to access the getWidgets() method by going to
> http://localhost:9000/xml/widgets I get "Invalid URL/Verb combination.
> Verb: GET Path: /widgets."
>
> What did I do wrong? I basically copied most of the restfull_http demo
> and removed the annotations.
>
>   


Re: Newby REST question

Posted by Willem Jiang <ni...@iona.com>.
Hi Eric,

You still need to use the annotation to tell CXF setup restful 
http-binding info which can map the request url to certain operation and 
parameters.

Cheers,

Willem.
Johnson, Eric wrote:
> I've got a class:
> package com.acme.customer;
>  
> public interface WidgetCatalog
> {
>   Widgets getWidgets();
>  
>   Widget getWidget(long id);
>  
>   void addWidget(Widget widget);
>  
>   void updateWidget(Widget w);
>   
>   int removeWidgets(String type, int num);
>   
>   void deleteWidget(Widget widget);
> }
>
> That I want to get working using the convention based REST stuff, so I
> publish it like this:
>
>        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
>         sf.setServiceClass(WidgetCatalog.class);
>  
>         sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
>         sf.setAddress("http://localhost:9000/xml/");
>  
>         WidgetCatalogImpl bs = new WidgetCatalogImpl();
>         sf.getServiceFactory().setInvoker(new BeanInvoker(bs));
>  
>         sf.getServiceFactory().setWrapped(true);
>  
>         sf.create();
>
> When I try to access the getWidgets() method by going to
> http://localhost:9000/xml/widgets I get "Invalid URL/Verb combination.
> Verb: GET Path: /widgets."
>
> What did I do wrong? I basically copied most of the restfull_http demo
> and removed the annotations.
>
>
>