hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalnichevski, Oleg" <oleg.kalnichev...@bearingpoint.com>
Subject RE: Slide and Jakarta-commons-httpClient
Date Tue, 10 Dec 2002 20:10:03 GMT
Still, I would not be so sure. I would not be surprised to a premature death if Sun's HttpConnection
implementation would automatically retry POST request as HTTP GET after having received status
code 405. That's why I personally had to abandon standard java.net classes. They do too much
on their own without first checking with me, if that's okay or not.
Are you absolutely positive that you are getting the expected response, and not just anything?

But if am wrong in my assumption, let's keep on digging
Oleg

-----Original Message-----
From: Thandra, Kiran [mailto:Extern.Kiran.Thandra@vw.com]
Sent: Tuesday, December 10, 2002 8:58 PM
To: 'Commons HttpClient Project'
Subject: RE: Slide and Jakarta-commons-httpClient


Hi,

Even i thought in the same way that it releated to server .But its not .i
was able to achieve this by using java.net.url and innovation api.but we are
planning to use apache as it offers more functionality we are lloking for.


I appreciate your suggestions.

This code works:

 java.net.URL url = new java.net.URL ("http://xyz.abc.com/verifyuser.asp");
  	  java.net.HttpURLConnection urlConn = (java.net.HttpURLConnection)
url.openConnection();
  	  urlConn.setRequestMethod("POST");
	  urlConn.setDoInput (true);
	  urlConn.setDoOutput (true);
      urlConn.setUseCaches (false);
      urlConn.setAllowUserInteraction(true);
      urlConn.setFollowRedirects(true);
      //urlConn.setInstanceFollowRedirects(true);
      urlConn.setRequestProperty ("Content-Type",
      "text/plain");
      java.io.DataOutputStream out = new
java.io.DataOutputStream(urlConn.getOutputStream());


      String content = "language=2"+"&user=bgbgb2"+
"&trlrd=jgjnbgjn"+"&password=MI9970";
      System.out.println("\n" + "sending form to HTTP server ...");
      out.writeBytes (content);
	  out.flush ();
	  out.close ();
	  // get input connection
       System.out.println(urlConn.getResponseCode());

      java.io.BufferedReader in = new java.io.BufferedReader(new
java.io.InputStreamReader
        (urlConn.getInputStream()));
     
	   System.out.println("reading HTML from HTTPserver");
       String line="";  
  	   while ((line = in.readLine()) != null) {
  			System.out.println(line);
  	   }




-----Original Message-----
From: Kalnichevski, Oleg [mailto:oleg.kalnichevski@bearingpoint.com]
Sent: Tuesday, December 10, 2002 2:50 PM
To: Commons HttpClient Project
Subject: RE: Slide and Jakarta-commons-httpClient


I think it status code 405 usually means that the given URL does not support
the method you are trying to execute. Most probably you are hitting wrong
URL. Please verify the target URL, while I am checking your code. I believe
POST method works slightly differently. Stay tuned
Oleg

-----Original Message-----
From: Thandra, Kiran [mailto:Extern.Kiran.Thandra@vw.com]
Sent: Tuesday, December 10, 2002 8:44 PM
To: 'Chang Sau Sheong'; 'Commons HttpClient Project'
Subject: RE: Slide and Jakarta-commons-httpClient


Hi ,
I have downloaded the latest jar file from CVS and Tried My Code I still get
the same error message.
I was able to achieve this by using java.net.url and innovation api.
Iam just wondering whats wrong in my code???

Suggestions appreciated.


java.net.URL u = new java.net.URL("http://abc.xyz.com");
org.apache.commons.httpclient.HttpClient client=new
org.apache.commons.httpclient.HttpClient();
	client.startSession(u);
org.apache.commons.httpclient.methods.PostMethod post = new
org.apache.commons.httpclient.methods.PostMethod();
org.apache.commons.httpclient.NameValuePair form_data[] = new
org.apache.commons.httpclient.NameValuePair[2];
			post.setRequestHeader("Content-type", "text/html");
form_data[0] = new org.apache.commons.httpclient.NameValuePair("uid",
"aaaaaa")
form_data[1] = new
org.apache.commons.httpclient.NameValuePair("pwd","bbbbb");
	
           post.setQueryString(form_data);
   	     int iResultCode = client.executeMethod(post);
		
		byte[] yaResponse = post.getResponseBody();
			
		client.endSession();


