You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex O'Ree <sp...@gmail.com> on 2013/06/07 13:38:05 UTC

New to REST with CXF

I have a REST service that I'm building using CXF 2.7.5 that deploys
correctly (it is listed with /services and the link returns a valid
wadl), however I'm a bit confused as to what the actual invocation url
is.

WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
Base URL from WADL: <resources
base="http://localhost:8080/juddiv3/services/inquiryRest">

My implementation class has

Re: New to REST with CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Have a look at

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-Jettison

Try setting either "ignoreNamespaces" or namespaceMap properties, that 
should fix it

HTH, Sergey
On 08/06/13 14:37, Alex O'Ree wrote:
> I added rt-rs-extension-providers & jettison 1.3.3 dependencies. Now
> I'm getting the following
>
> WARNING: javax.ws.rs.InternalServerErrorException:
> java.lang.IllegalStateException: Invalid JSON namespace: urn:uddi-org
> :api_v3
>          at org.apache.cxf.jaxrs.provider.json.JSONProvider.writeTo(JSONProvider.java:377)
>          at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1326)
>
>
> After some googling, I found that wrapped mode has to be false? Is
> this in the class that has is returned representing the response or
> the REST service impl? Or perhaps is the problem related to something
> else?
>
>
> On Fri, Jun 7, 2013 at 3:44 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
>> add rt-rs-extension-providers & jettison 1.3.3 dependencies or
>> JacksonJaxbJsonProvider
>>
>> Cheers, Sergey
>>
>> On 07/06/13 19:10, Alex O'Ree wrote:
>>>
>>> And magically, the last link now works. Thanks for the help. Now I
>>> get, "No message body writer has been found for response class
>>> BusinessEntity." After a quick google, it says that I need
>>> BusinessEntity to have an @XmlRootElement annotation which is already
>>> present, so I'm not really sure why I'm getting the error message.
>>> This only applies to the methods that return JSON encoded messages.
>>> XML encoding works fine for BusinessEntity.
>>>
>>> On Fri, Jun 7, 2013 at 11:31 AM, Sergey Beryozkin <sb...@gmail.com>
>>> wrote:
>>>>
>>>> Hi
>>>>
>>>> On 07/06/13 12:43, Alex O'Ree wrote:
>>>>>
>>>>>
>>>>> Sorry, not sure what I hit.
>>>>>
>>>>> I have a REST service that I'm building using CXF 2.7.5 that deploys
>>>>> correctly (it is listed with /services and the link returns a valid
>>>>> wadl), however I'm a bit confused as to what the actual invocation url
>>>>> is.
>>>>>
>>>>> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
>>>>> Base URL from WADL: <resources
>>>>> base="http://localhost:8080/juddiv3/services/inquiryRest">
>>>>>
>>>>> My implementation class has a @Path("/inquiry/") annotation
>>>>> Same class has a method defined as
>>>>>        @GET
>>>>>        @Path("/inquiry/JSON/businessDetail/{id}")
>>>>>        @Produces("application/json")
>>>>> public org.uddi.api_v3.BusinessEntity
>>>>> getBusinessDetailJSON(@PathParam("id") String id) throws
>>>>> WebApplicationException {
>>>>> //stuff
>>>>> }
>>>>>
>>>>> The service is deployed using beans.xml
>>>>>
>>>>> I've tried a number of variants, but I can get my code to fire off.
>>>>> Only one returns an actual error message. The URLs I've tried are
>>>>> below
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 200 No binding operation info while invoking unknown method with
>>>>> params unknown.
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest?inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>>
>>>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>> 404
>>>>>
>>>>> any ideas?
>>>>>
>>>> The last URI works for me, I've added
>>>>
>>>>
>>>> @GET
>>>>       @Path("/inquiry/JSON/businessDetail/{id}")
>>>>       @Produces("application/json")
>>>>       public Book getBusinessDetailJSON(@PathParam("id") String id) throws
>>>>           WebApplicationException {
>>>>           return new Book("uddi", 128L);
>>>>       }
>>>>
>>>> to one of our tests, and this test passes:
>>>>
>>>> @Test
>>>>       public void testGetCustomBookResponse0() {
>>>>           String address = "http://localhost:" + PORT +
>>>>
>>>> "/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";
>>>>           WebClient wc = WebClient.create(address);
>>>>           Response r = wc.accept("application/json").get(Response.class);
>>>>           Book book = r.readEntity(Book.class);
>>>>           assertEquals("uddi", book.getName());
>>>>       }
>>>>
>>>> the only difference is that you have
>>>>
>>>>
>>>>
>>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>>>
>>>> and I have
>>>>
>>>>
>>>> "http://localhost:8080/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";
>>>>
>>>>
>>>> "/juddiv3/services/inquiryRest" vs "/bookstore"
>>>>
>>>> In "/juddiv3/services/inquiryRest",  can I assume you have
>>>>
>>>> war context: "juddiv3"
>>>> CXFServlet: "/services/*"
>>>> jaxrs:server/@address="/inquiryRest"
>>>>
>>>> ?
>>>>
>>>> Cheers, Sergey
>>>>
>>>>
>>>>>
>>>>> On Fri, Jun 7, 2013 at 7:38 AM, Alex O'Ree <sp...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> I have a REST service that I'm building using CXF 2.7.5 that deploys
>>>>>> correctly (it is listed with /services and the link returns a valid
>>>>>> wadl), however I'm a bit confused as to what the actual invocation url
>>>>>> is.
>>>>>>
>>>>>> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
>>>>>> Base URL from WADL: <resources
>>>>>> base="http://localhost:8080/juddiv3/services/inquiryRest">
>>>>>>
>>>>>> My implementation class has
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>> Blog: http://sberyozkin.blogspot.com
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com



