Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35919 > unrolled thread

generic rest-api

Started byPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
First post2016-11-21 16:08 -0800
Last post2016-11-29 00:18 -0800
Articles 4 — 3 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  generic rest-api Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-11-21 16:08 -0800
    Re: generic rest-api Arne Vajhøj <arne@vajhoej.dk> - 2016-11-21 19:59 -0500
      Re: generic rest-api Sebastian <nowhere@nirvana.org> - 2016-11-22 21:46 +0100
        Re: generic rest-api Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-11-29 00:18 -0800

#35919 — generic rest-api

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-11-21 16:08 -0800
Subjectgeneric rest-api
Message-ID<7194c303-1388-4e3f-b340-39cd7d129653@googlegroups.com>
Hello,

I'm writing a framework which should be also accessable with a webservice. At the moment I'm using Jetty for the server. I have got a set of objects and each object should be defined as a webservice with a REST-API which returns the object as a JSON structure.

I need a call like http://server/"any path"/object_identifier/state which returns the current state of the object (I can get these information by calling a method).
And also I need for each method in the object a call like http://server/"any path"/object_identifier/methodname
The best case should be an automatically generation of all this URLs.

Is there any componente or framework to create a structure like this and is also portable to Tomcat, Jetty and Glassfish? I'm knowing Jersy, but I think I need some wrapper code around to do this.

Thanks 
Phil

[toc] | [next] | [standalone]


#35923

FromArne Vajhøj <arne@vajhoej.dk>
Date2016-11-21 19:59 -0500
Message-ID<o105a7$35b$1@gioia.aioe.org>
In reply to#35919
On 11/21/2016 7:08 PM, Philipp Kraus wrote:
> I'm writing a framework which should be also accessable with a
> webservice. At the moment I'm using Jetty for the server.

 > Is there any componente or framework to create a structure like this
 > and is also portable to Tomcat, Jetty and Glassfish?

Most likely any solution will be portable among any Java web container.

>                                                        I have got
> a set of objects and each object should be defined as a webservice
> with a REST-API which returns the object as a JSON structure.
>
> I need a call like http://server/"any path"/object_identifier/state
> which returns the current state of the object (I can get these
> information by calling a method). And also I need for each method in
> the object a call like http://server/"any
> path"/object_identifier/methodname The best case should be an
> automatically generation of all this URLs.
>
>                                                    I'm knowing
> Jersy, but I think I need some wrapper code around to do this.

The standard way is using JAX-RS.

I believe that Spring has its own non-standard thing.

http://server/"any path"/object_identifier/state is easy
as it is just a normal RESTful GET request.

http://server/"any path"/object_identifier/methodname is
tricky because it is not RESTful but RPC style.

RESTful only have resources and GET, POST, PUT and DELETE.

Arne

[toc] | [prev] | [next] | [standalone]


#35933

FromSebastian <nowhere@nirvana.org>
Date2016-11-22 21:46 +0100
Message-ID<o12aqf$e3k$1@news.albasani.net>
In reply to#35923
Am 22.11.2016 um 01:59 schrieb Arne Vajhøj:
> On 11/21/2016 7:08 PM, Philipp Kraus wrote:
>> I'm writing a framework which should be also accessable with a
>> webservice. At the moment I'm using Jetty for the server.
>
>> Is there any componente or framework to create a structure like this
>> and is also portable to Tomcat, Jetty and Glassfish?
>
> Most likely any solution will be portable among any Java web container.
>
>>                                                        I have got
>> a set of objects and each object should be defined as a webservice
>> with a REST-API which returns the object as a JSON structure.
>>
>> I need a call like http://server/"any path"/object_identifier/state
>> which returns the current state of the object (I can get these
>> information by calling a method). And also I need for each method in
>> the object a call like http://server/"any
>> path"/object_identifier/methodname The best case should be an
>> automatically generation of all this URLs.
>>
>>                                                    I'm knowing
>> Jersy, but I think I need some wrapper code around to do this.
>
> The standard way is using JAX-RS.
>
> I believe that Spring has its own non-standard thing.
>
> http://server/"any path"/object_identifier/state is easy
> as it is just a normal RESTful GET request.
>
> http://server/"any path"/object_identifier/methodname is
> tricky because it is not RESTful but RPC style.
>
> RESTful only have resources and GET, POST, PUT and DELETE.
>
> Arne
>
Yes, you should use a JAX-RS implementation. There are many of them, 
however. These links (one for Apache CXF, the other for Jersey/Jackson) 
were useful to me:

https://www.nabisoft.com/tutorials/java-ee/producing-and-consuming-json-or-xml-in-java-rest-services-with-jersey-and-jackson

https://idodevjobs.wordpress.com/2014/08/30/develop-a-simple-restful-webservices-using-apache-cxf-and-spring-framework/

You pays your money and you takes your choice.
--Sebastian

[toc] | [prev] | [next] | [standalone]


#35986

FromPhilipp Kraus <philipp.kraus.flashpixx@gmail.com>
Date2016-11-29 00:18 -0800
Message-ID<bec3ee92-9d1f-453f-a486-0dbbda359779@googlegroups.com>
In reply to#35933
Hello,

I have tested Jersey/Jackson and this is a good choice for me. In my case I need POST / GET and hopefully PUT and DELETE, but at the moment POST / GET are enough

Thanks for both answers.

Am Dienstag, 22. November 2016 21:46:18 UTC+1 schrieb Sebastian:
> Am 22.11.2016 um 01:59 schrieb Arne Vajhøj:
> > On 11/21/2016 7:08 PM, Philipp Kraus wrote:
> >> I'm writing a framework which should be also accessable with a
> >> webservice. At the moment I'm using Jetty for the server.
> >
> >> Is there any componente or framework to create a structure like this
> >> and is also portable to Tomcat, Jetty and Glassfish?
> >
> > Most likely any solution will be portable among any Java web container.
> >
> >>                                                        I have got
> >> a set of objects and each object should be defined as a webservice
> >> with a REST-API which returns the object as a JSON structure.
> >>
> >> I need a call like http://server/"any path"/object_identifier/state
> >> which returns the current state of the object (I can get these
> >> information by calling a method). And also I need for each method in
> >> the object a call like http://server/"any
> >> path"/object_identifier/methodname The best case should be an
> >> automatically generation of all this URLs.
> >>
> >>                                                    I'm knowing
> >> Jersy, but I think I need some wrapper code around to do this.
> >
> > The standard way is using JAX-RS.
> >
> > I believe that Spring has its own non-standard thing.
> >
> > http://server/"any path"/object_identifier/state is easy
> > as it is just a normal RESTful GET request.
> >
> > http://server/"any path"/object_identifier/methodname is
> > tricky because it is not RESTful but RPC style.
> >
> > RESTful only have resources and GET, POST, PUT and DELETE.
> >
> > Arne
> >
> Yes, you should use a JAX-RS implementation. There are many of them, 
> however. These links (one for Apache CXF, the other for Jersey/Jackson) 
> were useful to me:
> 
> https://www.nabisoft.com/tutorials/java-ee/producing-and-consuming-json-or-xml-in-java-rest-services-with-jersey-and-jackson
> 
> https://idodevjobs.wordpress.com/2014/08/30/develop-a-simple-restful-webservices-using-apache-cxf-and-spring-framework/
> 
> You pays your money and you takes your choice.
> --Sebastian

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web