• 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

Socket Server calling web service

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following requirement:

Create a socket server that accept request from clients (clients are implemented in C).

The request data form clients is in JSON format.

The data is deserialized (probably with Jackson).

The data is going to be used initially to call a web service. Later there might be a need to redirect the data to a Servlet, or to a different application so it can process it.

My question is, what is the best way to implement such a system? How should I implement the notification mechanism to notify the web service, Servlet etc?

Note: The socket server is a multi-thread application.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would use Jersey, the reference implementation for the JAX-RS API (for working with RESTful web services in Java). When you use it together with JAXB, it's quite easy to expose methods as web services, which can accept data in XML or JSON format. You don't have to do any low-level parsing and formatting of JSON data; Jersey and JAXB can do that almost automatically for you.

The Jersey user guide gives a good overview of how to use it.

In the project I'm currently working on, we're using Jersey and JAXB together with the Grizzly web server as described in section 11.3.1 of the user guide. Grizzly is the multi-threaded socket server.
 
John Dendrinos
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, maybe I was not clear enough, or maybe I did not understand your answer.

I have the socket server ready. It's a multi-threaded standalone java application that opens a java socket and listens for client requests.

My issue is about the mechanism to use when forwarding the client data to the web service, or to a Servlet, etc.

I need something flexible and generic.

I have been advised to use the Observable/Observer pattern but then I read that this might not be a very good idea (not very flexible?).

Also I don't know if this mechanism should be a different application, or part of the socket server application.
reply
    Bookmark Topic Watch Topic
  • New Topic