0

I have the following requirement:

I need to create a socket server that listens fro incoming requests. The socket clients are written in C. The clients send JSON data.

The client input needs to be redirected to different sources. for example there might be a need to call an internal or external web service(SOAP, JAX-WS).

My question is, what is the best way to achieve such a communication?

0

1 Answer 1

1

I would implement the redirecting service as an observer and notify him when your observable (the socket server that listens) is called. If you're not familiar with that pattern, have a look at http://en.wikipedia.org/wiki/Observer_pattern. You basically keep up the information flow by pushing your information further down the chain of processes instead of pulling it actively by your redirecting service.

I hope you didn't need any help with the SOAP, JAX-WS stuff - your requirement doesn't change anything compared to the way you would normally implement such a service. (If you're as lazy as me, go with the wsimport commandline application ^^)

Sign up to request clarification or add additional context in comments.

3 Comments

Let's say that I implement the socket server as a standalone application (I don't even know if that is the correct way to approach this). If I understand correctly what you 're saying is that this application should not interact with the web service directly. If I use this observable patern, should this be implemented as a separate java application? Should it be part of the web service application? Should it be running on a web container?
The short answer is: it depends :) Since you already have you socket server (as far as I understand it), I would start from there and don't change anything how he receives/marshalls the JSON data. Now that you got this data, you can send it to another webservice or whatever.. I would implement the class that actually sends your data to the webservice as the observer (thats what I meant). I don't really understand your comment though.. I never said that you should not interact with the webservice.
No, as I mentioned I have to create the socket server. I was not very clear, I meant the socket server should not interact directly with the web service, is that right? I am still not clear on where the observer should reside. It has to be part of the socket server application, or not?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.