• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing and REST

 
Ranch Hand
Posts: 167
Netbeans IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an EJB and can access the EJB via a RESTful Session Bean Delegator. So when I type in the URL in the browser, I see some XML output to the screen. How do I consume this in Java Swing?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By issuing an HTTP request, just like the browser. You can check out the low-level API in the java.net package, or you can use a higher-level 3rd-party API such as HttpClient.
 
Michelle Nicholes
Ranch Hand
Posts: 167
Netbeans IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I should have been more specific. I was asking if anyone had an examples of how to do it with whatever is the best technology since my EJB is on Glassfish and my front end is Java Swing.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My response addresses that need. If you are looking for example code, there's plenty to found with a search. The fact that the server is using EJBs or Glassfish is moot. From the outside, an HTTP request and response is independent of how it handled on the server.

Likewise, that the code is running as a Swing app is pretty much irrelevant as well. The server doesn't know or care what generated the request.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd prefer the Restlet framework or the Jersey library to implement REST clients. They are a little bit more high-level but any HTTP library like Apache HttpComponents should do fine. You can also find lots of sample code on the websites of the frameworks.

And as Bear said it doesn't matter for a REST client that your server side is implemented with EJBs or something else. That's the beauty of REST that you can use any technology which "speaks" HTTP.

Marco
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Ehrentreich wrote:That's the beauty of REST that you can use any technology which "speaks" HTTP.


Well put.
reply
    Bookmark Topic Watch Topic
  • New Topic