hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Becke <be...@u.washington.edu>
Subject Re: HTTPClient query
Date Wed, 26 Feb 2003 20:27:18 GMT
Hi Dheeraj,

Are you hitting "https://websmp203.sap-ag.de/" through a proxy?  If so, 
you you will need to setup the HttpClient instance for the proxy.  You 
will also need to supply NTLM credentials if it is an NTLM proxy.  Are 
you able to connect to other pages on this site besides the login page?

Mike

Dheeraj wrote:
> Hi Mike:
> 
> Thanks for your reply. I have posted the question to groups too.
> I am trying to log the site https://websmp203.sap-ag.de/login which is authenticated
by a proxy or NTLM. This would make it clear what I want.
> I have tried both UsernamePasswordCredentials, and the NTCredentials.
> I get a null at the line, and throws exception. However sometimes it returns 404 too,
though the site is 
> there.
> // execute the GET
>         int status = client.executeMethod( get );
> 
> My code does work for 
> HTTP, HTTPS (with out authentication) , and authentication for Tomcat.
> 
> I hope I am sufficiently clear. Would you please solve the mystery,
> 
> Thank You
> 
> Dheeraj
> 
> 
> Following are the details with respect to the problem.
> 
> package com.kcit.jakarta;
> 
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.UsernamePasswordCredentials;
> import org.apache.commons.httpclient.SimpleHttpConnectionManager;
> import org.apache.commons.httpclient.HostConfiguration;
> import org.apache.commons.httpclient.NTCredentials;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.PostMethod;
> 
> public class BasicAuthenticatonExample {
> 
>     public BasicAuthenticatonExample() {
>     }
> 
>     public static void main(String[] args) throws Exception {
>         HttpClient client = new HttpClient();
>      client.setConnectionTimeout(100000000);
> 
>     client.getState().setCredentials(
>                 "SAP Service Marketplace",
>                 new UsernamePasswordCredentials(<my-usesr-id>, <password>
)
>         );
> 
> 
> 
>     GetMethod get = new GetMethod("https://websmp203.sap-ag.de/login");
> 
> 
>         get.setDoAuthentication(true);
> 
>         // execute the GET
>         int status = client.executeMethod( get );
> 
>         // print the status and response
>         System.out.println(status +  "\n" +get.getResponseBodyAsString());
> 
>         // release any connection resources used by the method
>         get.releaseConnection();
>     }
> }
> 
> 
>   ----- Original Message ----- 
>   From: Michael Becke 
>   To: Dj 
>   Sent: Wednesday, February 26, 2003 7:18 PM
>   Subject: Re: HTTPClient query
> 
> 
>   Hello Dheeraj,
> 
>   If you could, please provide more information about what you are trying 
>   and what is failing.  A test case that shows the problem is always 
>   good.  Also, please post the question to the HttpClient mailing list at 
>   commons-httpclient-dev@jakarta.apache.org (you will have to subscribe 
>   first).  This will ensure that others can benefit from any possible 
>   solution.
> 
>   A http 404 response means that the file was not found.  Are you sure 
>   that you are posting to a URL that exists?
> 
>   Mike
> 
>   On Wednesday, February 26, 2003, at 12:33 AM, Dj wrote:
> 
>   > Hi Michael:
>   > 
>   > Please refer it to /commons/HTTPClient and a sample program written by 
>   > you BasicAuthenticatonExample.java.
>   > I am able to run this program for
>   > 1. simple HTTP
>   > 2. HTTPS
>   > 3. HTTP with Basic authenticator - tested on Tomcat's Manager.
>   > 
>   > I am stuck as I wish to hook on to a site which has a Basic 
>   > authentication with HTTPS. All the while I get a 404 Screen.
>   > Would you please help me with it. You code is very easy to implement 
>   > except for this case.
>   > 
>   > I need to make this tool very urgently. A quick technical help by is 
>   > highly appreciated.
>   > 
>   > Thank You,
>   > 
>   > 
>   > Dheeraj Srivastava
> 
> 
> 


Mime
View raw message