Link to home
Start Free TrialLog in
Avatar of rnicholus
rnicholus

asked on

Building a client application: (Port number where a JAVA client-program runs + Build a listener to get data from web service).

I'm trying to connect to a web service data source.
The way the service works is like this:
1.) First, I need to call a LOGIN method. The LOGIN method has two arguments: the IP and the port number where the data source infrastructure will connect to and send the data.
2.) Second, there's a method to request the type of data that I need.
3.) Then lastly after I request type of data that I need, the infrastructure will connect to the port I specify and start sending data.

So the questions are:
1.) In the first step, how can I know the port number that the JAVA program uses to go outside?
So that I can supply this information to the LOGIN method along with the IP address (that I can get easily using InetAddress).

2.) How do I build the listener to receive stream of data that is being pushed from the server?

I'm using J2SE 1.5.

Thanks in advance for all the help.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you sure this is a web service? Web services usually use the HTTP port
Avatar of rnicholus
rnicholus

ASKER

Yes, this is a web service that I need to access from a data provider.
If it's running on a non-standard port

a. You'll need to know what that port is - you can't guess
b. You'll probably need to use custom Socket programming to consume it, unless of course it's just a normal webservice running on a non-standard port
>> a. You'll need to know what that port is - you can't guess
Is there anyway I know from the JAVA program itself which port it's running on so that
my JAVA program can send that information (the IP and the port number) to the LOGIN method() of the web service?
Then the web-service data source will be able to push the data to exactly where my JAVA program is currently running.
>>Is there anyway I know from the JAVA program itself

If you have control of the port, you can choose it. Otherwise do a

netstat -ban

to try to determine which port it's listening on
In your last post, could you please point out where is the info. for me to choose which port the reader is running on?
>>where is the info. for me to choose which port the reader is running on?

If you have access to it, wherever its Socket is created
CEHJ,

Thanks for the ongoing help. I think I'm still confused about the overall concept here.
Below I include some snippets of my code that hopefully will help the discussion.

In the login() method below, I need to provide the IP and PORT number .
The way it works is that after I request subscription data the data-provider infrastructure will connect to the IP and PORT I
specify and start sending data.  

What I'm not sure is:
1.) Which port number I should provide in the code? Can I just choose any port?
What needs to be considered when I choose the port?

2.) After successful login() call and subscribe() call below? How should I build listener to listen to the data?
I read somewhere that I need to use JAVA Messaging Service?

-----------------------------------------------------------------------------------
MyWebServiceLocator locator = new MyWebServiceLocator();
     
MyWebServiceServerSoap speedService = locator.getMyWebServiceServerSoap

// ******************************
// *** LOGIN ***
// ******************************
login_result = speedService.login(IP, PORT);
LOGGER.info("LOGIN status: " + login_result);

// ******************************
// *** SUBSCRIBE ***
// ******************************
if ( login_result == true )
{
subscribe_result = speedService.subscribe("type1Data", true);
LOGGER.info("SUBSCRIBE status: " + subscribe_result);
}
-----------------------------------------------------------------------------------

Thanks again for the ongoing help.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi CEHJ, sorry for replying so late.

I have several more questions:

1.) How do I know the protocol the server is using?
2.) Can I build a listener using native JAVA API?

Thanks.
:-)