Hi Thom, try "/orgs.xml", not "orgs.xml". Server-relative URLs still have an absolute path.
hope that helps, Roland Thom Hehl <[EMAIL PROTECTED]> 12.09.2005 12:16 Please respond to "HttpClient User Discussion" To HttpClient User Discussion <[email protected]> cc Subject Cannot connect I really have done this before, but this is throwing me curves that I can't quite figure out. Here's the link I'm trying to create: http://orgmeta.xmlsweb.com:3245/orgs.xml? And here's the code I'm using... StringBuilder sb; String host="orgmeta.xmlsweb.com"; CgiProcessor cgi=new CgiProcessor(host,3245,true); BufferedReader br; try { br=new BufferedReader(new InputStreamReader( cgi.get("orgs.xml",""))); } catch (heavyweight.Exception he) { throw new IOException(he.toString()); } String str; while((str=br.readLine())!=null) { System.out.println(str); } File[] imgs=imgPath.listFiles(); return imgs; And the class that uses: package heavyweight.io; import java.lang.String; import java.lang.StringBuilder; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStream; import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.params.HttpClientParams; import org.apache.commons.httpclient.params.HttpMethodParams; import org.apache.log4j.Level; import org.apache.log4j.Logger; import heavyweight.io.CsvReader; /** * Automates an http session. * * Copyright Heavyweight Software, 2005 * */ public class CgiProcessor { /** * How many times to try before quitting */ public static final int RETRY_COUNT=5; /** * Default timeout */ public static final int TIMEOUT=5000; /** * Name of the interactive tools admin script */ public static final String ADMIN="/cgi-bin/listman/exec/admin.cgi"; /** * Name of button to republish listing index */ public static final String REPUBLISH_INDEX="setup_publish_listing_index"; /** * Name of button to republish listings */ public static final String REPUBLISH_LISTINGS="setup_publish_listings"; /** * value for the buttons */ public static final String PUBLISH_VALUE="++++Publish+++"; //For logging private static final Logger MyLog = Logger.getLogger(CgiProcessor.class.getName()); private HttpClient Client; private String Host; private int Port; /** * Constructor * @param host the host name (Note: not full URI, for instance * www.mysite.com, not www.mysite.com/admin.cgi. Defaults to * port 80. */ public CgiProcessor(String host) { this(host, 80, false); } /** * Constructor * @param host the host name (Note: not full URI, for instance * www.mysite.com, not www.mysite.com/admin.cgi * @param port the port number to use for this connection */ public CgiProcessor(String host, int port) { this(host, port, false); } /** * Constructor * @param host the host name (Note: not full URI, for instance * www.mysite.com, not www.mysite.com/admin.cgi * @param port the port number to use for this connection * @param log turn on or off logging for this session. */ public CgiProcessor(String host, int port, boolean log) { MyLog.setLevel(Level.DEBUG); MyLog.info("Constructor"); Host=host; Port=port; if(log) { System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty( "org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty( "org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug"); System.setProperty( "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); } if(!Host.contains(":")) { StringBuilder sb=new StringBuilder("http://"); sb.append(Host); Host=sb.toString(); } MyLog.debug(Host); //create a singular HttpClient object Client = new HttpClient(); //establish a connection within 5 seconds Client.getHttpConnectionManager(). getParams().setConnectionTimeout(TIMEOUT); Client.getHostConfiguration().setHost(Host, Port, "http"); HttpClientParams parms=Client.getParams(); parms.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true); parms.setCookiePolicy(CookiePolicy.RFC_2109); MyLog.info("Leaving constructor"); } /** * GET data from the server * @param url a URL that is relative to the host specified on the * constructor. e.g., cgi-bin/admin.cgi instead of * www.mysite.com/cgi-bin/admin.cgi * @param qString the query string to be passed in without the question mark * @return a string containing the HTML returned * @throws heavyweight.Exception for a variety of problems */ public InputStream get(String url, String qString) throws heavyweight.Exception { StringBuilder sb; GetMethod method = new GetMethod(url); method.setQueryString(qString); //execute the method InputStream responseBody = null; int tries=0; boolean successful=false; do { try { Client.executeMethod(method); responseBody = method.getResponseBodyAsStream(); successful=true; } catch (HttpException he) { sb=new StringBuilder("Http error connecting to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(he.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), he); } } catch (IOException ioe) { sb=new StringBuilder("Unable to connect to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(ioe.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), ioe); } } } while(!successful); //clean up the connection resources method.releaseConnection(); return responseBody; } /** * GET data from the host * @param url a URL that is relative to the host specified on the * constructor. e.g., cgi-bin/admin.cgi instead of * www.mysite.com/cgi-bin/admin.cgi * @param parms a name value pair array of parameters to pass to the * script. * @return a string containing the HTML returned * @throws heavyweight.Exception for a variety of problems */ public InputStream get(String url, NameValuePair[] parms) throws heavyweight.Exception { StringBuilder sb; if(MyLog.isDebugEnabled()) { MyLog.debug(url); } GetMethod method = new GetMethod(url); if(parms==null) { throw new IllegalArgumentException("Must pass paramters to execute (url, parms). For no parms, use execute(String)\n"); } method.setQueryString(parms); //execute the method InputStream responseBody = null; int tries=0; boolean successful=false; do { try { Client.executeMethod(method); responseBody = method.getResponseBodyAsStream(); successful=true; } catch (HttpException he) { sb=new StringBuilder("Http error connecting to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(he.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), he); } } catch (IOException ioe) { sb=new StringBuilder("Unable to connect to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(ioe.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), ioe); } } } while(!successful); //clean up the connection resources method.releaseConnection(); return responseBody; } /** * POST data to the host * @param url a URL that is relative to the host specified on the * constructor. e.g., cgi-bin/admin.cgi instead of * www.mysite.com/cgi-bin/admin.cgi * @param parms a name value pair array of parameters to pass to the * script. * @return a string containing the HTML returned * @throws heavyweight.Exception for a variety of problems */ public InputStream post(String url, NameValuePair[] parms) throws heavyweight.Exception { StringBuilder sb; PostMethod method = new PostMethod(url); if(parms==null) { throw new IllegalArgumentException("Must pass paramters to execute (url, parms). For no parms, use execute(String)\n"); } method.setRequestBody(parms); //execute the method InputStream responseBody = null; int tries=0; boolean successful=false; do { try { Client.executeMethod(method); responseBody = method.getResponseBodyAsStream(); successful=true; } catch (HttpException he) { sb=new StringBuilder("Http error connecting to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(he.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), he); } } catch (IOException ioe) { sb=new StringBuilder("Unable to connect to '"); sb.append(url); sb.append("'\n"); MyLog.error(sb.toString()); MyLog.error(ioe.getMessage()); if(++tries>RETRY_COUNT) { throw new heavyweight.Exception(sb.toString(), ioe); } } } while(!successful); //clean up the connection resources method.releaseConnection(); return responseBody; } } And here's the output logs.... rex version 0.9.3 copyright 2005, Heavyweight Software, all rights reserved Process started at 09/12/2005 at 06:06:07 AM 1 [main] INFO heavyweight.io.CgiProcessor - Constructor 1 [main] INFO heavyweight.io.CgiProcessor - Constructor 9 [main] DEBUG heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 9 [main] DEBUG heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:07:909 EDT [DEBUG] HttpClient - Java version: 1.5.0_04 2005/09/12 06:06:07:912 EDT [DEBUG] HttpClient - Java vendor: Sun Microsystems Inc. 2005/09/12 06:06:07:913 EDT [DEBUG] HttpClient - Java class path: rex.jar 2005/09/12 06:06:07:914 EDT [DEBUG] HttpClient - Operating system name: Linux 2005/09/12 06:06:07:914 EDT [DEBUG] HttpClient - Operating system architecture: i386 2005/09/12 06:06:07:915 EDT [DEBUG] HttpClient - Operating system version: 2.6.9-5.EL 2005/09/12 06:06:08:578 EDT [DEBUG] HttpClient - SUN 1.5: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS keystore; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores) 2005/09/12 06:06:08:579 EDT [DEBUG] HttpClient - SunRsaSign 1.5: Sun RSA signature provider 2005/09/12 06:06:08:583 EDT [DEBUG] HttpClient - SunJSSE 1.5: Sun JSSE provider(PKCS12, SunX509 key/trust factories, SSLv3, TLSv1) 2005/09/12 06:06:08:583 EDT [DEBUG] HttpClient - SunJCE 1.5: SunJCE Provider (implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC) 2005/09/12 06:06:08:584 EDT [DEBUG] HttpClient - SunJGSS 1.0: Sun (Kerberos v5) 2005/09/12 06:06:08:585 EDT [DEBUG] HttpClient - SunSASL 1.5: Sun SASL provider(implements client mechanisms for: DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5; server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5) 2005/09/12 06:06:08:614 EDT [DEBUG] DefaultHttpParams - Set parameter http.useragent = Jakarta Commons-HttpClient/3.0-rc3 2005/09/12 06:06:08:624 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.version = HTTP/1.1 2005/09/12 06:06:08:631 EDT [DEBUG] DefaultHttpParams - Set parameter http.connection-manager.class = class org.apache.commons.httpclient.SimpleHttpConnectionManager 2005/09/12 06:06:08:632 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = rfc2109 2005/09/12 06:06:08:632 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.element-charset = US-ASCII 2005/09/12 06:06:08:633 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.content-charset = ISO-8859-1 2005/09/12 06:06:08:641 EDT [DEBUG] DefaultHttpParams - Set parameter http.method.retry-handler = [EMAIL PROTECTED] 2005/09/12 06:06:08:643 EDT [DEBUG] DefaultHttpParams - Set parameter http.dateparser.patterns = [EEE, dd MMM yyyy HH:mm:ss zzz, EEEE, dd-MMM-yy HH:mm:ss zzz, EEE MMM d HH:mm:ss yyyy, EEE, dd-MMM-yyyy HH:mm:ss z, EEE, dd-MMM-yyyy HH-mm-ss z, EEE, dd MMM yy HH:mm:ss z, EEE dd-MMM-yyyy HH:mm:ss z, EEE dd MMM yyyy HH:mm:ss z, EEE dd-MMM-yyyy HH-mm-ss z, EEE dd-MMM-yy HH:mm:ss z, EEE dd MMM yy HH:mm:ss z, EEE,dd-MMM-yy HH:mm:ss z, EEE,dd-MMM-yyyy HH:mm:ss z, EEE, dd-MM-yyyy HH:mm:ss z] 2005/09/12 06:06:08:685 EDT [DEBUG] DefaultHttpParams - Set parameter http.connection.timeout = 5000 2005/09/12 06:06:08:737 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.single-cookie-header = true 2005/09/12 06:06:08:738 EDT [DEBUG] DefaultHttpParams - Set parameter http.protocol.cookie-policy = rfc2109 987 [main] INFO heavyweight.io.CgiProcessor - Leaving constructor 987 [main] INFO heavyweight.io.CgiProcessor - Leaving constructor 2005/09/12 06:06:09:019 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:410 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:411 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:418 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5668 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5668 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5669 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5669 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:13:428 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:431 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:431 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:438 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5688 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5688 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5688 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5688 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:13:440 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:450 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:450 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:451 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5701 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5701 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5707 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5707 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:13:459 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:468 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:469 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:470 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5719 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5719 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5720 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5720 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:13:472 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:481 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:481 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:482 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5732 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5732 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5732 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5732 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 2005/09/12 06:06:13:484 EDT [DEBUG] HttpConnection - Open connection to http://orgmeta.xmlsweb.com:3245 2005/09/12 06:06:13:487 EDT [DEBUG] HttpMethodDirector - Closing the connection. 2005/09/12 06:06:13:488 EDT [DEBUG] HttpMethodDirector - Method retry handler returned false. Automatic recovery will not be attempted 2005/09/12 06:06:13:494 EDT [DEBUG] HttpConnection - Releasing connection back to connection manager. 5744 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5744 [main] ERROR heavyweight.io.CgiProcessor - Unable to connect to 'orgs.xml' 5744 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com 5744 [main] ERROR heavyweight.io.CgiProcessor - http://orgmeta.xmlsweb.com Exception in thread "main" java.io.IOException: heavyweight.Exception: Unable to connect to 'orgs.xml' at retransform.idxloader.ParagonUtil.findImages(ParagonUtil.java:45) at rex.IdxFileConverter.main(IdxFileConverter.java:296) I just don't understand what to do next. The link works fine. Any ideas what I'm doing wrong? Thanks. -- "In every revolution, there is one man with a vision."--Jerome Bixby Thom Hehl <A href="www.heavyweightsoftware.com"> www.heavyweightsoftware.com</A> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
