• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing and REST

 
Michelle Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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 Streeter
Ranch Hand
Posts: 120
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!