ERROR MESSAGE:
iResultCode = 405
Server response:
<html><head><title>Error 405</title>

<meta name="robots" content="noindex">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1"></head>

<body>

<h2>HTTP Error 405</h2>

<p><strong>405 Method Not Allowed</strong></p>

<p>The method specified in the Request Line is not allowed for the resource
identified by the request. Please ensure that you have the proper MIME type
set up for the resource you are requesting.</p>

<p>Please contact the server's administrator if this problem persists.</p>

</body></html>



Regards,
Thandra




-----Original Message-----
From: Chang Sau Sheong [mailto:cssheong@pacific.net.sg]
Sent: Tuesday, December 10, 2002 11:29 AM
To: Thandra, Kiran
Subject: Re: Slide and Jakarta-commons-httpClient


get the latest from cvs.
.sausheong
elipva Ltd


----- Original Message -----
From: "Thandra, Kiran" <Extern.Kiran.Thandra@vw.com>
To: "'Chang Sau Sheong'" <cssheong@pacific.net.sg>
Sent: Wednesday, December 11, 2002 12:29 AM
Subject: RE: Slide and Jakarta-commons-httpClient


> Iam very thank full for all your suggestions
> Iam using the Release 2.0 Alpha 1 - 5 October 2001 . What is the latest
> version i need to use.
>
>
> Regards,
> Kiran Thandra
>
>
>
> -----Original Message-----
> From: Chang Sau Sheong [mailto:cssheong@pacific.net.sg]
> Sent: Tuesday, December 10, 2002 11:23 AM
> To: Commons HttpClient Project; Extern.Kiran.Thandra@vw.com
> Subject: Re: Slide and Jakarta-commons-httpClient
>
>
> I forgot  ... this is for the latest build, won't work with ur current
(old)
> build. Get the latest from CVS.
> .sausheong
> elipva Ltd
>
>
> ----- Original Message -----
> From: "Chang Sau Sheong" <cssheong@pacific.net.sg>
> To: "Commons HttpClient Project"
> <commons-httpclient-dev@jakarta.apache.org>; <Extern.Kiran.Thandra@vw.com>
> Sent: Wednesday, December 11, 2002 12:20 AM
> Subject: Re: Slide and Jakarta-commons-httpClient
>
>
> > Code snippet. This works fine for me. Hope it helps.
> >
> > <snippet>
> >
> >   InputStream is = nulll;
> >
> >     try {
> >       // 1. create httpclient object
> >       HttpClient client = new HttpClient();
> >
> >       // 2. create config object
> >       HostConfiguration config = new HostConfiguration();
> >
> >       // 3. set the configuration for
> >       config.setHost(url, port, protocol);
> >
> >       // 4. apply the configuration
> >       client.setHostConfiguration(config);
> >
> >       // 5. create a post method
> >       UrlPostMethod post = new UrlPostMethod(url + loginPage);
> >
> >       // 6. set the query parameters you want to post to the page
> >       post.addParameter(key, value);
> >
> >       // 7. execute the method through the client object
> >       client.executeMethod(post);
> >
> >       // 8. get back the response as an input stream
> >       is = post.getResponseBodyAsStream();
> >
> >     }
> >     catch (Exception e) {}
> >
> >     // ... process your input stream
> >
> > </snippet>
> >
> >
> >
> > .sausheong
> > elipva Ltd
> >
> >
> > ----- Original Message -----
> > From: "Thandra, Kiran" <Extern.Kiran.Thandra@vw.com>
> > To: "'Commons HttpClient Project'"
> > <commons-httpclient-dev@jakarta.apache.org>
> > Sent: Wednesday, December 11, 2002 12:12 AM
> > Subject: RE: Slide and Jakarta-commons-httpClient
> >
> >
> > > Hello ,
> > >
> > > Need some help with using Http Client. Iam new to this technology
> > .Basically
> > > we are trying to post some form data and get to a internet site and
get
> > the
> > > response back.Iam getting error 405 method not allowed.I was
> successfully
> > > post this data using Innovation Http Client Api and java.net.Some
times
> > its
> > > taking lot time to execute this request.
> > >
> > > I think not properly using the API.
> > >
> > > Any Suggestions are greately appreciated
> > >
> > > MY CODE:
> > >
> > > org.apache.commons.httpclient.HttpClient client=new
> > > org.apache.commons.httpclient.HttpClient();
> > >
> > > java.net.URL url=new java.net.URL("http://xyz.abc.com");
> > > client.startSession(url);
> > > System.out.println("session started");
> > >    org.apache.commons.httpclient.methods.PostMethod method = new
> > > org.apache.commons.httpclient.methods.PostMethod("/verifyuser.asp");
> > >    org.apache.commons.httpclient.NameValuePair form_data[] = new
> > > org.apache.commons.httpclient.NameValuePair[2];
> > >
> > >             form_data[0] = new
> > > org.apache.commons.httpclient.NameValuePair("uid", "2");
> > >     form_data[1] = new
> > > org.apache.commons.httpclient.NameValuePair("pwd","55455545");
> > >
> > > //org.apache.commons.httpclient.HttpState st=;
> > >
> > > //System.out.println(st);
> > >
> > >          //method.addRequestHeader("Expect","100-continue");
> > >          method.setFollowRedirects(false);
> > >          method.setQueryString(form_data);
> > >          method.setUseDisk(false);
> > >
> > >
> > >
> > >            try{
> > >                 method.execute(new
> > > org.apache.commons.httpclient.HttpState(),conn);
> > >                  int i=client.executeMethod(method);
> > >
> > >          java.io.BufferedReader in = new java.io.BufferedReader(new
> > > java.io.InputStreamReader
> > >         (method.getResponseBodyAsStream()));
> > >
> > >      while ((line = in.readLine()) != null) {
> > >   System.out.println(line);
> > >      }
> > >
> > >
> > >       }catch(Throwable t){
> > >             t.printStackTrace();
> > >
> > >          }
> > >
> > > Regards,
> > > Kiran Thandra
> > >
> > >
> > >
> > > e
> > >
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Pill, Juergen [mailto:Juergen.Pill@softwareag.com]
> > > Sent: Tuesday, December 10, 2002 9:19 AM
> > > To: 'commons-httpclient-dev@jakarta.apache.org'
> > > Subject: Slide and Jakarta-commons-httpClient
> > >
> > >
> > > Hello,
> > >
> > > My name is Juergen Pill and I am committer at the Jakarta Slide
project.
> > >
> > > Currently the Slide Client API is using a very old version of the
> > > Jakarta-Commons-HttpClient API. In our night compile, the most recent
> > > HttpClient is used thus, giving a series of error messages (with
GUMP).
> > >
> > > I have started porting the Slide Client API to use the current version
> of
> > > this HttpClient and will remove the local clone of HttpClient from
> Slide.
> > >
> > > I would like to make some changes to the HttpClient API for a better
> Slide
> > > integration.
> > >
> > > 1) Performance  [use _socket.setTcpNoDelay(true); in HttpConnection].
> This
> > > change was applied to Slide and if applied to HttpClient it brings ca.
> 5%
> > > performance in our test suite.
> > > 2) Introduce new class HttpRequestBodyMethodBase [cloned from
PutMethod]
> > to
> > > be used in many WebDAV Methods, let PutMethod inherit from this class.
> > > 3) HttpState: allow the HttpState class to carry the url encoding
> (default
> > > UTF-8) [needed, if the content body contains URLs, which must be
> encoded,
> > > see also next point]
> > > 4) HttpClient, HttpMethod, HttpMethodBase: allow the method to carry
the
> > > HttpState (or WebDAVState inherits from HttpState).
> > > 5) Modification in the Head Method to work in an authentication
> > enviroment,
> > > NPE if only responseBodyConsumed() is called.
> > > 6) Performance: Enable the application to send the authentication
header
> > at
> > > the very first call (instead of waiting for a 401 response code) [not
> > > finally solved yet]
> > >
> > > I have changed the sources locally, both HttpClient and Slide API do
> > compile
> > > again, our WedDAV test suite reports no errors.
> > >
> > > Would you like me to post the changed sources as a zipped file to this
> > list
> > > or would you like me to make the changes directly in the HttpClient
CVS
> > > (please note, I am not a committer (yet)). I am familiar with the
> > HttpClient
> > > and helped developing it, while it was hosted at the Slide project.
> > >
> > > Best regards,
> > >
> > > Juergen Pill
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <mailto:commons-httpclient-dev-help@jakarta.apache.org>
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:commons-httpclient-dev-help@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:commons-httpclient-dev-help@jakarta.apache.org>
> >

--
To unsubscribe, e-mail:
<mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-httpclient-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:
<mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:commons-httpclient-dev-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>


Mime
View raw message