Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SocketTimeOutException  RSS feed

 
dimpsonu arora
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using the follow code and getting SocketTimeOutException at
call.invoke();
public class SOAPCall extends AgentBase
{
public void NotesMain()
{
Session s = null;
Document doc = null;
try
{
s = getSession();
AgentContext ac = s.getAgentContext();
Database db = ac.getCurrentDatabase();
Agent agent = ac.getCurrentAgent();
System.out.println("ok so java agent is running");
// Retreive Args from SOAP Call Agent Data document
doc = db.getDocumentByID(agent.getParameterDocID());
Vector params = new Vector ();
Vector argName = doc.getItemValue("ArgName");
Vector argValue = doc.getItemValue("ArgValue");
Vector argType = doc.getItemValue("ArgType");
for (int i=0; i<argValue.size(); i++)
{
Class type = null;
int typeNumber = java.lang.Integer.parseInt((String) argType.elementAt(i));
switch (typeNumber)
{
case 0: // Empty
case 1: // Null
{
type = null;
break;
}
case 2: // Integer
{
type = Short.class;
break;
}
case 3: // Long
{
type = Integer.class;
break;
}
case 4: // Single
{
type = Float.class;
break;
}
case 5: // Double
{
type = Double.class;
break;
}
case 6: // Currency
{
type = Double.class;
break;
}
case 8: // String
{
type = String.class;
break;
}
case 11: // Boolean
{
type = Boolean.class;
break;
}
default: // should never get here
{
System.out.println("ERROR: Unknown Argument Data Type");
throw new IllegalArgumentException("Unknown Argument Data Type");
}
}
params.addElement(new Parameter((String) argName.elementAt(i), type, argValue.elementAt(i), null));
}
Call call = new Call();
String proxyHost = doc.getItemValueString("HTTPProxyHost");
if (proxyHost != null)
{
SOAPHTTPConnection conn = new SOAPHTTPConnection();
conn.setProxyHost(proxyHost);
if (doc.hasItem("HTTPProxyPort"))
conn.setProxyPort(doc.getItemValueInteger("HTTPProxyPort"));
if (doc.hasItem("HTTPTimeout"))
conn.setTimeout(doc.getItemValueInteger("HTTPTimeout"));
call.setSOAPTransport(conn);
}
call.setParams(params);
call.setTimeout(8000);
System.out.println(doc.getItemValueString("ServiceNamespace"));
call.setTargetObjectURI(doc.getItemValueString("ServiceNamespace"));
call.setMethodName(doc.getItemValueString("MethodName"));
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
System.out.println("ok so java agent is running and here i set the usrl adn call the invooke function");

URL url = new URL("http://10.16.142.169/p3/QS4CALBT.NSF/agtSOAP?OpenAgent");
Response resp = call.invoke(url, "");

System.out.println("got the response");
if (resp.generatedFault())
{System.out.println("error hai bhai");
Fault fault = resp.getFault();
doc.replaceItemValue("FaultCode", fault.getFaultCode());
doc.replaceItemValue("FaultString", fault.getFaultString());
doc.replaceItemValue("FaultActor", fault.getFaultActorURI());
}
else
{
Parameter result = resp.getReturnValue();
String typeName = result.getType().getName();
if ( (typeName.equals("short")) ||
(typeName.equals("java.lang.Short"))) {
doc.replaceItemValue("ReturnType", "2");// Integer
} else if ((typeName.equals("int")) ||
(typeName.equals("java.lang.Integer"))) {
doc.replaceItemValue("ReturnType", "3");// Long
} else if ((typeName.equals("float")) ||
(typeName.equals("java.lang.Float"))) {
doc.replaceItemValue("ReturnType", "4");// Single
} else if ((typeName.equals("long")) ||
(typeName.equals("java.lang.Long")) ||
(typeName.equals("double")) ||
(typeName.equals("java.lang.Double"))) {
doc.replaceItemValue("ReturnType", "5");// Double
} else if (typeName.equals("java.lang.String")) {
doc.replaceItemValue("ReturnType", "8");// String
} else if ((typeName.equals("boolean")) ||
(typeName.equals("java.lang.Boolean"))) {
doc.replaceItemValue("ReturnType", "11");// Boolean
} else {
System.out.println("Sadly ERROR: Unsupported Return Data Type");
throw new IllegalArgumentException("Unsupported Return Data Type " + typeName);
}
doc.replaceItemValue("ReturnValue", result.getValue().toString());
doc.replaceItemValue("ReturnName", result.getName());
}
doc.save();
}
catch(Exception e)
{
String faultcode = "";
String faultstring = "";
if (e instanceof NotesException) {
NotesException ne = (NotesException)e;
faultcode = "SOAP-ENV:Client.SOAPConnect";
faultstring = ne.getClass().getName() +" "+ ne.id +": " + ne.text;
System.err.println(faultstring);
} else if (e instanceof SOAPException) {
SOAPException se = (SOAPException)e;
faultcode = se.getFaultCode();
faultstring = se.getMessage();
} else {
faultcode = "SOAP-ENV:Client.SOAPConnect";
faultstring = e.toString();
}
e.printStackTrace();
if (doc != null) try
{
doc.replaceItemValue("FaultCode", faultcode);
doc.replaceItemValue("FaultString", faultstring);
doc.replaceItemValue("FaultActor", "");
doc.save();
} catch (NotesException ignore) {
// ignore
}
}
}
}



Exception is:
03/06/2006 11:02:45 AM HTTP JVM: http://10.16.142.105/p3/QS4CALBT.NSF/agtSOAP?O
penAgent
03/06/2006 11:02:45 AM HTTP JVM: ok so java agent is running and here i set the
usrl adn call the invooke function
03/06/2006 11:02:54 AM HTTP JVM: [SOAPException: faultCode=SOAP-ENV:Client; msg
=Read timed out; targetException=java.net.SocketTimeoutException: Read timed out
]
03/06/2006 11:02:54 AM HTTP JVM: at org.apache.soap.transport.http.SOAPHT
TPConnection.send(SOAPHTTPConnection.java:358)
03/06/2006 11:02:54 AM HTTP JVM: at org.apache.soap.rpc.Call.invoke(Call.
java:248)
03/06/2006 11:02:54 AM HTTP JVM: at SOAPCall.NotesMain(SOAPCall.java:103)

03/06/2006 11:02:54 AM HTTP JVM: at lotus.domino.AgentBase.runNotes(Unkno
wn Source)
03/06/2006 11:02:54 AM HTTP JVM: at lotus.domino.NotesThread.run(Unknown
Source)
03/06/2006 11:02:54 AM Closed session for abhi/HCLGGN Databases accessed: 1
Documents read: 1 Documents written: 1
03/06/2006 11:02:55 AM Closed session for abhi/HCLGGN Databases accessed: 4
Documents read: 0 Documents written: 0
03/06/2006 11:02:55 AM HTTP Server: Agent message: SOAP agent failed
03/06/2006 11:02:55 AM HTTP Server: Agent message: 1
03/06/2006 11:02:55 AM HTTP Server: Agent message: 2
03/06/2006 11:02:55 AM HTTP Server: Agent message: some crap error
03/06/2006 11:02:55 AM HTTP Server: Agent message: (SOAP-ENV:Client) Read timed
out on line 117
Can anybody help why it is happening. Thanks in Advance.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!