views:

191

answers:

2

Hello!

I'm playing around with P2P.
I want to use JAX-WS for communication inside a P2P network.
Some peers are "behind a firewall", so they can't listen on ports. (They act as clients).
Other peers are allowed to listen on ports. (They act as servers (and clients)).

Now I want to be able to abstract from the fact, which peers are server and which not. So, peers have to be able to execute web-service commands on each other, with equal "abilities" for server peers and client peers.

In a "world without web-services" I would open a socket, and after the socket is opened, servers could talk to clients in the same way clients talk to servers (in both directions equally, because the connection stays open).

But JAX-WS is based on (stateless) HTTP, and there is no such thing as "HTTP connections".
So, servers couldn't make a client call, right?

What can be done to overcome this?

+1  A: 

Can I suggest that you take a look at JXTA ? This is a Java technology for building peer-to-peer systems, and will handle peers behind firewalls etc.

Obviously you may have to use JAX-WS, but you should have a look at JXTA if you're not aware of it. I suspect it'll solve a number of problems for you.

Brian Agnew
+1  A: 

in web service paradigm, you have a 'DIRECTION' for call, there is a client (request initiator) and service (request servant) ... so, if you make both entities (station1 and station2) be in the same time ws-client and ws-server, you can solve this issue.

Another option for clients behind firewall is to POLL the ws-server (client calls periodically the ws to find out news)

silmx
In my question I have written, that some peers are clients-only because they're firewalled. So both client and server will not work for all peers; I was also thinking about periodic calls, but that would question the necessity for JAX-WS at all.
ivan_ivanovich_ivanoff
polling is just a way to use WS. - WS comes with benefits (simplified communication)
silmx