Monday, July 12, 2004

Socket Timeout Exception in Web Service

Help!

I have exposed 2 methods in a Web Service using Apache Axis 1.1 viz.
1. public String serviceMethod()
2. public String sayNow()

Method 2 simply returns a String "Hello"

Method 1 i.e. serviceMethod() loads a class from its local file system and calls its only method say test1(). Method name is discovered through Reflection API.

Interestingly, if test1() simply contains self-contained byte codes, works fine! But now when I have test1() call the Web Service method sayNow(), problem occurs.

Snippet of method test1() is...

...

Options options = new Options(args);
String endpointURL = options.getURL();
System.out.println("End point URL is :" + endpointURL);
args = options.getRemainingArgs();

Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
call.setOperationName( new QName("MyService2", "sayNow") );
call.setReturnType( XMLType.XSD_STRING );

System.out.println("Invoking sayNow()...");
String res = (String)call.invoke( new Object[] {} ); /* Marked */

System.out.println("\nYou typed " + res);

...

So invoking serviceMethod() loads a class TestClient.class from its local file system. After loading this class, it calls method test1() on it whose snippet is pasted above. This method in turn calls sayNow() as seen. In short, a Web Service call another Web Service call. I get a Socket Timeout Exception at /* Marked */

If I run TestClient through a command prompt, it works great again. I am not sure what the problem may be here...any suggestions!

Regards
Sandeep

Web Services And Mobile Agents

Pop, Click Here...Toward Synthesis of Web Services and Mobile Agents