Zhaohua,
(1) Please state the exact version of HttpClient you are using
(2) If you are using the latest release (3.0RC3) post the complete
context/wire log of the HTTP session and the source code of
PostXML.MyCredentialsProvider class
Oleg
On Wed, 2005-08-03 at 14:10 -0400, Zhaohua Meng wrote:
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]