Re: Help please - htpclient-4.0alpha3
On Sun, 2008-03-16 at 15:00 +0530, Biju P wrote: Hi, I am working on a research, on web technologies. I have downloaded your httpclient4.0-alpha3. I have tried running ClientExecuteDirect.java program that comes with httpclient4.0-alpha3. But I am getting the below error message. executing request to http://issues.apache.org:80 log4j:WARN No appenders could be found for logger (org.apache.http.impl.client.ClientParamsStack). log4j:WARN Please initialize the log4j system properly. You need to create a file called log4j.properties and store it in the root of your classpath directory (I would expect to store it in WEB-INF/classes will work in your case). example log4j properties content: log4j.rootLogger=debug, stdout, logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.File=log.txt log4j.appender.logfile.MaxFileSize=512KB # Keep three backup files. log4j.appender.logfile.MaxBackupIndex=3 # Pattern to output: date priority [category] - message log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n HTH salu2 It would be great help, if you could help me on this. Thanks alot, Biju P M Mailto: [EMAIL PROTECTED] =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -- Thorsten Scherler thorsten.at.apache.org Open Source Java consulting, training and solutions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help please - htpclient-4.0alpha3
Hi Thorsten, Thank you very much. The issue has been resolved. Thanks alot, Biju P M Mailto: [EMAIL PROTECTED] Thorsten Scherler [EMAIL PROTECTED] 03/17/2008 01:30 PM Please respond to HttpClient User Discussion httpclient-users@hc.apache.org To HttpClient User Discussion httpclient-users@hc.apache.org cc Subject Re: Help please - htpclient-4.0alpha3 On Sun, 2008-03-16 at 15:00 +0530, Biju P wrote: Hi, I am working on a research, on web technologies. I have downloaded your httpclient4.0-alpha3. I have tried running ClientExecuteDirect.java program that comes with httpclient4.0-alpha3. But I am getting the below error message. executing request to http://issues.apache.org:80 log4j:WARN No appenders could be found for logger (org.apache.http.impl.client.ClientParamsStack). log4j:WARN Please initialize the log4j system properly. You need to create a file called log4j.properties and store it in the root of your classpath directory (I would expect to store it in WEB-INF/classes will work in your case). example log4j properties content: log4j.rootLogger=debug, stdout, logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.File=log.txt log4j.appender.logfile.MaxFileSize=512KB # Keep three backup files. log4j.appender.logfile.MaxBackupIndex=3 # Pattern to output: date priority [category] - message log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n HTH salu2 It would be great help, if you could help me on this. Thanks alot, Biju P M Mailto: [EMAIL PROTECTED] =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -- Thorsten Scherler thorsten.at.apache.org Open Source Java consulting, training and solutions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ForwardSourceID:NT284A =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
Re: Help please - htpclient-4.0alpha3
On Mon, 2008-03-17 at 13:37 +0530, Biju P wrote: Hi Thorsten, Thank you very much. The issue has been resolved. Thanks alot, Glad it works. salu2 Biju P M Mailto: [EMAIL PROTECTED] Thorsten Scherler [EMAIL PROTECTED] 03/17/2008 01:30 PM Please respond to HttpClient User Discussion httpclient-users@hc.apache.org To HttpClient User Discussion httpclient-users@hc.apache.org cc Subject Re: Help please - htpclient-4.0alpha3 On Sun, 2008-03-16 at 15:00 +0530, Biju P wrote: Hi, I am working on a research, on web technologies. I have downloaded your httpclient4.0-alpha3. I have tried running ClientExecuteDirect.java program that comes with httpclient4.0-alpha3. But I am getting the below error message. executing request to http://issues.apache.org:80 log4j:WARN No appenders could be found for logger (org.apache.http.impl.client.ClientParamsStack). log4j:WARN Please initialize the log4j system properly. You need to create a file called log4j.properties and store it in the root of your classpath directory (I would expect to store it in WEB-INF/classes will work in your case). example log4j properties content: log4j.rootLogger=debug, stdout, logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n log4j.appender.logfile=org.apache.log4j.RollingFileAppender log4j.appender.logfile.File=log.txt log4j.appender.logfile.MaxFileSize=512KB # Keep three backup files. log4j.appender.logfile.MaxBackupIndex=3 # Pattern to output: date priority [category] - message log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n HTH salu2 It would be great help, if you could help me on this. Thanks alot, Biju P M Mailto: [EMAIL PROTECTED] =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -- Thorsten Scherler thorsten.at.apache.org Open Source Java consulting, training and solutions - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how 2 supress contentType when using multipartentity
Please help me. I building a bot and trying to upload file along with form fields. when compare the request generated by httpclient with that of microsoft browser, I notice that httpclient is having following format after the header. ---boundaryid Content-Disposition: form-data; name=fieldname1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit value1 ---boundaryid Content-Disposition: form-data; name=fieldname2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit value2 ---boundaryid : : But internet explorer generates request in following format ---boundaryid Content-Disposition: form-data; name=fieldname1 value1 ---boundaryid Content-Disposition: form-data; name=fieldname2 value2 ---boundaryid : : Notice the Content-Type and Content-Transfer-Encoding fields are populated by HttpClient. The webserver is not expecting these two fields and therefore throwing me an error as it is not able to trace the value for the required formfield (I guess it is poorly written server) How do I get rid of these extra two values while using httpclient multipartentity. please see snippet of my code below Part[] parts = new Part[files.length + nvPairs.length]; //setup form fields for(int i = 0 ; i nvPairs.length ; i++){ parts[i] = new StringPart(nvPairs[i].getName(), nvPairs[i].getValue(),CHAR_SET); } //setup files for(int i = nvPairs.length, j=0 ; j files.length ; j++,i++){ File targetFile = new File(files[j].getValue()); parts[i] = new FilePart(files[j].getValue(), targetFile); } post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); statusCode = httpClient.executeMethod(post); Please help ASAP. Thanks in advance. -- View this message in context: http://www.nabble.com/how-2-supress-contentType-when-using-multipartentity-tp16098366p16098366.html Sent from the HttpClient-User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using HTTPClient to call Creative Commons Web Service
On Sat, 2008-03-15 at 10:00 -0700, Wayne Richards wrote: This is probably a newbie question, as I have just started working with the HTTPClient. The question is that I know that the following line placed in a browser address line will return what I want. http://api.creativecommons.org/rest/license/standard/issue?answers=%3Canswers%3E%0A%3Clicense-standard%3E%3Cderivatives%3Esa%3C%2Fderivatives%3E%0A%3Ccommercial%3Ey%3C%2Fcommercial%3E%0A%3Cjurisdiction%3Epl%3C%2Fjurisdiction%3E%0A%3C%2Flicense-standard%3E%0A%3C%2Fanswers%3E%0A Wayne, Use a traffic analyzer to capture packets generated by the browser and then program HttpClient to generate identical / compatible packets. Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how 2 supress contentType when using multipartentity
On Mon, 2008-03-17 at 11:30 -0700, ghanchakkar wrote: Please help me. I building a bot and trying to upload file along with form fields. when compare the request generated by httpclient with that of microsoft browser, I notice that httpclient is having following format after the header. ---boundaryid Content-Disposition: form-data; name=fieldname1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit value1 ---boundaryid Content-Disposition: form-data; name=fieldname2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit value2 ---boundaryid : : But internet explorer generates request in following format ---boundaryid Content-Disposition: form-data; name=fieldname1 value1 ---boundaryid Content-Disposition: form-data; name=fieldname2 value2 ---boundaryid : : Notice the Content-Type and Content-Transfer-Encoding fields are populated by HttpClient. The webserver is not expecting these two fields Then the webserver is buggy. and therefore throwing me an error as it is not able to trace the value for the required formfield (I guess it is poorly written server) How do I get rid of these extra two values while using httpclient multipartentity. Set them to null. Hope this helps. Oleg please see snippet of my code below Part[] parts = new Part[files.length + nvPairs.length]; //setup form fields for(int i = 0 ; i nvPairs.length ; i++){ parts[i] = new StringPart(nvPairs[i].getName(), nvPairs[i].getValue(),CHAR_SET); } //setup files for(int i = nvPairs.length, j=0 ; j files.length ; j++,i++){ File targetFile = new File(files[j].getValue()); parts[i] = new FilePart(files[j].getValue(), targetFile); } post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); statusCode = httpClient.executeMethod(post); Please help ASAP. Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How could cause connection reset
On Fri, 2008-03-14 at 11:24 +0800, hjw wrote: Hi,dear all: I trying to use httpclient to get data from a website once in 1 second ,but when the count of getting data is appropriate to above 300 times,the programme will show a connection reset exception,I must keep the programme to work no breaking,could you tell me what will cause the exception and how to prevent it. I am sorry for my pool English. regards, Raymond Raymond, What is it exactly you are doing? Are you sending a new HTTP request every second or do you send just _one_ HTTP request and then poll the data from the response output stream every second? Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How could cause connection reset
Oleg Kalnichevski , I am sending a new HTTP request every second and then get the response.butusually connection reset after between 400 and 500 times,and some can over 1000 times. Raymond 2008/3/18, Oleg Kalnichevski [EMAIL PROTECTED]: On Fri, 2008-03-14 at 11:24 +0800, hjw wrote: Hi,dear all: I trying to use httpclient to get data from a website once in 1 second ,but when the count of getting data is appropriate to above 300 times,the programme will show a connection reset exception,I must keep the programme to work no breaking,could you tell me what will cause the exception and how to prevent it. I am sorry for my pool English. regards, Raymond Raymond, What is it exactly you are doing? Are you sending a new HTTP request every second or do you send just _one_ HTTP request and then poll the data from the response output stream every second? Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Send/Receive serialized object using Apache's httpclient package
Hi, Is it possible send/receive serialized object using HttpClient? I always get java.io.StreamCorruptedException: invalid stream header Exception. Here is my server side (servlet code) public void doPost ( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(application/x-www-form-urlencoded); ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream()); ArrayList l = new ArrayList(); l.add(Index Server is running); oos.writeObject(l); } Client side code that access this servlet public OutputStream sendRequest (String method, HashMap args) throws IOException, IndexServerCommunicationException { PostMethod post = new PostMethod(m_url); try { post.setRequestEntity(new StringRequestEntity(something)); m_client.executeMethod(post); ObjectInputStream ois = new ObjectInputStream(post.getResponseBodyAsStream()); return ois; } finally { post.releaseConnection(); } } Any help is appreciated. Thanks -Valli - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How could cause connection reset
I think you are make spider. some server refuse you request when you send http request more frequence, like google 2008/3/18, hjw [EMAIL PROTECTED]: Oleg Kalnichevski , I am sending a new HTTP request every second and then get the response.butusually connection reset after between 400 and 500 times,and some can over 1000 times. Raymond 2008/3/18, Oleg Kalnichevski [EMAIL PROTECTED]: On Fri, 2008-03-14 at 11:24 +0800, hjw wrote: Hi,dear all: I trying to use httpclient to get data from a website once in 1 second ,but when the count of getting data is appropriate to above 300 times,the programme will show a connection reset exception,I must keep the programme to work no breaking,could you tell me what will cause the exception and how to prevent it. I am sorry for my pool English. regards, Raymond Raymond, What is it exactly you are doing? Are you sending a new HTTP request every second or do you send just _one_ HTTP request and then poll the data from the response output stream every second? Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How could cause connection reset
You are right,but data on the server I request is change frequence ,sometimes may be 2 version data in one second. 2008/3/18, 游泳池的鱼 [EMAIL PROTECTED]: I think you are make spider. some server refuse you request when you send http request more frequence, like google 2008/3/18, hjw [EMAIL PROTECTED]: Oleg Kalnichevski , I am sending a new HTTP request every second and then get the response.butusually connection reset after between 400 and 500 times,and some can over 1000 times. Raymond 2008/3/18, Oleg Kalnichevski [EMAIL PROTECTED]: On Fri, 2008-03-14 at 11:24 +0800, hjw wrote: Hi,dear all: I trying to use httpclient to get data from a website once in 1 second ,but when the count of getting data is appropriate to above 300 times,the programme will show a connection reset exception,I must keep the programme to work no breaking,could you tell me what will cause the exception and how to prevent it. I am sorry for my pool English. regards, Raymond Raymond, What is it exactly you are doing? Are you sending a new HTTP request every second or do you send just _one_ HTTP request and then poll the data from the response output stream every second? Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SSL Site
Hi .. I followed your steps . I have downloaded the certificate and stored as DER in local. Then I tried to execute the following command. keytool -keystore C:\Program Files\Java\jdk1.6.0\jre\lib\security\cacerts -import -alias mysecurestore -file C:\temp\certfile.cer -trustcacerts Its asking for a password. I am not sure , What password to supply. Can you please suggest me. olegk wrote: On Wed, 2007-05-02 at 22:22 -0700, RossW wrote: ok cool...i fixed the problem. So first of all i had to connect through proxy first and then secondly i had to add the certificate to the keystore and then add the keystore as a property to code..now working fine. so here is the code which made all the difference. first i had to export the cert from the site...once logged in i just double clicked on the lock icon in IE (on the status bar down the bottom of IE when logged into the secure site)and then found and copy to file button. I saved it as a DER encrypted file to say c:\temp\certfile.cer and then using keytool as follows (keytool can be found in the JDK bin folder) keytool -keystore C:\Program Files\Java\jdk1.6.0\jre\lib\security\cacerts -import -alias mysecurestore -file C:\temp\certfile.cer -trustcacerts System.setProperty(javax.net.ssl.trustStore, C:\\Program Files\\Java\\jdk1.6.0\\jre\\lib\\security\\cacerts); and now is working like a charm. I hope this comes in handy for someone else in future cuz this one really sucked. Ross You may consider using AuthSSLProtocolSocketFactory if you want to avoid having to modify the cacerts file http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/ http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/ssl/AuthSSLProtocolSocketFactory.java?view=markup For details see http://jakarta.apache.org/commons/httpclient/sslguide.html Oleg RossW wrote: ok now i am getting this...the change i made which was causing the prev error was to connect via proxy first. Funny thing was that i was told without any doubt that it was not proxied. Anyways now i am getting SSL cert related errors javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown Source) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.flush(Unknown Source) at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(Unknown Source) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(Unknown Source) at org.apache.commons.httpclient.HttpMethodBase.execute(Unknown Source) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(Unknown Source) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(Unknown Source) at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source) at org.apache.commons.httpclient.HttpClient.executeMethod(Unknown Source) at chester_japp.Chester_queue.record_proc(Chester_queue.java:129) at chester_japp.Chester_queue.run(Chester_queue.java:382) at java.lang.Thread.run(Unknown Source) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.validator.PKIXValidator.doBuild(Unknown Source) at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) at sun.security.validator.Validator.validate(Unknown Source) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source) at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) at