1 26 package com.scalagent.kjoram.ksoap; 27 28 import java.io.IOException ; 29 import java.io.InterruptedIOException ; 30 31 import com.scalagent.kjoram.excepts.*; 32 import com.scalagent.kjoram.jms.*; 33 import com.scalagent.kjoram.JoramTracing; 34 35 import com.scalagent.ksoap.*; 36 37 41 public class HttpConnection { 42 43 44 protected HttpTransport httpConnect = null; 45 46 protected String serverUrl; 47 48 protected boolean compress = false; 49 50 51 public HttpConnection(String serverUrl) { 52 this.serverUrl = serverUrl; 53 54 httpConnect = new HttpTransport(serverUrl,"ProxyService"); 56 } 57 58 64 public AbstractJmsReply call(AbstractJmsRequest request,String name, int cnxId) throws Exception { 65 SoapObject sO; 66 Object result = null; 67 68 try { 69 httpConnect.reset(); 70 71 if (JoramTracing.dbgClient) 72 JoramTracing.log(JoramTracing.DEBUG, 73 "HttpConnection.call(" + request + 74 "," + cnxId + ")"); 75 76 sO = ConversionSoapHelper.getSoapObject(request,name,cnxId); 78 79 int timer=10; 81 while (true) { 82 try { 83 result = httpConnect.call(sO); 84 85 if (JoramTracing.dbgClient) 86 JoramTracing.log(JoramTracing.DEBUG, 87 "HttpConnection.call result = " + result); 88 break; 89 } catch (InterruptedIOException iIOE) { 90 httpConnect.reset(); 91 continue; 92 } catch (IOException ioE) { 93 ioE.printStackTrace(); 94 95 if (!(request instanceof CnxConnectRequest)) { 97 if (JoramTracing.dbgClient) 98 JoramTracing.log(JoramTracing.DEBUG, 99 "timer=" + timer); 100 timer++; 101 Thread.sleep(timer*1000); 102 } else 104 throw ioE; 105 } 106 } 107 } 108 catch (Exception e) { 110 if (e instanceof IOException ) 113 throw e; 114 else if (e instanceof InterruptedException ) 116 throw e; 117 } 118 119 AbstractJmsReply reply = (AbstractJmsReply) ConversionSoapHelper.getObject((SoapObject)result); 121 if (JoramTracing.dbgClient) { 122 JoramTracing.log(JoramTracing.DEBUG, 123 "HttpConnection.call : reply=" + reply); 124 JoramTracing.log(JoramTracing.DEBUG, 125 " cnxId=" + cnxId); 126 if (reply != null) 127 JoramTracing.log(JoramTracing.DEBUG, 128 " correlationId=" +reply.getCorrelationId()); 129 JoramTracing.log(JoramTracing.DEBUG, 130 " request=" + request); 131 } 132 133 return reply; 135 } 136 137 } 138 | Popular Tags |