You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Christian Blavier <cb...@gmail.com> on 2007/07/03 17:37:38 UTC

Problem writing restful services with Spring

Hello,

I am currently using CXF 2.0-SNAPSHOT, and I've got some trouble writing
restful services with CXF.

Here is my spring configuration :

<beans>

<bean id="JaxWsServiceFactoryBean" class="
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">

<property name="wrapped" value="false"/>

</bean>

<jaxws:endpoint id="restfulServer"

implementor="#bookService"

address="/bookService"

bindingUri="http://apache.org/cxf/binding/http">

<jaxws:serviceFactory>

<ref bean="JaxWsServiceFactoryBean"/>

</jaxws:serviceFactory>

</jaxws:endpoint>
</beans>

My bookService is a simple java service with a single getBooks() method
which return a collection of Books
I haven't got any error at jetty startup and I can see a wsdl at
http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl
but nothing at http://localhost:8080/yuipoc-webapp/cxf/books or any other
rest-like address

Where am I wrong ?
Thanks

Re: Problem writing restful services with Spring

Posted by Jim Ma <em...@iona.com>.
Hi ,
I wrote the follow configuration to deploy  the sample 
restful_http_binding (under <cxf-home>/samples) in tomcat :

<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:jaxws="http://cxf.apache.org/jaxws"
      xmlns:soap="http://cxf.apache.org/bindings/soap"
      xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap 
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">     
    <jaxws:endpoint
            id="customer"
            implementor="com.acme.customer.CustomerServiceImpl"
            address="/customer"
            bindingUri="http://apache.org/cxf/binding/http">
            <jaxws:serviceFactory>
              <bean id="JaxWsServiceFactoryBean" 
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
                       <property name="wrapped" value="false"/>
              </bean>        
            </jaxws:serviceFactory>                 
    </jaxws:endpoint>
</beans>

I tried  this configuration and it works . I can get info from :
http://localhost:8080/customer/services/customer/customers
I do not know if return "List" cause this problem .The method I tried 
like this
     @Get
    @HttpResource(location = "/customers")
    @WebResult(name = "Customers")
    Customers getCustomers();

Hope this will help.

Cheers

Jim

