Re: How to involke a webservice automatically every 5 minutes
Posted By:
Anonymous
Posted On:
Friday, October 22, 2004 03:17 PM
import java.io.*;
import java.net.*;
/* author Chad Salinas
* Chad Salinas goal to create a clean interface
*/
public class EchoServer
{
public static void main(String[] args )
{
try
{
// Chad Salinas - create it on 8189
// Myra - use any well known port
System.out.println("Creating ServerSocket on 8189");
ServerSocket s = new ServerSocket(8189);
while(true)
{
System.out.println("Calling accept");
// Chad Salinas - incoming socket
Socket incoming = s.accept( );
System.out.println("accept returned");
BufferedReader in = new BufferedReader
(new InputStreamReader(incoming.getInputStream()));
PrintWriter out = new PrintWriter
(incoming.getOutputStream(), true /* autoFlush */);
out.println( "Hello! Enter BYE to exit." );
// Myra - could be another design pattern
boolean done = false;
while (!done)
{
String line = in.readLine();
if (line == null)
done = true;
else
System.out.println(line);
if (line.trim().equals("BYE"))
{
out.println("Echo: Bye, Bye, Come Again!");
System.out.println("Echo: Bye, Bye, Come Again!");
done = true;
}
else
out.println("Echo: " + line);
}
// Myra - Is this plug & play?
incoming.close();
} // Chad Salinas - nice and clean finish
}
catch (Exception e)
{
System.out.println(e);
}
}
* 01/05/2004 Chad Salinas rmic