dcsimg
APACHE HTTP CLIENTCOMPONENT
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, December 6, 2002 03:43 PM

Error 405 Hi, Iam using the Apache HTTP CLient component to submit some form info to a external site and get back the response.Iam getting anerror 405.Basically we are trying to submit info to a webportal server programatically and get the response back from that remote server. Any Suggestions are appreciated My Code: My Code: org.apache.commons.httpclient.Header CONTENT_TYPE = new org.apache.commons.httpclient.Header("Content-Type","text/html"); org.apache.commons.httpclient.HttpClient client=new org.apache.commons.httpclient.HttpClient(); //org.apache.commons.httpclient.HttpConnection con=new org.apache.commons.httpclient.HttpConnection("portal.cpn.vwg",)   More>>
Error 405

Hi,
Iam using the Apache HTTP CLient component to submit some form info to a external site and get back the response.Iam getting anerror 405.Basically we are trying to submit info to a webportal server programatically and get the response back from that remote server.

Any Suggestions are appreciated

My Code:
My Code:
org.apache.commons.httpclient.Header CONTENT_TYPE = new org.apache.commons.httpclient.Header("Content-Type","text/html");
org.apache.commons.httpclient.HttpClient client=new org.apache.commons.httpclient.HttpClient();
//org.apache.commons.httpclient.HttpConnection con=new org.apache.commons.httpclient.HttpConnection("portal.cpn.vwg",);
//org.apache.commons.httpclient.HttpState httpState= new org.apache.commons.httpclient.HttpState();

org.apache.commons.httpclient.methods.PostMethod post = new org.apache.commons.httpclient.methods.PostMethod();
post.setFollowRedirects(true);
java.net.URL url=new java.net.URL("http://xyz.abc.com/");
org.apache.commons.httpclient.NameValuePair form_data[] = new org.apache.commons.httpclient.NameValuePair[4];

form_data[0] = new org.apache.commons.httpclient.NameValuePair("language", "2");
form_data[1] = new org.apache.commons.httpclient.NameValuePair("user","amndsmndjn");
form_data[2] = new org.apache.commons.httpclient.NameValuePair("dealer","jnjfbvjf");
form_data[3] = new org.apache.commons.httpclient.NameValuePair("password","vfjbvfS");





post.setQueryString("/verifyuser.asp?language=");
post.setQueryString(form_data);

client.startSession(url);
client.executeMethod(post);
org.apache.commons.httpclient.Header resp[] =post.getResponseHeaders();

for(int i=0;i
System.out.println(resp[i]);


}
final String strGetResponseBody =post.getResponseBodyAsString();
System.out.println(strGetResponseBody);

ERROR MESSAGES:
Server: Microsoft-IIS/4.0

HTTP/1.1 405 Method not allowed
Server: Microsoft-IIS/4.0
Date: Fri, 06 Dec 2002 22:58:06 GMT
Connection: close
Content-Length: 545
Content-Type: text/html








HTTP Error 405



405 Method Not Allowed



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.



Please contact the server's administrator if this problem persists.





I was able to do this succesfully with other HTTP clinets ,but we have to go with Apache.

Any Suggestions Appreciated.

Thanks
Thandra    <<Less

Re: APACHE HTTP CLIENTCOMPONENT

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, December 9, 2002 06:41 AM

I think (?) it is telling you that the URL you are trying does not accept "POST" requests (that's the "Method" you are trying, which is apparently "Not Allowed" on the server side), so you have to do a "GET" instead.

About | Sitemap | Contact