Re: New to REST with CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
add rt-rs-extension-providers & jettison 1.3.3 dependencies or 
JacksonJaxbJsonProvider

Cheers, Sergey
On 07/06/13 19:10, Alex O'Ree wrote:
> And magically, the last link now works. Thanks for the help. Now I
> get, "No message body writer has been found for response class
> BusinessEntity." After a quick google, it says that I need
> BusinessEntity to have an @XmlRootElement annotation which is already
> present, so I'm not really sure why I'm getting the error message.
> This only applies to the methods that return JSON encoded messages.
> XML encoding works fine for BusinessEntity.
>
> On Fri, Jun 7, 2013 at 11:31 AM, Sergey Beryozkin <sb...@gmail.com> wrote:
>> Hi
>>
>> On 07/06/13 12:43, Alex O'Ree wrote:
>>>
>>> Sorry, not sure what I hit.
>>>
>>> I have a REST service that I'm building using CXF 2.7.5 that deploys
>>> correctly (it is listed with /services and the link returns a valid
>>> wadl), however I'm a bit confused as to what the actual invocation url
>>> is.
>>>
>>> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
>>> Base URL from WADL: <resources
>>> base="http://localhost:8080/juddiv3/services/inquiryRest">
>>>
>>> My implementation class has a @Path("/inquiry/") annotation
>>> Same class has a method defined as
>>>       @GET
>>>       @Path("/inquiry/JSON/businessDetail/{id}")
>>>       @Produces("application/json")
>>> public org.uddi.api_v3.BusinessEntity
>>> getBusinessDetailJSON(@PathParam("id") String id) throws
>>> WebApplicationException {
>>> //stuff
>>> }
>>>
>>> The service is deployed using beans.xml
>>>
>>> I've tried a number of variants, but I can get my code to fire off.
>>> Only one returns an actual error message. The URLs I've tried are
>>> below
>>>
>>> http://localhost:8080/juddiv3/services/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 200 No binding operation info while invoking unknown method with
>>> params unknown.
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest?inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>> 404
>>>
>>> any ideas?
>>>
>> The last URI works for me, I've added
>>
>>
>> @GET
>>      @Path("/inquiry/JSON/businessDetail/{id}")
>>      @Produces("application/json")
>>      public Book getBusinessDetailJSON(@PathParam("id") String id) throws
>>          WebApplicationException {
>>          return new Book("uddi", 128L);
>>      }
>>
>> to one of our tests, and this test passes:
>>
>> @Test
>>      public void testGetCustomBookResponse0() {
>>          String address = "http://localhost:" + PORT +
>> "/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";
>>          WebClient wc = WebClient.create(address);
>>          Response r = wc.accept("application/json").get(Response.class);
>>          Book book = r.readEntity(Book.class);
>>          assertEquals("uddi", book.getName());
>>      }
>>
>> the only difference is that you have
>>
>>
>> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
>>
>> and I have
>>
>> "http://localhost:8080/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";
>>
>>
>> "/juddiv3/services/inquiryRest" vs "/bookstore"
>>
>> In "/juddiv3/services/inquiryRest",  can I assume you have
>>
>> war context: "juddiv3"
>> CXFServlet: "/services/*"
>> jaxrs:server/@address="/inquiryRest"
>>
>> ?
>>
>> Cheers, Sergey
>>
>>
>>>
>>> On Fri, Jun 7, 2013 at 7:38 AM, Alex O'Ree <sp...@gmail.com> wrote:
>>>>
>>>> I have a REST service that I'm building using CXF 2.7.5 that deploys
>>>> correctly (it is listed with /services and the link returns a valid
>>>> wadl), however I'm a bit confused as to what the actual invocation url
>>>> is.
>>>>
>>>> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
>>>> Base URL from WADL: <resources
>>>> base="http://localhost:8080/juddiv3/services/inquiryRest">
>>>>
>>>> My implementation class has
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>> Blog: http://sberyozkin.blogspot.com


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: New to REST with CXF

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 07/06/13 12:43, Alex O'Ree wrote:
> Sorry, not sure what I hit.
>
> I have a REST service that I'm building using CXF 2.7.5 that deploys
> correctly (it is listed with /services and the link returns a valid
> wadl), however I'm a bit confused as to what the actual invocation url
> is.
>
> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
> Base URL from WADL: <resources
> base="http://localhost:8080/juddiv3/services/inquiryRest">
>
> My implementation class has a @Path("/inquiry/") annotation
> Same class has a method defined as
>      @GET
>      @Path("/inquiry/JSON/businessDetail/{id}")
>      @Produces("application/json")
> public org.uddi.api_v3.BusinessEntity
> getBusinessDetailJSON(@PathParam("id") String id) throws
> WebApplicationException {
> //stuff
> }
>
> The service is deployed using beans.xml
>
> I've tried a number of variants, but I can get my code to fire off.
> Only one returns an actual error message. The URLs I've tried are
> below
> http://localhost:8080/juddiv3/services/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
> 200 No binding operation info while invoking unknown method with
> params unknown.
> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
> http://localhost:8080/juddiv3/services/inquiryRest?inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
> http://localhost:8080/juddiv3/services/inquiryRest/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
> http://localhost:8080/juddiv3/services/inquiryRest/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
> http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
> 404
>
> any ideas?
>
The last URI works for me, I've added