Christian Blavier wrote:
> It doesn't work :(
>
> My method is annotated like this (in a @WebService class) :
>
> @Get
>
> @HttpResource(location="/books")
>
> *public* List getBooks() {
>
> *return* books;
>
> }
>
> and I get a "org.apache.cxf.interceptor.Fault: Invalid URL/Verb 
> combination.
> Verb: GET Path: /books" exception when I try
> http://localhost:8080/yuipoc-webapp/cxf/bookService/books
> and the http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl address
> still works.
>
>
>
>
>
> 2007/7/5, Dan Diephouse <da...@envoisolutions.com>:
>>
>> I *think* given your configuration, that the correct address to look at
>> might be:
>>
>> http://localhost:8080/yuipoc-webapp/cxf/bookService/books<
>> http://localhost:8080/yuipoc-webapp/cxf/books>
>>
>> The address attribute on <jaxws:endpoint> specifies the root location 
>> for
>> the restful service. Then the URIs in @HttpResource are appended to 
>> it (if
>> you're using annotations).
>>
>> Cheers,
>> - Dan
>>
>> On 7/5/07, Christian Blavier <cb...@gmail.com> wrote:
>> >
>> > No idea ? Anyone ?
>> > I'm still blocked on this.. :/
>> >
>> > 2007/7/3, Christian Blavier <cb...@gmail.com>:
>> > >
>> > > Hello,
>> > >
>> > > I am currently using CXF 2.0-SNAPSHOT, and I've got some trouble
>> writing
>> > > restful services with CXF.
>> > >
>> > > Here is my spring configuration :
>> > >
>> > > <beans>
>> > >
>> > > <bean id="JaxWsServiceFactoryBean" class="
>> > > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>> > >
>> > > <property name="wrapped" value="false"/>
>> > >
>> > > </bean>
>> > >
>> > > <jaxws:endpoint id="restfulServer"
>> > >
>> > > implementor="#bookService"
>> > >
>> > > address="/bookService"
>> > >
>> > > bindingUri="http://apache.org/cxf/binding/http" >
>> > >
>> > > <jaxws:serviceFactory>
>> > >
>> > > <ref bean= "JaxWsServiceFactoryBean"/>
>> > >
>> > > </jaxws:serviceFactory>
>> > >
>> > > </jaxws:endpoint>
>> > > </
>> > > beans>
>> > > My bookService is a simple java service with a single getBooks()
>> method
>> > > which return a collection of Books
>> > > I haven't got any error at jetty startup and I can see a wsdl at
>> > http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl
>> > >
>> > > but nothing at http://localhost:8080/yuipoc-webapp/cxf/books or any
>> > other
>> > > rest-like address
>> > >
>> > > Where am I wrong ?
>> > > Thanks
>> > >
>> >
>>
>>
>>
>> -- 
>> Dan Diephouse
>> Envoi Solutions
>> http://envoisolutions.com | http://netzooid.com/blog
>>
>

Re: Problem writing restful services with Spring

Posted by Christian Blavier <cb...@gmail.com>.
It doesn't work :(

My method is annotated like this (in a @WebService class) :

@Get

@HttpResource(location="/books")

*public* List getBooks() {

*return* books;

}

and I get a "org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination.
Verb: GET Path: /books" exception when I try
http://localhost:8080/yuipoc-webapp/cxf/bookService/books
and the http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl address
still works.





2007/7/5, Dan Diephouse <da...@envoisolutions.com>:
>
> I *think* given your configuration, that the correct address to look at
> might be:
>
> http://localhost:8080/yuipoc-webapp/cxf/bookService/books<
> http://localhost:8080/yuipoc-webapp/cxf/books>
>
> The address attribute on <jaxws:endpoint> specifies the root location for
> the restful service. Then the URIs in @HttpResource are appended to it (if
> you're using annotations).
>
> Cheers,
> - Dan
>
> On 7/5/07, Christian Blavier <cb...@gmail.com> wrote:
> >
> > No idea ? Anyone ?
> > I'm still blocked on this.. :/
> >
> > 2007/7/3, Christian Blavier <cb...@gmail.com>:
> > >
> > > Hello,
> > >
> > > I am currently using CXF 2.0-SNAPSHOT, and I've got some trouble
> writing
> > > restful services with CXF.
> > >
> > > Here is my spring configuration :
> > >
> > > <beans>
> > >
> > > <bean id="JaxWsServiceFactoryBean" class="
> > > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> > >
> > > <property name="wrapped" value="false"/>
> > >
> > > </bean>
> > >
> > > <jaxws:endpoint id="restfulServer"
> > >
> > > implementor="#bookService"
> > >
> > > address="/bookService"
> > >
> > > bindingUri="http://apache.org/cxf/binding/http" >
> > >
> > > <jaxws:serviceFactory>
> > >
> > > <ref bean= "JaxWsServiceFactoryBean"/>
> > >
> > > </jaxws:serviceFactory>
> > >
> > > </jaxws:endpoint>
> > > </
> > > beans>
> > > My bookService is a simple java service with a single getBooks()
> method
> > > which return a collection of Books
> > > I haven't got any error at jetty startup and I can see a wsdl at
> > http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl
> > >
> > > but nothing at http://localhost:8080/yuipoc-webapp/cxf/books or any
> > other
> > > rest-like address
> > >
> > > Where am I wrong ?
> > > Thanks
> > >
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>

Re: Problem writing restful services with Spring

Posted by Dan Diephouse <da...@envoisolutions.com>.
I *think* given your configuration, that the correct address to look at
might be:

http://localhost:8080/yuipoc-webapp/cxf/bookService/books<http://localhost:8080/yuipoc-webapp/cxf/books>

The address attribute on <jaxws:endpoint> specifies the root location for
the restful service. Then the URIs in @HttpResource are appended to it (if
you're using annotations).

Cheers,
- Dan

On 7/5/07, Christian Blavier <cb...@gmail.com> wrote:
>
> No idea ? Anyone ?
> I'm still blocked on this.. :/
>
> 2007/7/3, Christian Blavier <cb...@gmail.com>:
> >
> > Hello,
> >
> > I am currently using CXF 2.0-SNAPSHOT, and I've got some trouble writing
> > restful services with CXF.
> >
> > Here is my spring configuration :
> >
> > <beans>
> >
> > <bean id="JaxWsServiceFactoryBean" class="
> > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
> >
> > <property name="wrapped" value="false"/>
> >
> > </bean>
> >
> > <jaxws:endpoint id="restfulServer"
> >
> > implementor="#bookService"
> >
> > address="/bookService"
> >
> > bindingUri="http://apache.org/cxf/binding/http" >
> >
> > <jaxws:serviceFactory>
> >
> > <ref bean= "JaxWsServiceFactoryBean"/>
> >
> > </jaxws:serviceFactory>
> >
> > </jaxws:endpoint>
> > </
> > beans>
> > My bookService is a simple java service with a single getBooks() method
> > which return a collection of Books
> > I haven't got any error at jetty startup and I can see a wsdl at
> http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl
> >
> > but nothing at http://localhost:8080/yuipoc-webapp/cxf/books or any
> other
> > rest-like address
> >
> > Where am I wrong ?
> > Thanks
> >
>



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

Re: Problem writing restful services with Spring

Posted by Christian Blavier <cb...@gmail.com>.
No idea ? Anyone ?
I'm still blocked on this.. :/

2007/7/3, Christian Blavier <cb...@gmail.com>:
>
> Hello,
>
> I am currently using CXF 2.0-SNAPSHOT, and I've got some trouble writing
> restful services with CXF.
>
> Here is my spring configuration :
>
> <beans>
>
> <bean id="JaxWsServiceFactoryBean" class="
> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
>
> <property name="wrapped" value="false"/>
>
> </bean>
>
> <jaxws:endpoint id="restfulServer"
>
> implementor="#bookService"
>
> address="/bookService"
>
> bindingUri="http://apache.org/cxf/binding/http" >
>
> <jaxws:serviceFactory>
>
> <ref bean= "JaxWsServiceFactoryBean"/>
>
> </jaxws:serviceFactory>
>
> </jaxws:endpoint>
> </
> beans>
> My bookService is a simple java service with a single getBooks() method
> which return a collection of Books
> I haven't got any error at jetty startup and I can see a wsdl at http://localhost:8080/yuipoc-webapp/cxf/bookService?wsdl
>
> but nothing at http://localhost:8080/yuipoc-webapp/cxf/books or any other
> rest-like address
>
> Where am I wrong ?
> Thanks
>