So I have a java app that happily talks to a web service and asks it for stuff several hundred times in a span of 20 mintues.
Everything was working fine using the test web service (but slow).. when I connected my app the the real web service, I noticed it was much much faster but but I get an exception:
I/O exception (java.net.BindException) caught when processing request: Address already in use: connec
I put a Thread.sleep(1000)
between the consecutive web service calls and it seems to work but is there a better way to fix this rather than slowing down execution? Maybe an option I can set while initializing the webservice?
I am using axis 2, and java.
Code sample:
private String getPath(long id, String name) {
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
String path = name;
rDto[] roles = null;
FindParent currentEntity = new Stub.FindParent();
currentEntity.setEntityId(id);
//Send Request
Stub.FindParentE req = new Stub.FindParentE();
req.setFindParent(currentEntity);
//Get Response
FindParentResponseE response = null;
try {
response = stub.FindParent(req);
} catch (RemoteException e) {
logger.fatal("Error receiving parent" + e);
System.exit(0);
} catch (ServiceExceptionException0 e) {
logger.fatal("Error receiving parent" + e);
System.exit(0);
}
if ( ! (null == response.getFindParentResponse().get_return() )) {
oeDto[] ids = response.getFindParentResponse().get_return();
paths = new ArrayList();
for (int i = 0; i < ids.length; i++) {
//getPossibleHiearchy
String name = ids[i].getName();
long id = ids[i].getId();
paths.add( getBranch(id, name) + "/" + name);
}
...
}
return path;
}