Hi,
I'm facing some trouble concerning heavy loads on soap rpc.
I coded a soap client that simulates several clients with a Thread
implementation.
My snippet code is:
public class SOAPClient
{
public static void main (String[] args) throws Exception
{
URL url = new URL(args[0]);
String sXML = null;
for (int i = 0; i < 50; i++)
{
sXML = "<?xml version=\"1.0\" encoding=\"US-ASCII\"?><request client
= \"client"+i+"\" action = \"action"+i+"\"><parameter name =
\"name"+i+"\">My Name"+i+"</parameter></request> ";
Call call = new Call();
call.setTargetObjectURI("urn:Connector");
call.setMethodName("sendRequest");
call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
Vector params = new Vector();
params.addElement(new org.apache.soap.rpc.Parameter("sXML",
String.class, sXML, null));
call.setParams(params);
(new TestThread(call, url)).start();
}
}
}
public class TestThread extends Thread
{
Call testCall = null;
URL url = null;
public TestThread(Call testCall, URL url)
{
this.testCall = testCall;
this.url = url;
}
public void run()
{
try {
org.apache.soap.rpc.Response resp = testCall.invoke(url, "");
if (resp.generatedFault())
{
Fault fault = resp.getFault();
System.out.println(this.getName() + "Fault Code = " +
fault.getFaultCode());
System.out.println(this.getName() + "Fault String = " +
fault.getFaultString());
}
else
{
org.apache.soap.rpc.Parameter result = resp.getReturnValue();
String res = result.toString();
Object obj = result.getValue();
String resp2 = obj.toString();
System.out.println(this.getName()+" - Result: "+resp2);
}
}
catch (Exception e)
{
System.out.println(this.getName() + " :Error! - " + e.getMessage());
}
}
}
, and I'm getting the following exception for most of the Threads (30 out of
50):
Thread-i Error opening socket: Connection refused: connect
Does anyone explain me why am I getting this? Is it because SOAP can only
handle about 20 http connections?
Tiago Fernandes Thomaz