@GET
     @Path("/inquiry/JSON/businessDetail/{id}")
     @Produces("application/json")
     public Book getBusinessDetailJSON(@PathParam("id") String id) throws
         WebApplicationException {
         return new Book("uddi", 128L);
     }

to one of our tests, and this test passes:

@Test
     public void testGetCustomBookResponse0() {
         String address = "http://localhost:" + PORT + 
"/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";
         WebClient wc = WebClient.create(address);
         Response r = wc.accept("application/json").get(Response.class);
         Book book = r.readEntity(Book.class);
         assertEquals("uddi", book.getName());
     }

the only difference is that you have

http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf

and I have

"http://localhost:8080/bookstore/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf";


"/juddiv3/services/inquiryRest" vs "/bookstore"

In "/juddiv3/services/inquiryRest",  can I assume you have

war context: "juddiv3"
CXFServlet: "/services/*"
jaxrs:server/@address="/inquiryRest"

?

Cheers, Sergey

>
> On Fri, Jun 7, 2013 at 7:38 AM, Alex O'Ree <sp...@gmail.com> wrote:
>> I have a REST service that I'm building using CXF 2.7.5 that deploys
>> correctly (it is listed with /services and the link returns a valid
>> wadl), however I'm a bit confused as to what the actual invocation url
>> is.
>>
>> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
>> Base URL from WADL: <resources
>> base="http://localhost:8080/juddiv3/services/inquiryRest">
>>
>> My implementation class has


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: New to REST with CXF

Posted by Alex O'Ree <sp...@gmail.com>.
Sorry, not sure what I hit.

I have a REST service that I'm building using CXF 2.7.5 that deploys
correctly (it is listed with /services and the link returns a valid
wadl), however I'm a bit confused as to what the actual invocation url
is.

WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
Base URL from WADL: <resources
base="http://localhost:8080/juddiv3/services/inquiryRest">

My implementation class has a @Path("/inquiry/") annotation
Same class has a method defined as
    @GET
    @Path("/inquiry/JSON/businessDetail/{id}")
    @Produces("application/json")
public org.uddi.api_v3.BusinessEntity
getBusinessDetailJSON(@PathParam("id") String id) throws
WebApplicationException {
//stuff
}

The service is deployed using beans.xml

I've tried a number of variants, but I can get my code to fire off.
Only one returns an actual error message. The URLs I've tried are
below
http://localhost:8080/juddiv3/services/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
200 No binding operation info while invoking unknown method with
params unknown.
http://localhost:8080/juddiv3/services/inquiryRest/inquiry/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
404
http://localhost:8080/juddiv3/services/inquiryRest/inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
404
http://localhost:8080/juddiv3/services/inquiryRest?inquiry/businessDetail/uddi:juddi.apache.org:businesses-asf
404
http://localhost:8080/juddiv3/services/inquiryRest/businessDetail/uddi:juddi.apache.org:businesses-asf
404
http://localhost:8080/juddiv3/services/inquiryRest/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
404
http://localhost:8080/juddiv3/services/inquiryRest/inquiry/JSON/businessDetail/uddi:juddi.apache.org:businesses-asf
404

any ideas?


On Fri, Jun 7, 2013 at 7:38 AM, Alex O'Ree <sp...@gmail.com> wrote:
> I have a REST service that I'm building using CXF 2.7.5 that deploys
> correctly (it is listed with /services and the link returns a valid
> wadl), however I'm a bit confused as to what the actual invocation url
> is.
>
> WADL URL: http://localhost:8080/juddiv3/services/inquiryRest?_wadl
> Base URL from WADL: <resources
> base="http://localhost:8080/juddiv3/services/inquiryRest">
>
> My implementation class has