[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-10-02
12
Medium Priority
?
161 Views
Last Modified: 2013-12-29
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.
0
Comment
Question by:rnicholus
  • 7
  • 5
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 19999826
Are you sure this is a web service? Web services usually use the HTTP port
0
 

Author Comment

by:rnicholus
ID: 20000778
Yes, this is a web service that I need to access from a data provider.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20000963
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rnicholus
ID: 20001209
>> 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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20001397
>>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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20001409
0
 

Author Comment

by:rnicholus
ID: 20001751
In your last post, could you please point out where is the info. for me to choose which port the reader is running on?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20001904
>>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
0
 

Author Comment

by:rnicholus
ID: 20010583
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.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1125 total points
ID: 20012209
1. If you can choose your client side port for the server app to connect to, choose a port >1024, perhaps something memorable like 22222

2. This depends on the protocol the server is using. If it's using JMS, then you'll need to use JMS on the port you chose in 1.
0
 

Author Comment

by:rnicholus
ID: 20041649
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20666964
:-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month18 days, 5 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question