Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 51356 invoked from network); 3 Aug 2005 18:10:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Aug 2005 18:10:32 -0000 Received: (qmail 86298 invoked by uid 500); 3 Aug 2005 18:10:21 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 86139 invoked by uid 500); 3 Aug 2005 18:10:17 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 86122 invoked by uid 99); 3 Aug 2005 18:10:16 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 11:10:16 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_60_70,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [204.177.90.21] (HELO mmsmail.cgsh.com) (204.177.90.21) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Aug 2005 11:10:05 -0700 Received: from 10.1.1.22 by mmsmail.cgsh.com with ESMTP (SMTP Relay); Wed, 03 Aug 2005 14:08:55 -0500 X-Server-Uuid: CD10BE61-2DEF-48A3-8888-AA284D0EA513 To: "'Jakarta Commons Users List'" Subject: httpclient running in a loop MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.0.3 September 26, 2003 Message-ID: From: "Zhaohua Meng" Date: Wed, 3 Aug 2005 14:10:04 -0400 X-MIMETrack: Serialize by Router on NYSMTP01/SRVC/Cgsh(Release 6.5.4|March 27, 2005) at 08/03/2005 02:11:17 PM, Serialize complete at 08/03/2005 02:11:17 PM X-WSS-ID: 6EEFC9CD3BK473199-01-03 Content-Type: multipart/alternative; boundary="=_alternative 0063EF2D85257052_=" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --=_alternative 0063EF2D85257052_= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Gurus, My following code ends up in the httpclient sending request/getting response again and again, when Basic Authentication failed. How do I make it stop after "Authorization: Basic dGVzdGltYW46aW1hbjg=" header is sent to server and and the server responds with 401 (the second trip)? Thanks, Zhaohua public static void postWithSupportedAuth() throws IOException, HttpException, IllegalAccessException, InstantiationException, ClassNotFoundException, ParserConfigurationException { String secProviderName = "com.sun.crypto.provider.SunJCE"; java.security.Provider secProvider = (java.security.Provider)Class.forName(secProviderName).newInstance(); Security.addProvider(secProvider); String strURL = "http://driman8.cgsh.com/worksite/services/factory.asmx"; String strXMLFilename = "C:/project/junk/Test/Java Source/request.xml"; String requestDoc = ImanageCreateWorkspaceSOAP.getTestDoc(); // Prepare HTTP post PostMethod post = new PostMethod(strURL); post.setRequestEntity(new StringRequestEntity(requestDoc, "text/xml; charset=UTF-8","UTF-8")); post.setRequestHeader("Content-type", "text/xml; charset=UTF-8"); post.setRequestHeader("SOAPAction", "\"http://worksite.imanage.com/CreateWorkspace\"" ); HttpClient httpclient = new HttpClient(); post.getParams().setVersion(HttpVersion.HTTP_1_1); httpclient.getParams().setParameter(CredentialsProvider.PROVIDER, new PostXML.MyCredentialsProvider()); post.setDoAuthentication(true); try { int result = httpclient.executeMethod(post); System.out.println("Response status code: " + result); System.out.println("Response body: "); } finally { // Release current connection to the connection pool once you are done post.releaseConnection(); } } This message is being sent from a law firm and may contain confidential or privileged information. If you are not the intended recipient, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy. --=_alternative 0063EF2D85257052_=--