Server to Client Notification / Web service(jax-ws) to client communication - java

I am going to write a smart client application. This application will be swing based desktop client that will communicate with web service. I want to be a message has been sent to client from web service when any change occurs at server side file system. I wanted to use web services but I am not sure how I would implement a two-way communication between the server and client. Is it possible? If so how? If not what are the alternatives?

You have to program your client to be able to ping a request after a predefined frequency to check if there is a changes occurred on the server side. The client expect the changes occurred on the server or null if no change.

Related

Server as both client and server in Java

I am a newbie to server side operations. I am just wondering can a Java server be a server as well as client?
Here is a scenario, Client-A connects to Server-A and requests some data from Server-A. Server-A don't have that data but it knows Server-B has that. Can Server-A pull that data from Server-B and push it to Client-A.
Any help to understand this concept would be appreciated.
Thanks in advance!
"Client" and "Server" are highly context-dependant. For example, your typical web server will probably be the "Server" on a http connection. On the other hand, it will probably be the "Client" for a database, and potentially other services (such as a web service, where it acts as the client on another http connection).
In your example Client A is a client for Server A and Server A is a client of Server B.
To put in other words Server A acts as a server for client A and Server B acts as a server for Server A.
The terms server and client are used depending on the context. I hope I have not confused you.

How to test client- server architecture when using UDP?

I'm creating a small multiplayer game project using Java and I wanted to know if it were possible to test the client- server architecture on one machine. At the moment there is 1 client and 1 server, the client can send messages to the server as the server listens, then when the server responds to the client, instead of the clients listener reading the packet it gets looped back to the server.
Does anyone know how I can fix this?

Check if client is online

So I have a server with a few clients.
When a client sends in a message I'd like the server to send it out to any one of the clients. However I don't really want the clients to be polling for messages, rather, I'd somehow like the server to check if they are online and then send them the message if they are.
I'm assuming the client will need a socket that's listening for incoming messages?
But what's a good method for the server to 'test' if the client is online? How the server know the address of the client?
I'm using Java with JAX-WS.
I'm sure there must be some method or design pattern for this that I'm not finding via google?

Web cilent and server communication throught firewall

I want to create a web application, which is divided into two part one is client and another is server.
Client:
Client part is on the shared server.
Client is the GWT Application which only use to display data (containing only ui elements and ui events).
Client application is used by server to view and present it's own data.
Server:
The server is the simple java web service (restlet).
The server is reside behind the firewall.
The server contains actual data.
There are N number of servers.
Server does not contains any view if server wants ro view data it will use the gwt client application.
Every server uses same gwt application to view it's own data.
Note :
Client does not contains any address of the server. server will send the request to view it's data.
There is no firewall inbound exception on server firewall to access server data from out side client
I need to communicate client and server through firewall, Is there any architecture or design pattern to implement this type of application?
I don't think that the firewall can bring new restrictions to a GWT application compared with other types of applications (clients).
In case you have the GWT client on one server which makes calls to a different server you might have some issues due to same origin restriction.
This can be resolved in several ways:
- your GWT application has a server-side part which calls the other servers. And your GWT client makes normal RPC / JSON calls to the GWT server side (on the same server).
- in case you want to make directly the call on the different server from your GWT client you can use JSONP or the restygwt library.

Tomcat Push to Java Client

I'm trying to build a Java web app that will let me browse a remote file system behind my NAT router. The client can talk outbound HTTP only.
I've got my Java client on the remote machine talking to my Tomcat server, which is then serving the data back up as web pages. Something like this:
File Server (java client) -> Web Server <- Browser
What I can't figure out is how to have the Tomcat server talk back to the remote Java client.
What I want to happen is:
User clicks on a folder in their browser.
Browser ajaxes to the server.
The Tomcat server contacts the remote java client.
The remote java client responds with the directory listing.
The Tomcat server sends back the new data formatted as HTML to the user.
I've looked at Comet and Tomcat 7's asynchronous stuff but I'm struggling!
If you need full-duplex communication over HTTP, than I strongly recommend using Atmosphere and Web Sockets. It simplifies server push a lot, and it's container agnostic (the framework).
You can use Async Http Client library for your remote java client in that case.
If you want to implement a PUSH behavior, then Commet is the way to go.
If there are few clients, perhaps you could solve your requirements by allowing the client to continuosly PULL changes from the server each few seconds.

Categories