You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Fabrício Cabral <fa...@gmail.com> on 2009/02/16 22:41:01 UTC

Hold a socket connection to a legacy application

Hi all!

I'm building a "proxy" web service that connects a legacy application
(via sockets). This web service works fine, but I'd like to put this
legacy connection persistent, i.e, connect to the legacy application
and hold this connecting until I call a disconnect() method of my web
service. So does anyone any idea how can I do that? I'm using
Axis2-1.4.1.

Thanks in advance,

-- 
--fx

Re: Hold a socket connection to a legacy application

Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Fabrício
> For historic purpose: I solved this problem using the sessions concept. How
> I did:
>
> 1) Implements the Lifecycle interface to POJO service's class
>
> 2) add <service name="ServiceName" scope="application"> </service> to
> axis2.xml and services.xml files
>
> 3) Overrride the init() and destroy() methos. In init() you should put your open
> socket and others methods and in destroy() you must the socket close
> operation;
>   
Yes, this should work fine, since you are using the application scope 
for your service

cheers
asankha
>>> I guess all you need is how to manipulate a client socket in Java [1]. You
>>> could use the SO_TIMEOUT = 0
>>>       
>> Will it maintain my socket connection opened after successives calls?
>> Could I use *the same* socket to send another "command" to my legacy
>> application? I'm asking it because I know by design web services are stateless,
>> so I think that will be destroy all socket connections when it ends. I'm wrong?
>>     
>
>   


-- 
Asankha C. Perera
http://adroitlogic.org

http://esbmagic.blogspot.com


Re: Hold a socket connection to a legacy application

Posted by Fabrício Cabral <fa...@gmail.com>.
For historic purpose: I solved this problem using the sessions concept. How
I did:

1) Implements the Lifecycle interface to POJO service's class

2) add <service name="ServiceName" scope="application"> </service> to
axis2.xml and services.xml files

3) Overrride the init() and destroy() methos. In init() you should put your open
socket and others methods and in destroy() you must the socket close
operation;

Thanks everybody!

>> I guess all you need is how to manipulate a client socket in Java [1]. You
>> could use the SO_TIMEOUT = 0
>
> Will it maintain my socket connection opened after successives calls?
> Could I use *the same* socket to send another "command" to my legacy
> application? I'm asking it because I know by design web services are stateless,
> so I think that will be destroy all socket connections when it ends. I'm wrong?

-- 
--fx

Re: Hold a socket connection to a legacy application

Posted by Fabrício Cabral <fa...@gmail.com>.
Hi Asankha!

> I guess all you need is how to manipulate a client socket in Java [1]. You
> could use the SO_TIMEOUT = 0

Will it maintain my socket connection opened after successives calls?
Could I use *the same* socket to send another "command" to my legacy
application? I'm asking it because I know by design web services are stateless,
so I think that will be destroy all socket connections when it ends. I'm wrong?

Thanks very much for your help,

-- 
--fx

Re: Hold a socket connection to a legacy application

Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Fabrício
> I'll look it, but I think need something more simple. I just want to
> my web service hold the
> socket connection with my application (i.e., don't closed the socket),
> so I won't need
> reestablish this connection.
>   
I guess all you need is how to manipulate a client socket in Java [1]. 
You could use the SO_TIMEOUT = 0

cheers
asankha

[1] http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html

-- 
Asankha C. Perera
http://adroitlogic.org

http://esbmagic.blogspot.com


Re: Hold a socket connection to a legacy application

Posted by Fabrício Cabral <fa...@gmail.com>.
Hi Asankha!

> What is the connection to your legacy backend? is it plain TCP sockets or
> HTTP etc?

It's a proprietary protocol over plain TCP.

> The Apache Synapse ESB (http://synapse.apache.org) allows you to build proxy
> services for transport, message format switching and message transformation
> and a load of other features. You may want to consider building your proxy
> in alignment with Synapse

I'll look it, but I think need something more simple. I just want to
my web service hold the
socket connection with my application (i.e., don't closed the socket),
so I won't need
reestablish this connection.

Thanks for your attention,

-- 
--fx

Re: Hold a socket connection to a legacy application

Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Fabrício
> I'm building a "proxy" web service that connects a legacy application
> (via sockets). This web service works fine, but I'd like to put this
> legacy connection persistent, i.e, connect to the legacy application
> and hold this connecting until I call a disconnect() method of my web
> service. So does anyone any idea how can I do that? I'm using
> Axis2-1.4.1.
>   
What is the connection to your legacy backend? is it plain TCP sockets 
or HTTP etc?

The Apache Synapse ESB (http://synapse.apache.org) allows you to build 
proxy services for transport, message format switching and message 
transformation and a load of other features. You may want to consider 
building your proxy in alignment with Synapse

cheers
asankha

-- 
Asankha C. Perera
http://adroitlogic.org

http://esbmagic.blogspot.com